Skip to content

Commit

Permalink
refactor(args): Improve the way we use yargs to simplify the markdown…
Browse files Browse the repository at this point in the history
…-toc option
  • Loading branch information
tmcw committed Dec 29, 2016
1 parent 5bfc660 commit dd9c03a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ module.exports.builder = extend({},
default: 'json',
choices: ['json', 'md', 'remark', 'html']
},
'no-markdown-toc': {
'markdown-toc': {
describe: 'include a table of contents in markdown output',
default: 'stdout',
default: true,
type: 'boolean'
},
output: {
Expand Down Expand Up @@ -69,7 +69,7 @@ module.exports.handler = function build(argv, callback) {
version: argv['project-version'] || (argv.package || {}).version,
theme: argv.theme,
paths: argv.paths,
'no-markdown-toc': argv['no-markdown-toc'],
markdownToc: argv.markdownToc,
hljs: argv.hljs || {}
};

Expand Down
2 changes: 1 addition & 1 deletion lib/output/markdown_ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function markdownAST(comments, options, callback) {

var root = rerouteLinks(linkerStack.link,
u('root', generatorComment
.concat(options['no-markdown-toc'] ? [] : tableOfContentsHeading)
.concat(options.markdownToc ? tableOfContentsHeading : [])
.concat(comments.reduce(function (memo, comment) {
return memo.concat(generate(2, comment));
}, []))));
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ test('outputs', function (ttt) {

if (file.match(/es6.input.js/)) {
tt.test('no markdown TOC', function (t) {
outputMarkdown(_.cloneDeep(result), { 'no-markdown-toc': true }, function (err, result) {
outputMarkdown(_.cloneDeep(result), { markdownToc: false }, function (err, result) {
t.ifError(err);
var outputfile = file.replace('.input.js', '.output-toc.md');
if (UPDATE) {
Expand Down

0 comments on commit dd9c03a

Please sign in to comment.