From 67d109862abaa806c97f18346e5423e15bcd6436 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Thu, 13 Jul 2017 23:11:39 -0700 Subject: [PATCH] [doclint] parse getters as properties From the api standpoint, there's no difference between property and a getter. References #14. --- docs/api.md | 4 ++-- utils/doclint/JSBuilder.js | 7 ++++++- utils/doclint/test/02-method-errors/foo.js | 3 +++ utils/doclint/test/golden/02-method-errors.txt | 3 ++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/api.md b/docs/api.md index 8d9cbc7e..2c97788d 100644 --- a/docs/api.md +++ b/docs/api.md @@ -86,7 +86,7 @@ * [headers.values()](#headersvalues) - [class: Body](#class-body) * [body.arrayBuffer()](#bodyarraybuffer) - * [body.bodyUsed()](#bodybodyused) + * [body.bodyUsed](#bodybodyused) * [body.buffer()](#bodybuffer) * [body.json()](#bodyjson) * [body.text()](#bodytext) @@ -449,7 +449,7 @@ If there's already a header with name `name`, the header gets overwritten. ### class: Body #### body.arrayBuffer() -#### body.bodyUsed() +#### body.bodyUsed #### body.buffer() #### body.json() #### body.text() diff --git a/utils/doclint/JSBuilder.js b/utils/doclint/JSBuilder.js index 26866171..c30ecfb9 100644 --- a/utils/doclint/JSBuilder.js +++ b/utils/doclint/JSBuilder.js @@ -30,10 +30,15 @@ class JSOutline { _onMethodDefinition(node) { console.assert(this._currentClassName !== null); console.assert(node.value.type === 'FunctionExpression'); + let methodName = this._extractText(node.key); + if (node.kind === 'get') { + let property = Documentation.Member.createProperty(methodName); + this._currentClassMembers.push(property); + return; + } const args = []; for (let param of node.value.params) args.push(new Documentation.Argument(this._extractText(param))); - let methodName = this._extractText(node.key); let method = Documentation.Member.createMethod(methodName, args); this._currentClassMembers.push(method); // Extract properties from constructor. diff --git a/utils/doclint/test/02-method-errors/foo.js b/utils/doclint/test/02-method-errors/foo.js index fe8b2039..3f499572 100644 --- a/utils/doclint/test/02-method-errors/foo.js +++ b/utils/doclint/test/02-method-errors/foo.js @@ -4,4 +4,7 @@ class Foo { stop() { } + + get zzz() { + } } diff --git a/utils/doclint/test/golden/02-method-errors.txt b/utils/doclint/test/golden/02-method-errors.txt index 6295473c..d919f52e 100644 --- a/utils/doclint/test/golden/02-method-errors.txt +++ b/utils/doclint/test/golden/02-method-errors.txt @@ -1,2 +1,3 @@ [MarkDown] Non-existing method found: Foo.proceed() -[MarkDown] Method not found: Foo.stop() \ No newline at end of file +[MarkDown] Method not found: Foo.stop() +[MarkDown] Property not found: Foo.zzz \ No newline at end of file