Automatically generate table-of-contents for markdown

This patch teaches doclint to regenerate table of contents
automatically whenever it's needed.

This patch:
- splits lint.js into lint.js and cli.js
- teaches cli.js to generate table-of-contents
- removes the test for table-of-contents errors from doclint
- adds a test for doclint failing to parse object destructuring in
  method parameters.
This commit is contained in:
Andrey Lushnikov
2017-07-21 10:27:53 -07:00
parent 52de75742b
commit 0960dc38d1
16 changed files with 93 additions and 65 deletions

View File

@@ -3,5 +3,9 @@
- `arg1` <[string]>
- `arg2` <[string]>
#### foo.bar(options)
- `options` <[Object]>
#### foo.test(...files)
- `...filePaths` <[string]>

View File

@@ -4,4 +4,7 @@ class Foo {
test(...filePaths) {
}
bar({visibility}) {
}
}

View File

@@ -1,8 +0,0 @@
<!-- toc -->
- [class: Dialog](#class-dialog)
<!-- tocstop -->
### class: Foo

View File

@@ -1,2 +0,0 @@
class Foo {
}

View File

@@ -1,4 +1,7 @@
[JavaScript] JS Parsing issue: unsupported syntax to define parameter in Foo.bar(): {visibility}
[MarkDown] Heading arguments for "foo.test(...files)" do not match described ones, i.e. "...files" != "...filePaths"
[MarkDown] Method Foo.bar() fails to describe its parameters:
- Non-existing argument found: options
[MarkDown] Method Foo.constructor() fails to describe its parameters:
- Argument not found: arg3
- Non-existing argument found: arg2
[MarkDown] Heading arguments for "foo.test(...files)" do not match described ones, i.e. "...files" != "...filePaths"
- Non-existing argument found: arg2

View File

@@ -1 +0,0 @@
[MarkDown] Markdown TOC is outdated, run `yarn generate-toc`

View File

@@ -1,4 +1,4 @@
[MarkDown] foo.www() has mistyped 'return' type declaration: expected exactly 'returns: ', found 'returns '.
[MarkDown] Async method Foo.asyncFunction should describe return type Promise
[MarkDown] Method Foo.return42 is missing return type description
[MarkDown] Method Foo.returnNothing has unneeded description of return type
[MarkDown] foo.www() has mistyped 'return' type declaration: expected exactly 'returns: ', found 'returns '.
[MarkDown] Method Foo.returnNothing has unneeded description of return type

View File

@@ -35,11 +35,10 @@ describe('doclint', function() {
it('02-method-errors', SX(test));
it('03-property-errors', SX(test));
it('04-bad-arguments', SX(test));
it('05-outdated-toc', SX(test));
it('05-event-errors', SX(test));
it('06-duplicates', SX(test));
it('07-sorting', SX(test));
it('08-return', SX(test));
it('09-event-errors', SX(test));
});
async function test() {