Skip to content

Commit

Permalink
Generators/Markdown: fix footer not parsing
Browse files Browse the repository at this point in the history
As things were, if the output of the Markdown doc generation would be used in a Markdown-friendly environment, the footer would not be interpreted as markdown and would not display correctly.

Fixed now by adding a blank line at the start of the footer.

Includes updated test expectations.
  • Loading branch information
jrfnl committed Nov 18, 2024
1 parent 15db723 commit 12235bd
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Generators/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function printFooter()
// Turn off errors so we don't get timezone warnings if people
// don't have their timezone set.
$errorLevel = error_reporting(0);
echo 'Documentation generated on '.date('r');
echo PHP_EOL.'Documentation generated on '.date('r');
echo ' by [PHP_CodeSniffer '.Config::VERSION.'](https://github.com/PHPCSStandards/PHP_CodeSniffer)'.PHP_EOL;
error_reporting($errorLevel);

Expand Down
1 change: 1 addition & 0 deletions tests/Core/Generators/Expectations/ExpectedOutputOneDoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

## One Standard Block, No Code
Documentation contains one standard block and no code comparison.

Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,5 @@ This is standard block two.
</td>
</tr>
</table>

Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)
2 changes: 1 addition & 1 deletion tests/Core/Generators/Fixtures/MarkdownDouble.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MarkdownDouble extends Markdown
*/
protected function printFooter()
{
echo 'Documentation generated on *REDACTED*';
echo PHP_EOL.'Documentation generated on *REDACTED*';
echo ' by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer)'.PHP_EOL;
}

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 @@ -89,7 +89,7 @@ public function testFooter()
$config = new ConfigDouble(["--standard=$standard"]);
$ruleset = new Ruleset($config);

$regex = '`^Documentation generated on [A-Z][a-z]{2}, [0-9]{2} [A-Z][a-z]{2} 20[0-9]{2} [0-2][0-9](?::[0-5][0-9]){2} [+-][0-9]{4}';
$regex = '`^\RDocumentation generated on [A-Z][a-z]{2}, [0-9]{2} [A-Z][a-z]{2} 20[0-9]{2} [0-2][0-9](?::[0-5][0-9]){2} [+-][0-9]{4}';
$regex .= ' by \[PHP_CodeSniffer [3-9]\.[0-9]+.[0-9]+\]\(https://github\.com/PHPCSStandards/PHP_CodeSniffer\)\R$`';
$this->expectOutputRegex($regex);

Expand Down

0 comments on commit 12235bd

Please sign in to comment.