Skip to content

Commit

Permalink
Merge pull request #687 from PHPCSStandards/feature/generators-html-m…
Browse files Browse the repository at this point in the history
…arkdown-no-output-on-no-docs

Generators HTML/Markdown: don't print header/footer when there are no docs
  • Loading branch information
jrfnl authored Nov 18, 2024
2 parents 98c8972 + 36e6746 commit 6792fb1
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 82 deletions.
4 changes: 4 additions & 0 deletions src/Generators/HTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class HTML extends Generator
*/
public function generate()
{
if (empty($this->docFiles) === true) {
return;
}

ob_start();
$this->printHeader();
$this->printToc();
Expand Down
4 changes: 4 additions & 0 deletions src/Generators/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class Markdown extends Generator
*/
public function generate()
{
if (empty($this->docFiles) === true) {
return;
}

ob_start();
$this->printHeader();

Expand Down
78 changes: 0 additions & 78 deletions tests/Core/Generators/Expectations/ExpectedOutputNoDocs.html

This file was deleted.

2 changes: 0 additions & 2 deletions tests/Core/Generators/Expectations/ExpectedOutputNoDocs.md

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Core/Generators/HTMLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function dataDocs()
return [
'Standard without docs' => [
'standard' => __DIR__.'/NoDocsTest.xml',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputNoDocs.html',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputEmpty.txt',
],
'Standard with one doc file' => [
'standard' => __DIR__.'/OneDocTest.xml',
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Generators/MarkdownTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function dataDocs()
return [
'Standard without docs' => [
'standard' => __DIR__.'/NoDocsTest.xml',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputNoDocs.md',
'pathToExpected' => __DIR__.'/Expectations/ExpectedOutputEmpty.txt',
],
'Standard with one doc file' => [
'standard' => __DIR__.'/OneDocTest.xml',
Expand Down

0 comments on commit 6792fb1

Please sign in to comment.