Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/doc/allhtml.js4
-rw-r--r--tools/doc/html.js20
2 files changed, 16 insertions, 8 deletions
diff --git a/tools/doc/allhtml.js b/tools/doc/allhtml.js
index 5a24cee4292..93197f812e1 100644
--- a/tools/doc/allhtml.js
+++ b/tools/doc/allhtml.js
@@ -59,9 +59,11 @@ let all = toc.replace(/index\.html/g, 'all.html')
all = all.replace(/<title>.*?\| /, '<title>');
// Insert the combined table of contents.
-const tocStart = /<\w+ id="toc"[^>]*>\s*<\w+>.*?<\/\w+>\s*/.exec(all);
+const tocStart = /<!-- TOC -->/.exec(all);
all = all.slice(0, tocStart.index + tocStart[0].length) +
+ '<details id="toc" open><summary>Table of contents</summary>\n' +
'<ul>\n' + contents + '</ul>\n' +
+ '</details>\n' +
all.slice(tocStart.index + tocStart[0].length);
// Replace apicontent with the concatenated set of apicontents from each source.
diff --git a/tools/doc/html.js b/tools/doc/html.js
index d35fd47b601..6eb3484052b 100644
--- a/tools/doc/html.js
+++ b/tools/doc/html.js
@@ -382,13 +382,19 @@ function buildToc({ filename, apilinks }) {
node.children.push({ type: 'html', value: anchor });
});
- file.toc = unified()
- .use(markdown)
- .use(gfm)
- .use(remark2rehype, { allowDangerousHtml: true })
- .use(raw)
- .use(htmlStringify)
- .processSync(toc).toString();
+ if (toc !== '') {
+ file.toc = '<details id="toc" open><summary>Table of contents</summary>' +
+ unified()
+ .use(markdown)
+ .use(gfm)
+ .use(remark2rehype, { allowDangerousHtml: true })
+ .use(raw)
+ .use(htmlStringify)
+ .processSync(toc).toString() +
+ '</details>';
+ } else {
+ file.toc = '<!-- TOC -->';
+ }
};
}