Skip to content

Commit 15bbc06

Browse files
ygongdevtmcw
authored andcommitted
Adding additional cli option, markdown-toc-max-depth for configuring markdown-toc maxDepth (documentationjs#1215)
1 parent 04a0a29 commit 15bbc06

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

declarations/comment.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type DocumentationConfig = {
1414
parseExtension: Array<string>,
1515
noReferenceLinks?: boolean,
1616
markdownToc?: boolean,
17+
markdownTocMaxDepth?: number,
1718
documentExported?: boolean,
1819
resolve?: string,
1920
hljs?: Object

docs/USAGE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Options:
2929
they change [boolean]
3030
--markdown-toc include a table of contents in markdown output
3131
[boolean] [default: true]
32+
--markdown-toc-max-depth specifies the max depth of the table of contents in markdown output
33+
[number] [default: 6]
3234
--shallow shallow mode turns off dependency resolution, only
3335
processing the specified files (or the main script
3436
specified in package.json)

src/commands/shared_options.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,11 @@ module.exports.sharedOutputOptions = {
123123
describe: 'include a table of contents in markdown output',
124124
default: true,
125125
type: 'boolean'
126+
},
127+
'markdown-toc-max-depth': {
128+
describe:
129+
'specifies the max depth of the table of contents in markdown output',
130+
default: 6,
131+
type: 'number'
126132
}
127133
};

src/output/markdown_ast.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,11 @@ function buildMarkdownAST(comments, config) {
371371
);
372372

373373
const pluginRemark = remark();
374-
if (config.markdownToc) pluginRemark.use(toc, { tight: true });
374+
if (config.markdownToc)
375+
pluginRemark.use(toc, {
376+
tight: true,
377+
maxDepth: config.markdownTocMaxDepth
378+
});
375379
if (config.noReferenceLinks !== true) pluginRemark.use(links);
376380
root = pluginRemark.run(root);
377381

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy