Skip to content

Commit 36e6746

Browse files
committed
Generators HTML/Markdown: don't print header/footer when there are no docs
As things were, the Markdown/HTML header and footer would always be printed, even if there were no docs to display. In my opinion, there should be no output if there are no docs. This is in line with the `Text` output, which would already not generate any output when there are no docs. Includes updated test expectations.
1 parent 56784f1 commit 36e6746

File tree

6 files changed

+10
-82
lines changed

6 files changed

+10
-82
lines changed

src/Generators/HTML.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ class HTML extends Generator
103103
*/
104104
public function generate()
105105
{
106+
if (empty($this->docFiles) === true) {
107+
return;
108+
}
109+
106110
ob_start();
107111
$this->printHeader();
108112
$this->printToc();

src/Generators/Markdown.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class Markdown extends Generator
2727
*/
2828
public function generate()
2929
{
30+
if (empty($this->docFiles) === true) {
31+
return;
32+
}
33+
3034
ob_start();
3135
$this->printHeader();
3236

tests/Core/Generators/Expectations/ExpectedOutputNoDocs.html

Lines changed: 0 additions & 78 deletions
This file was deleted.

tests/Core/Generators/Expectations/ExpectedOutputNoDocs.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/Core/Generators/HTMLTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static function dataDocs()
6262
return [
6363
'Standard without docs' => [
6464
'standard' => __DIR__.'/NoDocsTest.xml',
65-
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputNoDocs.html',
65+
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputEmpty.txt',
6666
],
6767
'Standard with one doc file' => [
6868
'standard' => __DIR__.'/OneDocTest.xml',

tests/Core/Generators/MarkdownTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static function dataDocs()
6262
return [
6363
'Standard without docs' => [
6464
'standard' => __DIR__.'/NoDocsTest.xml',
65-
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputNoDocs.md',
65+
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputEmpty.txt',
6666
],
6767
'Standard with one doc file' => [
6868
'standard' => __DIR__.'/OneDocTest.xml',

0 commit comments

Comments
 (0)