Skip to content

Commit 4762547

Browse files
committed
added link to prev version of guides
1 parent 3d910f5 commit 4762547

35 files changed

+40
-70
lines changed

RoboFile.php

Lines changed: 6 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -42,76 +42,7 @@ function publish()
4242
->push()
4343
->run();
4444
}
45-
46-
47-
/**
48-
* builds docs for specific branch
49-
*/
50-
function docsBranch($branch)
51-
{
52-
$this->yell("Creating docs for $branch");
53-
$dir = "docs-$branch";
54-
55-
$this->taskGitStack()
56-
->cloneRepo('git@github.com:Codeception/Codeception.git', 'source')
57-
->run();
58-
59-
$this->taskGitStack()
60-
->dir('source')
61-
->checkout($branch)
62-
->run();
63-
64-
$this->taskCleanDir($dir)->run();
65-
66-
$this->taskWriteToFile("_includes/doc_$branch.html")
67-
->text('<div class="alert alert-danger">')
68-
->text('You are viewing documentation for Codeception <strong>' . $branch . '</strong>. ')
69-
->text('Switch to <a href="/docs">latest stable &raquo;</a>')
70-
->text('</div>')
71-
->run();
72-
73-
74-
$indexFile = $this->taskWriteToFile($dir . '/index.md')
75-
->line('---')
76-
->line('layout: doc')
77-
->line("title: Codeception $branch Documentation")
78-
->line('---')
79-
->text("\n\n{% include doc_$branch.html %}\n\n\n")
80-
->line("# Codeception $branch Guides\n\n");
81-
82-
$guides = Finder::create()
83-
->ignoreVCS(true)
84-
->depth('== 0')
85-
->name('*.md')
86-
->sortByName()
87-
->in('source/docs');
88-
89-
90-
foreach ($guides as $file) {
91-
$contents = file_get_contents($file->getRealPath());
92-
$name = substr($file->getBasename(), 0, -3);
93-
$title = preg_replace("(\d+-)", '', $name);
94-
if (preg_match('/^# (.*)$/m', $contents, $matches)) {
95-
$title = $matches[1];
96-
}
97-
$indexFile->line("* [$title](/$dir/$name)");
98-
99-
$this->taskWriteToFile($dir . '/' . $file->getBasename())
100-
->line('---')
101-
->line('layout: doc')
102-
->line('title: Codeception Documentation')
103-
->line('---')
104-
->line('')
105-
->line('')
106-
->text("{% include doc_$branch.html %}")
107-
->line('')
108-
->line('')
109-
->text($contents)
110-
->run();
111-
}
112-
$indexFile->run();
113-
// $this->taskDeleteDir('source')->run();
114-
}
45+
11546

11647
/**
11748
* @desc generates modules reference from source files
@@ -138,6 +69,9 @@ public function buildDocsGuides() {
13869
->sortByName()
13970
->in('guides');
14071

72+
$prevVersionDocs = [
73+
'01-Introduction.md', '02-GettingStarted.md', '03-AcceptanceTests.md', '04-FunctionalTests.md', '05-UnitTests.md', '06-ModulesAndHelpers.md', '06-ReusingTestCode.md', '07-AdvancedUsage.md', '07-BDD.md', '08-Customization.md', '09-Data.md', '10-APITesting.md', '11-Codecoverage.md', '12-ContinuousIntegration.md', '12-ParallelExecution.md','APITesting', 'AcceptanceTests', 'AdvancedUsage', 'BDD', 'Codecoverage', 'ContinuousIntegration', 'Customization', 'Data', 'Debugging', 'FunctionalTests', 'GettingStarted', 'Introduction', 'ModulesAndHelpers', 'ParallelExecution', 'Reporting', 'ReusingTestCode', 'UnitTests',
74+
];
14175
$guidesLinks = [];
14276

14377
foreach ($guides as $file) {
@@ -150,6 +84,7 @@ public function buildDocsGuides() {
15084
$title = preg_replace('/([a-z\d])([A-Z])/', '\\1 \\2', $title);
15185

15286
$contents = file_get_contents($file->getPathname());
87+
$pervVersionLink = in_array($file->getBasename(), $prevVersionDocs) ? '<div class="alert alert-success"><b>You are viewing docs for Codeception 5</b>. <a href="https://github.com/Codeception/codeception.github.com/blob/4.x/docs/' . $file->getBasename() . '">Switch to previous version of this guide</a> for Codeception 4.x</div>' : '';
15388

15489
foreach ([$file->getBasename(), $titleName . '.md'] as $filename) {
15590
$this->taskWriteToFile('docs/' . $filename)
@@ -158,6 +93,7 @@ public function buildDocsGuides() {
15893
->line("title: $title - Codeception Docs")
15994
->line('---')
16095
->line('')
96+
->line($pervVersionLink)
16197
->line('')
16298
->text($contents)
16399
->line('')

docs/01-Introduction.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ layout: doc
33
title: Introduction - Codeception Docs
44
---
55

6+
<div class="alert alert-success"><b>You are viewing docs for Codeception 5</b>. <a href="https://github.com/Codeception/codeception.github.com/blob/4.x/docs/01-Introduction.md">Switch to previous version of this guide</a> if you still use Codeception 4.x</div>
67

78
# Introduction
89

docs/02-GettingStarted.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ layout: doc
33
title: Getting Started - Codeception Docs
44
---
55

6+
<div class="alert alert-success"><b>You are viewing docs for Codeception 5</b>. <a href="https://github.com/Codeception/codeception.github.com/blob/4.x/docs/02-GettingStarted.md">Switch to previous version of this guide</a> if you still use Codeception 4.x</div>
67

78
# Getting Started
89

docs/03-AcceptanceTests.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ layout: doc
33
title: Acceptance Tests - Codeception Docs
44
---
55

6+
<div class="alert alert-success"><b>You are viewing docs for Codeception 5</b>. <a href="https://github.com/Codeception/codeception.github.com/blob/4.x/docs/03-AcceptanceTests.md">Switch to previous version of this guide</a> if you still use Codeception 4.x</div>
67

78
# Acceptance Testing
89

docs/04-FunctionalTests.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ layout: doc
33
title: Functional Tests - Codeception Docs
44
---
55

6+
<div class="alert alert-success"><b>You are viewing docs for Codeception 5</b>. <a href="https://github.com/Codeception/codeception.github.com/blob/4.x/docs/04-FunctionalTests.md">Switch to previous version of this guide</a> if you still use Codeception 4.x</div>
67

78
# Functional Tests
89

docs/05-UnitTests.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ layout: doc
33
title: Unit Tests - Codeception Docs
44
---
55

6+
<div class="alert alert-success"><b>You are viewing docs for Codeception 5</b>. <a href="https://github.com/Codeception/codeception.github.com/blob/4.x/docs/05-UnitTests.md">Switch to previous version of this guide</a> if you still use Codeception 4.x</div>
67

78
# Unit & Integration Tests
89

docs/06-Debugging.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ title: Debugging - Codeception Docs
44
---
55

66

7+
78
# Debugging
89

910
Writing a test is always the process of learning the code and the application.

docs/06-ModulesAndHelpers.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ layout: doc
33
title: Modules And Helpers - Codeception Docs
44
---
55

6+
<div class="alert alert-success"><b>You are viewing docs for Codeception 5</b>. <a href="https://github.com/Codeception/codeception.github.com/blob/4.x/docs/06-ModulesAndHelpers.md">Switch to previous version of this guide</a> if you still use Codeception 4.x</div>
67

78
# Modules and Helpers
89

docs/06-ReusingTestCode.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ layout: doc
33
title: Reusing Test Code - Codeception Docs
44
---
55

6+
<div class="alert alert-success"><b>You are viewing docs for Codeception 5</b>. <a href="https://github.com/Codeception/codeception.github.com/blob/4.x/docs/06-ReusingTestCode.md">Switch to previous version of this guide</a> if you still use Codeception 4.x</div>
67

78
# Reusing Test Code
89

docs/07-AdvancedUsage.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ layout: doc
33
title: Advanced Usage - Codeception Docs
44
---
55

6+
<div class="alert alert-success"><b>You are viewing docs for Codeception 5</b>. <a href="https://github.com/Codeception/codeception.github.com/blob/4.x/docs/07-AdvancedUsage.md">Switch to previous version of this guide</a> if you still use Codeception 4.x</div>
67

78
# Advanced Usage
89

0 commit comments

Comments
 (0)