Generators: don't print documentation title if there are no docs #755
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Previously, in case of an XML documentation file contained no usable documentation, the Generators would still print the title for the sniff documentation, even though there was no documentation to print.
It is my opinion, that in such a case, the title should also not be printed.
Some screenshots of situations which will no longer occur once this PR is merged:
HTML
Markdown
Commits
Generators/Text: don't print title if there is no content
This refactors the class to retrieve the intended output, instead of echo-ing it out directly and validates whether it makes sense to print anything at all about a sniff before sending the output to screen.
It deprecates the following methods, which will be removed in PHPCS 4.0:
printTitle()
in favour ofgetFormattedTitle()
printTextBlock()
in favour ofgetFormattedTextBlock()
printCodeComparisonBlock()
in favour ofgetFormattedCodeComparisonBlock()
Generators/Markdown: don't print title if there is no content
This refactors the class to retrieve the intended output, instead of echo-ing it out directly and validates whether it makes sense to print anything at all about a sniff before sending the output to screen.
It deprecates the following methods, which will be removed in PHPCS 4.0:
printHeader()
in favour ofgetFormattedHeader()
printFooter()
in favour ofgetFormattedFooter()
printTextBlock()
in favour ofgetFormattedTextBlock()
printCodeComparisonBlock()
in favour ofgetFormattedCodeComparisonBlock()
Generators/HTML: don't print title if there is no content
This refactors the class to retrieve the intended output, instead of echo-ing it out directly and validates whether it makes sense to print anything at all about a sniff before sending the output to screen.
It deprecates the following methods, which will be removed in PHPCS 4.0:
printHeader()
in favour ofgetFormattedHeader()
printToc()
in favour ofgetFormattedToc()
printFooter()
in favour ofgetFormattedFooter()
printTextBlock()
in favour ofgetFormattedTextBlock()
printCodeComparisonBlock()
in favour ofgetFormattedCodeComparisonBlock()
Suggested changelog entry
Changed
Deprecated
The following methods have been deprecated and will be removed in PHP_CodeSniffer 4.0:
PHP_CodeSniffer\Generators\Text\printTitle()
in favour ofPHP_CodeSniffer\Generators\Text\getFormattedTitle()
PHP_CodeSniffer\Generators\Text\printTextBlock()
in favour ofPHP_CodeSniffer\Generators\Text\getFormattedTextBlock()
PHP_CodeSniffer\Generators\Text\printCodeComparisonBlock()
in favour ofPHP_CodeSniffer\Generators\Text\getFormattedCodeComparisonBlock()
PHP_CodeSniffer\Generators\Markdown\printHeader()
in favour ofPHP_CodeSniffer\Generators\Markdown\getFormattedHeader()
PHP_CodeSniffer\Generators\Markdown\printFooter()
in favour ofPHP_CodeSniffer\Generators\Markdown\getFormattedFooter()
PHP_CodeSniffer\Generators\Markdown\printTextBlock()
in favour ofPHP_CodeSniffer\Generators\Markdown\getFormattedTextBlock()
PHP_CodeSniffer\Generators\Markdown\printCodeComparisonBlock()
in favour ofPHP_CodeSniffer\Generators\Markdown\getFormattedCodeComparisonBlock()
PHP_CodeSniffer\Generators\HTML\printHeader()
in favour ofPHP_CodeSniffer\Generators\HTML\getFormattedHeader()
PHP_CodeSniffer\Generators\HTML\printToc()
in favour ofPHP_CodeSniffer\Generators\HTML\getFormattedToc()
PHP_CodeSniffer\Generators\HTML\printFooter()
in favour ofPHP_CodeSniffer\Generators\HTML\getFormattedFooter()
PHP_CodeSniffer\Generators\HTML\printTextBlock()
in favour ofPHP_CodeSniffer\Generators\HTML\getFormattedTextBlock()
PHP_CodeSniffer\Generators\HTML\printCodeComparisonBlock()
in favour ofPHP_CodeSniffer\Generators\HTML\getFormattedCodeComparisonBlock()
Related issues/external references
This PR is part of a series of PRs which will add a complete set of tests (and improvements) for the Generator feature.
Also see: #671 and #716.
Types of changes