Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 26 additions & 18 deletions src/Generators/HTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,20 @@ protected function printHeader()
protected function getFormattedHeader()
{
$standard = $this->ruleset->name;
$output = '<html>'.PHP_EOL;
$output .= ' <head>'.PHP_EOL;
$output .= " <title>$standard Coding Standards</title>".PHP_EOL;
$output .= ' '.str_replace("\n", PHP_EOL, self::STYLESHEET).PHP_EOL;
$output .= ' </head>'.PHP_EOL;
$output .= ' <body>'.PHP_EOL;
$output .= " <h1>$standard Coding Standards</h1>".PHP_EOL;

return $output;
$output = sprintf(
'<html>
<head>
<title>%1$s Coding Standards</title>
%2$s
</head>
<body>
<h1>%1$s Coding Standards</h1>',
$standard,
self::STYLESHEET
);

// Use the correct line endings based on the OS.
return str_replace("\n", PHP_EOL, $output).PHP_EOL;

}//end getFormattedHeader()

Expand Down Expand Up @@ -197,12 +202,14 @@ protected function getFormattedToc()
$output = ' <h2>Table of Contents</h2>'.PHP_EOL;
$output .= ' <ul class="toc">'.PHP_EOL;

$listItemTemplate = ' <li><a href="#%s">%s</a></li>'.PHP_EOL;

foreach ($this->docFiles as $file) {
$doc = new DOMDocument();
$doc->load($file);
$documentation = $doc->getElementsByTagName('documentation')->item(0);
$title = $this->getTitle($documentation);
$output .= ' <li><a href="#'.str_replace(' ', '-', $title).'">'.$title.'</a></li>'.PHP_EOL;
$output .= sprintf($listItemTemplate, str_replace(' ', '-', $title), $title);
}

$output .= ' </ul>'.PHP_EOL;
Expand Down Expand Up @@ -240,16 +247,17 @@ protected function getFormattedFooter()
// Turn off errors so we don't get timezone warnings if people
// don't have their timezone set.
$errorLevel = error_reporting(0);
$output = ' <div class="tag-line">';
$output .= 'Documentation generated on '.date('r');
$output .= ' by <a href="https://github.com/PHPCSStandards/PHP_CodeSniffer">PHP_CodeSniffer '.Config::VERSION.'</a>';
$output .= '</div>'.PHP_EOL;
$output = sprintf(
' <div class="tag-line">Documentation generated on %s by <a href="https://github.com/PHPCSStandards/PHP_CodeSniffer">PHP_CodeSniffer %s</a></div>
</body>
</html>',
date('r'),
Config::VERSION
);
error_reporting($errorLevel);

$output .= ' </body>'.PHP_EOL;
$output .= '</html>'.PHP_EOL;

return $output;
// Use the correct line endings based on the OS.
return str_replace("\n", PHP_EOL, $output).PHP_EOL;

}//end getFormattedFooter()

Expand Down
12 changes: 5 additions & 7 deletions tests/Core/Generators/Fixtures/HTMLDouble.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ class HTMLDouble extends HTML
*/
protected function getFormattedFooter()
{
$output = ' <div class="tag-line">';
$output .= 'Documentation generated on #REDACTED#';
$output .= ' by <a href="https://github.com/PHPCSStandards/PHP_CodeSniffer">PHP_CodeSniffer #VERSION#</a>';
$output .= '</div>'.PHP_EOL;
$output .= ' </body>'.PHP_EOL;
$output .= '</html>'.PHP_EOL;
$output =' <div class="tag-line">Documentation generated on #REDACTED# by <a href="https://github.com/PHPCSStandards/PHP_CodeSniffer">PHP_CodeSniffer #VERSION#</a></div>
</body>
</html>';

return $output;
// Use the correct line endings based on the OS.
return str_replace("\n", PHP_EOL, $output).PHP_EOL;
}

/**
Expand Down
Loading