Skip to content

Commit

Permalink
Merge pull request #697 from PHPCSStandards/generators-html-only-disp…
Browse files Browse the repository at this point in the history
…lay-toc-for-multiple-docs

Generators/HTML: only display a TOC when there is more than one doc
  • Loading branch information
jrfnl authored Nov 22, 2024
2 parents 866f7cf + 2a045d3 commit 806f4ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/Generators/HTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ protected function printHeader()
*/
protected function printToc()
{
// Only show a TOC when there are two or more docs to display.
if (count($this->docFiles) < 2) {
return;
}

echo ' <h2>Table of Contents</h2>'.PHP_EOL;
echo ' <ul class="toc">'.PHP_EOL;

Expand Down
4 changes: 0 additions & 4 deletions tests/Core/Generators/Expectations/ExpectedOutputOneDoc.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@
</head>
<body>
<h1>GeneratorTest Coding Standards</h1>
<h2>Table of Contents</h2>
<ul class="toc">
<li><a href="#One-Standard-Block,-No-Code">One Standard Block, No Code</a></li>
</ul>
<a name="One-Standard-Block,-No-Code" />
<h2>One Standard Block, No Code</h2>
<p class="text">Documentation contains one standard block and no code comparison.</p>
Expand Down

0 comments on commit 806f4ad

Please sign in to comment.