From bb5917c219653a85fc30ff55ca295f28fd4d6d87 Mon Sep 17 00:00:00 2001 From: ygongdev Date: Sun, 10 Mar 2019 03:16:56 -0700 Subject: [PATCH] Adding additional cli option, markdown-toc-max-depth for configuring markdown-toc maxDepth --- declarations/comment.js | 1 + docs/USAGE.md | 2 ++ src/commands/shared_options.js | 6 ++++++ src/output/markdown_ast.js | 6 +++++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/declarations/comment.js b/declarations/comment.js index 3a375077d..741900d02 100644 --- a/declarations/comment.js +++ b/declarations/comment.js @@ -14,6 +14,7 @@ type DocumentationConfig = { parseExtension: Array, noReferenceLinks?: boolean, markdownToc?: boolean, + markdownTocMaxDepth?: number, documentExported?: boolean, resolve?: string, hljs?: Object diff --git a/docs/USAGE.md b/docs/USAGE.md index 14960f983..16789baf6 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -29,6 +29,8 @@ Options: they change [boolean] --markdown-toc include a table of contents in markdown output [boolean] [default: true] + --markdown-toc-max-depth specifies the max depth of the table of contents in markdown output + [number] [default: 6] --shallow shallow mode turns off dependency resolution, only processing the specified files (or the main script specified in package.json) diff --git a/src/commands/shared_options.js b/src/commands/shared_options.js index b8c326306..5dc92fd54 100644 --- a/src/commands/shared_options.js +++ b/src/commands/shared_options.js @@ -123,5 +123,11 @@ module.exports.sharedOutputOptions = { describe: 'include a table of contents in markdown output', default: true, type: 'boolean' + }, + 'markdown-toc-max-depth': { + describe: + 'specifies the max depth of the table of contents in markdown output', + default: 6, + type: 'number' } }; diff --git a/src/output/markdown_ast.js b/src/output/markdown_ast.js index d612b9358..e029819ed 100644 --- a/src/output/markdown_ast.js +++ b/src/output/markdown_ast.js @@ -371,7 +371,11 @@ function buildMarkdownAST(comments, config) { ); const pluginRemark = remark(); - if (config.markdownToc) pluginRemark.use(toc, { tight: true }); + if (config.markdownToc) + pluginRemark.use(toc, { + tight: true, + maxDepth: config.markdownTocMaxDepth + }); if (config.noReferenceLinks !== true) pluginRemark.use(links); root = pluginRemark.run(root); 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