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 <franziska.hinkelmann@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott authored and jasnell committed Apr 23, 2020
1 parent 17f1202 commit 5315304
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 5315304

Please sign in to comment.