Permalink
Browse files

doc: prevent displaying empty version picker

Backport-PR-URL: #15670
PR-URL: #15420
Fixes: #15396
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information...
chris--young authored and MylesBorins committed Sep 14, 2017
1 parent 37dd2ad commit a13ac69ff9157648b191b33d3dc0282444b7e84d
Showing with 26 additions and 10 deletions.
  1. +12 −0 doc/api_assets/style.css
  2. +4 −7 doc/template.html
  3. +10 −3 tools/doc/html.js
View
@@ -91,6 +91,15 @@ em code {
#gtoc li {
display: inline;
border-right: 1px #000 solid;
margin-right: 0.4em;
padding-right: 0.4em;
}
#gtoc li:last-child {
border-right: none;
margin-right: 0;
padding-right: 0;
}
li.version-picker {
@@ -118,6 +127,9 @@ ol.version-picker {
#gtoc ol.version-picker li {
display: block;
border-right: 0;
margin-right: 0;
width: 100%;
}
ol.version-picker li a {
View
@@ -25,18 +25,15 @@ <h1>Node.js __VERSION__ Documentation</h1>
<div id="gtoc">
<ul>
<li>
<a href="index.html" name="toc">Index</a> |
<a href="index.html" name="toc">Index</a>
</li>
<li>
<a href="all.html">View on single page</a> |
<a href="all.html">View on single page</a>
</li>
<li>
<a href="__FILENAME__.json">View as JSON</a> |
</li>
<li class="version-picker">
<a href="#">View another version <span>&#x25bc;</span></a>
__ALTDOCS__
<a href="__FILENAME__.json">View as JSON</a>
</li>
__ALTDOCS__
</ul>
</div>
<hr>
View
@@ -33,7 +33,6 @@ var gtocPath = path.resolve(path.join(
var gtocLoading = null;
var gtocData = null;
var docCreated = null;
var nodeVersion = null;
/**
* opts: input, filename, template, nodeVersion.
@@ -211,9 +210,17 @@ function altDocs(filename) {
return html + '</a></li>';
}
const lis = (vs) => vs.filter(lte).map(li).join('\n');
const lis = versions.filter(lte).map(li).join('\n');
return `<ol class="version-picker">${lis(versions)}</ol>`;
if (!lis.length)
return '';
return `
<li class="version-picker">
<a href="#">View another version <span>&#x25bc;</span></a>
<ol class="version-picker">${lis}</ol>
</li>
`;
}
// handle general body-text replacements

0 comments on commit a13ac69

Please sign in to comment.