From 12235bda7805484c8ffe4fd9a53df5bfbaa5e63f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 3 Nov 2024 16:13:12 +0100 Subject: [PATCH] Generators/Markdown: fix footer not parsing 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. --- src/Generators/Markdown.php | 2 +- tests/Core/Generators/Expectations/ExpectedOutputOneDoc.md | 1 + .../Core/Generators/Expectations/ExpectedOutputStructureDocs.md | 1 + tests/Core/Generators/Fixtures/MarkdownDouble.php | 2 +- tests/Core/Generators/MarkdownTest.php | 2 +- 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Generators/Markdown.php b/src/Generators/Markdown.php index d8e700b8ca..ab30cd59a7 100644 --- a/src/Generators/Markdown.php +++ b/src/Generators/Markdown.php @@ -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); diff --git a/tests/Core/Generators/Expectations/ExpectedOutputOneDoc.md b/tests/Core/Generators/Expectations/ExpectedOutputOneDoc.md index f8deb0ce20..0cc0ecceae 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputOneDoc.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputOneDoc.md @@ -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) diff --git a/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.md b/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.md index d613df2951..116af5df1e 100644 --- a/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.md +++ b/tests/Core/Generators/Expectations/ExpectedOutputStructureDocs.md @@ -168,4 +168,5 @@ This is standard block two. + Documentation generated on *REDACTED* by [PHP_CodeSniffer *VERSION*](https://github.com/PHPCSStandards/PHP_CodeSniffer) diff --git a/tests/Core/Generators/Fixtures/MarkdownDouble.php b/tests/Core/Generators/Fixtures/MarkdownDouble.php index 6f51f3ec4c..ed2a5d8f58 100644 --- a/tests/Core/Generators/Fixtures/MarkdownDouble.php +++ b/tests/Core/Generators/Fixtures/MarkdownDouble.php @@ -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; } diff --git a/tests/Core/Generators/MarkdownTest.php b/tests/Core/Generators/MarkdownTest.php index adba19518f..0610678dbe 100644 --- a/tests/Core/Generators/MarkdownTest.php +++ b/tests/Core/Generators/MarkdownTest.php @@ -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);