Skip to content

Commit

Permalink
tools: remove unused code in doc generation tool
Browse files Browse the repository at this point in the history
tools/doc/html.js includes code that looks for comments with
`start-include` and `end-include` for file inclusion. This seems to be
legacy code that is no longer used. The code only appears in the
table-of-contents generation function. The strings `start-include` and
`end-include` appear nowhere else in our tools and nowhere at all in our
docs.

PR-URL: #32913
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Trott authored and BridgeAR committed Apr 28, 2020
1 parent 015f33c commit c402edd
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions tools/doc/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,23 +313,11 @@ function versionSort(a, b) {

function buildToc({ filename, apilinks }) {
return (tree, file) => {
const startIncludeRefRE = /^\s*<!-- \[start-include:(.+)\] -->\s*$/;
const endIncludeRefRE = /^\s*<!-- \[end-include:.+\] -->\s*$/;
const realFilenames = [filename];
const idCounters = Object.create(null);
let toc = '';
let depth = 0;

visit(tree, null, (node) => {
// Keep track of the current filename for comment wrappers of inclusions.
if (node.type === 'html') {
const [, includedFileName] = node.value.match(startIncludeRefRE) || [];
if (includedFileName !== undefined)
realFilenames.unshift(includedFileName);
else if (endIncludeRefRE.test(node.value))
realFilenames.shift();
}

if (node.type !== 'heading') return;

if (node.depth - depth > 1) {
Expand All @@ -339,7 +327,7 @@ function buildToc({ filename, apilinks }) {
}

depth = node.depth;
const realFilename = path.basename(realFilenames[0], '.md');
const realFilename = path.basename(filename, '.md');
const headingText = file.contents.slice(
node.children[0].position.start.offset,
node.position.end.offset).trim();
Expand Down

0 comments on commit c402edd

Please sign in to comment.