Skip to content

Commit 6792fb1

Browse files
authored
Merge pull request #687 from PHPCSStandards/feature/generators-html-markdown-no-output-on-no-docs
Generators HTML/Markdown: don't print header/footer when there are no docs
2 parents 98c8972 + 36e6746 commit 6792fb1

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)