Skip to content

Commit f99b38f

Browse files
Mattia Pontonioruyadorno
authored andcommitted
doc: wrap TOC in a <details> tag
PR-URL: #36896Fixes: #36885 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 1149af6 commit f99b38f

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎doc/api_assets/style.css‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,8 @@ hr {
472472
margin:001rem;
473473
}
474474

475-
#toch2 {
476-
margin:1.5rem0;
475+
#toc>ul {
476+
margin-top:1.5rem;
477477
}
478478

479479
#tocp {

‎doc/template.html‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ <h1>Node.js __VERSION__ Documentation</h1>
5555
<hr>
5656
</header>
5757

58-
<divid="toc">
59-
<h2>Table of Contents</h2>
58+
<detailsid="toc"open>
59+
<summary>Table of Contents</summary>
6060
__TOC__
61-
</div>
61+
</details>
6262

6363
<divid="apicontent">
6464
__CONTENT__

‎tools/doc/allhtml.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ for (const link of toc.match(/<a.*?>/g)) {
3131
constdata=fs.readFileSync(source+'/'+href,'utf8');
3232

3333
// Split the doc.
34-
constmatch=/(<\/ul>\s*)?<\/div>\s*<divid="apicontent">/.exec(data);
34+
constmatch=/(<\/ul>\s*)?<\/\w+>\s*<\w+id="apicontent">/.exec(data);
3535

3636
contents+=data.slice(0,match.index)
37-
.replace(/[\s\S]*?<divid="toc">\s*<h2>.*?<\/h2>\s*(<ul>\s*)?/,'');
37+
.replace(/[\s\S]*?id="toc"[^>]*>\s*<\w+>.*?<\/\w+>\s*(<ul>\s*)?/,'');
3838

3939
apicontent+=data.slice(match.index+match[0].length)
4040
.replace(/<!--APIEND-->[\s\S]*/,'')
@@ -59,13 +59,13 @@ let all = toc.replace(/index\.html/g, 'all.html')
5959
all=all.replace(/<title>.*?\|/,'<title>');
6060

6161
// Insert the combined table of contents.
62-
consttocStart=/<divid="toc">\s*<h2>.*?<\/h2>\s*/.exec(all);
62+
consttocStart=/<\w+id="toc"[^>]*>\s*<\w+>.*?<\/\w+>\s*/.exec(all);
6363
all=all.slice(0,tocStart.index+tocStart[0].length)+
6464
'<ul>\n'+contents+'</ul>\n'+
6565
all.slice(tocStart.index+tocStart[0].length);
6666

6767
// Replace apicontent with the concatenated set of apicontents from each source.
68-
constapiStart=/<divid="apicontent">\s*/.exec(all);
68+
constapiStart=/<\w+id="apicontent">\s*/.exec(all);
6969
constapiEnd=all.lastIndexOf('<!-- API END -->');
7070
all=all.slice(0,apiStart.index+apiStart[0].length)+
7171
apicontent+

0 commit comments

Comments
 (0)