From d884fc725e67577041b18748592e46b2d415ee15 Mon Sep 17 00:00:00 2001
From: Tom MacWright
Date: Sun, 29 Jan 2017 18:54:35 -0500
Subject: [PATCH 1/2] Support deprecated tag
---
default_theme/section._ | 15 +-
lib/output/markdown_ast.js | 4 +-
lib/parse.js | 6 +-
test/fixture/html/nested.config-output.html | 402 +-------------------
test/fixture/html/nested.output.files | 402 +-------------------
5 files changed, 49 insertions(+), 780 deletions(-)
diff --git a/default_theme/section._ b/default_theme/section._
index a75159b83..4ef057fee 100644
--- a/default_theme/section._
+++ b/default_theme/section._
@@ -24,7 +24,7 @@
<%= formatType(section.type) %>
<% } %>
- <% if (section.augments) { %>
+ <% if (section.augments.length) { %>
Extends
<% if (section.augments) { %>
@@ -35,13 +35,14 @@
<% } %>
+ <% if (section.deprecated) { %>Deprecated: <%= md(section.deprecated, true) %>
<% }%>
<% if (section.version) { %>Version: <%- section.version %>
<% }%>
<% if (section.license) { %>License: <%- section.license %>
<% }%>
<% if (section.author) { %>Author: <%- section.author %>
<% }%>
- <% if (section.copyright) { %>Copyright: <%- section.copyright %>
<% }%>
+ <% if (section.copyright) { %>Copyright: <%= md(section.copyright, true) %>
<% }%>
<% if (section.since) { %>Since: <%- section.since %>
<% }%>
- <% if (section.params) { %>
+ <% if (section.params.length) { %>
Parameters
<% section.params.forEach(function(param) { %>
@@ -81,7 +82,7 @@
<% } %>
- <% if (section.properties) { %>
+ <% if (section.properties.length) { %>
Properties
<% section.properties.forEach(function(property) { %>
@@ -108,7 +109,7 @@
<% } %>
- <% if (section.returns) { %>
+ <% if (section.returns.length) { %>
<% section.returns.forEach(function(ret) { %>
Returns
<%= formatType(ret.type) %>
<% if (ret.description) { %>:
@@ -117,7 +118,7 @@
<% }) %>
<% } %>
- <% if (section.throws) { %>
+ <% if (section.throws.length) { %>
Throws
<% section.throws.forEach(function(throws) { %>
@@ -126,7 +127,7 @@
<% } %>
- <% if (section.examples) { %>
+ <% if (section.examples.length) { %>
Example
<% section.examples.forEach(function(example) { %>
<% if (example.caption) { %><%= md(example.caption) %>
<% } %>
diff --git a/lib/output/markdown_ast.js b/lib/output/markdown_ast.js
index 8c9748fb4..4058603f4 100644
--- a/lib/output/markdown_ast.js
+++ b/lib/output/markdown_ast.js
@@ -174,14 +174,14 @@ function buildMarkdownAST(comments/*: Array */, config/*: Documentation
}
function metaSection(comment/*: Comment */) {
- let meta = ['version', 'since', 'copyright', 'author', 'license']
+ let meta = ['version', 'since', 'copyright', 'author', 'license', 'deprecated']
.filter(tag => comment[tag]);
return !!meta.length && [u('strong', [u('text', 'Meta')])].concat(
u('list', { ordered: false },
meta
.map(tag => {
let metaContent;
- if (tag === 'copyright') {
+ if (tag === 'copyright' || tag === 'deprecated') {
metaContent = comment[tag];
} else {
metaContent = u('text', comment[tag]);
diff --git a/lib/parse.js b/lib/parse.js
index 176f99032..1b859a56b 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -77,7 +77,11 @@ var flatteners = {
'copyright': flattenMarkdownDescription,
'default': todo,
'defaultvalue': synonym('default'),
- 'deprecated': flattenMarkdownDescription,
+ deprecated(result, tag) {
+ let description = tag.description || 'This is deprecated.';
+ result.deprecated = parseMarkdown(description);
+ },
+ flattenMarkdownDescription,
'desc': synonym('description'),
'description': flattenMarkdownDescription,
'emits': synonym('fires'),
diff --git a/test/fixture/html/nested.config-output.html b/test/fixture/html/nested.config-output.html
index 534109b8d..0367dc120 100644
--- a/test/fixture/html/nested.config-output.html
+++ b/test/fixture/html/nested.config-output.html
@@ -279,6 +279,7 @@
+
Parameters
@@ -296,27 +297,12 @@
-
Properties
-
-
-
-
-
-
- Throws
-
-
- Example
-
-
Static Members
@@ -342,19 +328,13 @@
-
- Extends
-
-
-
-
-
+
Parameters
@@ -380,11 +360,6 @@
-
Properties
-
-
-
-
@@ -397,16 +372,8 @@
-
Throws
-
-
- Example
-
-
@@ -437,19 +404,13 @@
-
- Extends
-
-
-
-
-
+
Parameters
@@ -467,11 +428,6 @@
-
Properties
-
-
-
-
@@ -484,16 +440,8 @@
-
Throws
-
-
- Example
-
-
@@ -523,19 +471,13 @@
- Extends
-
-
-
-
-
+
Parameters
@@ -563,11 +505,6 @@
-
Properties
-
-
-
-
@@ -580,16 +517,8 @@
-
Throws
-
-
- Example
-
-
@@ -619,19 +548,13 @@
- Extends
-
-
-
-
-
+
Parameters
@@ -650,11 +573,6 @@
-
Properties
-
-
-
-
@@ -667,11 +585,6 @@
-
Throws
-
-
Example
@@ -710,48 +623,22 @@
MAGIC_NUMBER
-
- Extends
-
-
-
-
-
-
-
- Parameters
-
-
-
- Properties
-
-
-
-
-
-
- Throws
-
-
- Example
-
+
@@ -790,32 +677,16 @@
- Extends
-
-
-
-
-
-
-
- Parameters
-
-
-
- Properties
-
-
-
+
@@ -829,11 +700,6 @@
-
Throws
-
-
Example
@@ -872,19 +738,13 @@
-
- Extends
-
-
-
-
-
+
Parameters
@@ -938,27 +798,12 @@
-
Properties
-
-
-
-
-
-
- Throws
-
-
- Example
-
-
@@ -996,48 +841,22 @@
event
-
- Extends
-
-
-
-
-
-
-
- Parameters
-
-
-
- Properties
-
-
-
-
-
-
- Throws
-
-
- Example
-
+
@@ -1077,19 +896,13 @@
CustomError(other: any, also: any)
-
- Extends
-
-
-
-
-
+
Parameters
@@ -1143,20 +956,10 @@
-
-
-
Throws
-
-
- Example
-
-
@@ -1189,32 +992,16 @@
- Extends
-
-
-
-
-
-
-
- Parameters
-
-
-
- Properties
-
-
-
+
@@ -1228,16 +1015,8 @@
-
Throws
-
-
- Example
-
-
@@ -1268,19 +1047,13 @@
- Extends
-
-
-
-
-
+
Parameters
@@ -1298,11 +1071,6 @@
-
Properties
-
-
-
-
@@ -1315,16 +1083,8 @@
-
Throws
-
-
- Example
-
-
@@ -1357,32 +1117,16 @@
- Extends
-
-
-
-
-
-
-
- Parameters
-
-
-
- Properties
-
-
-
+
@@ -1396,16 +1140,8 @@
-
Throws
-
-
- Example
-
-
@@ -1436,48 +1172,22 @@
new Foo()
-
- Extends
-
-
-
-
-
-
-
- Parameters
-
-
-
- Properties
-
-
-
-
-
-
- Throws
-
-
- Example
-
+
@@ -1504,48 +1214,22 @@
bar
-
- Extends
-
-
-
-
-
-
-
- Parameters
-
-
-
- Properties
-
-
-
-
-
-
- Throws
-
-
- Example
-
+
@@ -1587,48 +1271,22 @@
customStreams
-
- Extends
-
-
-
-
-
-
-
- Parameters
-
-
-
- Properties
-
-
-
-
-
-
- Throws
-
-
- Example
-
+
@@ -1653,48 +1311,22 @@
new passthrough()
-
- Extends
-
-
-
-
-
-
-
- Parameters
-
-
-
- Properties
-
-
-
-
-
-
- Throws
-
-
- Example
-
+
diff --git a/test/fixture/html/nested.output.files b/test/fixture/html/nested.output.files
index 13a20901c..42111c5aa 100644
--- a/test/fixture/html/nested.output.files
+++ b/test/fixture/html/nested.output.files
@@ -241,6 +241,7 @@
+
Parameters
@@ -258,27 +259,12 @@
- Properties
-
-
-
-
-
-
- Throws
-
-
- Example
-
-
Static Members
@@ -304,19 +290,13 @@ This is a [link to something that does not exist]DoesNot
-
- Extends
-
-
-
-
-
+
Parameters
@@ -342,11 +322,6 @@ This is a [link to something that does not exist]DoesNot
- Properties
-
-
-
-
@@ -359,16 +334,8 @@ This is a [link to something that does not exist]DoesNot
- Throws
-
-
- Example
-
-
@@ -399,19 +366,13 @@ the referenced class type
-
- Extends
-
-
-
-
-
+
Parameters
@@ -429,11 +390,6 @@ the referenced class type
- Properties
-
-
-
-
@@ -446,16 +402,8 @@ the referenced class type
- Throws
-
-
- Example
-
-
@@ -485,19 +433,13 @@ the referenced class type
-
- Extends
-
-
-
-
-
+
Parameters
@@ -525,11 +467,6 @@ the referenced class type
- Properties
-
-
-
-
@@ -542,16 +479,8 @@ the referenced class type
- Throws
-
-
- Example
-
-
@@ -581,19 +510,13 @@ the referenced class type
-
- Extends
-
-
-
-
-
+
Parameters
@@ -612,11 +535,6 @@ the referenced class type
- Properties
-
-
-
-
@@ -629,11 +547,6 @@ the referenced class type
- Throws
-
-
Example
@@ -672,48 +585,22 @@ k.isArrayOfBuffers();
MAGIC_NUMBER
-
- Extends
-
-
-
-
-
-
-
- Parameters
-
-
-
- Properties
-
-
-
-
-
-
- Throws
-
-
- Example
-
+
@@ -752,32 +639,16 @@ k.isArrayOfBuffers();
-
- Extends
-
-
-
-
-
-
-
- Parameters
-
-
-
- Properties
-
-
-
+
@@ -791,11 +662,6 @@ k.isArrayOfBuffers();
- Throws
-
-
Example
@@ -834,19 +700,13 @@ k.isArrayOfBuffers();
-
- Extends
-
-
-
-
-
+
Parameters
@@ -900,27 +760,12 @@ k.isArrayOfBuffers();
- Properties
-
-
-
-
-
-
- Throws
-
-
- Example
-
-
@@ -958,48 +803,22 @@ k.isArrayOfBuffers();
event
-
- Extends
-
-
-
-
-
-
-
- Parameters
-
-
-
- Properties
-
-
-
-
-
-
- Throws
-
-
- Example
-
+
@@ -1039,19 +858,13 @@ k.isArrayOfBuffers();
CustomError(other: any, also: any)
-
- Extends
-
-
-
-
-
+
Parameters
@@ -1105,20 +918,10 @@ k.isArrayOfBuffers();
-
-
- Throws
-
-
- Example
-
-
@@ -1151,32 +954,16 @@ like a klass
-
- Extends
-
-
-
-
-
-
-
- Parameters
-
-
-
- Properties
-
-
-
+
@@ -1190,16 +977,8 @@ like a klass
- Throws
-
-
- Example
-
-
@@ -1230,19 +1009,13 @@ like a klass
-
- Extends
-
-
-
-
-
+
Parameters
@@ -1260,11 +1033,6 @@ like a klass
- Properties
-
-
-
-
@@ -1277,16 +1045,8 @@ like a klass
- Throws
-
-
- Example
-
-
@@ -1319,32 +1079,16 @@ like a klass. This needs a undefined
-
- Extends
-
-
-
-
-
-
-
- Parameters
-
-
-
- Properties
-
-
-
+
@@ -1358,16 +1102,8 @@ like a klass. This needs a klass. This needs a klass. This needs a klass. This needs a klass. This needs a = 1) {
+ n.isObjectExpression(path.parentPath)) {
+
+ // Foo = { bar() {} };
+ // Foo.prototype = { bar() {} };
+ // Foo.bar = { baz() {} };
+ if (n.isAssignmentExpression(path.parentPath.parentPath)) {
+ identifiers = extractIdentifiers(path.parentPath.parentPath.get('left'));
+ if (identifiers.length >= 1) {
+ inferMembershipFromIdentifiers(comment, identifiers);
+ }
+ }
+
+ // var Foo = { bar() {} };
+ if (n.isVariableDeclarator(path.parentPath.parentPath)) {
+ identifiers = [path.parentPath.parentPath.get('id').node.name];
inferMembershipFromIdentifiers(comment, identifiers);
}
}
diff --git a/test/fixture/document-exported.output.json b/test/fixture/document-exported.output.json
index 671a4b4a1..f44342daf 100644
--- a/test/fixture/document-exported.output.json
+++ b/test/fixture/document-exported.output.json
@@ -843,6 +843,183 @@
"instance": [],
"events": [],
"static": [
+ {
+ "description": "",
+ "tags": [],
+ "loc": {
+ "start": {
+ "line": 13,
+ "column": 2
+ },
+ "end": {
+ "line": 13,
+ "column": 13
+ }
+ },
+ "context": {
+ "loc": {
+ "start": {
+ "line": 13,
+ "column": 2
+ },
+ "end": {
+ "line": 13,
+ "column": 13
+ }
+ }
+ },
+ "augments": [],
+ "errors": [],
+ "examples": [],
+ "params": [],
+ "properties": [],
+ "returns": [],
+ "sees": [],
+ "throws": [],
+ "todos": [],
+ "name": "method",
+ "kind": "function",
+ "memberof": "object",
+ "scope": "static",
+ "members": {
+ "global": [],
+ "inner": [],
+ "instance": [],
+ "events": [],
+ "static": []
+ },
+ "path": [
+ {
+ "name": "object"
+ },
+ {
+ "name": "method",
+ "kind": "function",
+ "scope": "static"
+ }
+ ],
+ "namespace": "object.method"
+ },
+ {
+ "description": "",
+ "tags": [],
+ "loc": {
+ "start": {
+ "line": 14,
+ "column": 2
+ },
+ "end": {
+ "line": 14,
+ "column": 17
+ }
+ },
+ "context": {
+ "loc": {
+ "start": {
+ "line": 14,
+ "column": 2
+ },
+ "end": {
+ "line": 14,
+ "column": 17
+ }
+ }
+ },
+ "augments": [],
+ "errors": [],
+ "examples": [],
+ "params": [],
+ "properties": [],
+ "returns": [],
+ "sees": [],
+ "throws": [],
+ "todos": [],
+ "name": "getter",
+ "kind": "member",
+ "memberof": "object",
+ "scope": "static",
+ "members": {
+ "global": [],
+ "inner": [],
+ "instance": [],
+ "events": [],
+ "static": []
+ },
+ "path": [
+ {
+ "name": "object"
+ },
+ {
+ "name": "getter",
+ "kind": "member",
+ "scope": "static"
+ }
+ ],
+ "namespace": "object.getter"
+ },
+ {
+ "description": "",
+ "tags": [],
+ "loc": {
+ "start": {
+ "line": 15,
+ "column": 2
+ },
+ "end": {
+ "line": 15,
+ "column": 18
+ }
+ },
+ "context": {
+ "loc": {
+ "start": {
+ "line": 15,
+ "column": 2
+ },
+ "end": {
+ "line": 15,
+ "column": 18
+ }
+ }
+ },
+ "augments": [],
+ "errors": [],
+ "examples": [],
+ "params": [
+ {
+ "title": "param",
+ "name": "v",
+ "lineNumber": 15
+ }
+ ],
+ "properties": [],
+ "returns": [],
+ "sees": [],
+ "throws": [],
+ "todos": [],
+ "name": "setter",
+ "kind": "member",
+ "memberof": "object",
+ "scope": "static",
+ "members": {
+ "global": [],
+ "inner": [],
+ "instance": [],
+ "events": [],
+ "static": []
+ },
+ "path": [
+ {
+ "name": "object"
+ },
+ {
+ "name": "setter",
+ "kind": "member",
+ "scope": "static"
+ }
+ ],
+ "namespace": "object.setter"
+ },
{
"description": "",
"tags": [],
@@ -964,165 +1141,6 @@
],
"namespace": "object"
},
- {
- "description": "",
- "tags": [],
- "loc": {
- "start": {
- "line": 13,
- "column": 2
- },
- "end": {
- "line": 13,
- "column": 13
- }
- },
- "context": {
- "loc": {
- "start": {
- "line": 13,
- "column": 2
- },
- "end": {
- "line": 13,
- "column": 13
- }
- }
- },
- "augments": [],
- "errors": [],
- "examples": [],
- "params": [],
- "properties": [],
- "returns": [],
- "sees": [],
- "throws": [],
- "todos": [],
- "name": "method",
- "kind": "function",
- "members": {
- "global": [],
- "inner": [],
- "instance": [],
- "events": [],
- "static": []
- },
- "path": [
- {
- "name": "method",
- "kind": "function"
- }
- ],
- "namespace": "method"
- },
- {
- "description": "",
- "tags": [],
- "loc": {
- "start": {
- "line": 14,
- "column": 2
- },
- "end": {
- "line": 14,
- "column": 17
- }
- },
- "context": {
- "loc": {
- "start": {
- "line": 14,
- "column": 2
- },
- "end": {
- "line": 14,
- "column": 17
- }
- }
- },
- "augments": [],
- "errors": [],
- "examples": [],
- "params": [],
- "properties": [],
- "returns": [],
- "sees": [],
- "throws": [],
- "todos": [],
- "name": "getter",
- "kind": "member",
- "members": {
- "global": [],
- "inner": [],
- "instance": [],
- "events": [],
- "static": []
- },
- "path": [
- {
- "name": "getter",
- "kind": "member"
- }
- ],
- "namespace": "getter"
- },
- {
- "description": "",
- "tags": [],
- "loc": {
- "start": {
- "line": 15,
- "column": 2
- },
- "end": {
- "line": 15,
- "column": 18
- }
- },
- "context": {
- "loc": {
- "start": {
- "line": 15,
- "column": 2
- },
- "end": {
- "line": 15,
- "column": 18
- }
- }
- },
- "augments": [],
- "errors": [],
- "examples": [],
- "params": [
- {
- "title": "param",
- "name": "v",
- "lineNumber": 15
- }
- ],
- "properties": [],
- "returns": [],
- "sees": [],
- "throws": [],
- "todos": [],
- "name": "setter",
- "kind": "member",
- "members": {
- "global": [],
- "inner": [],
- "instance": [],
- "events": [],
- "static": []
- },
- "path": [
- {
- "name": "setter",
- "kind": "member"
- }
- ],
- "namespace": "setter"
- },
{
"description": "",
"tags": [],
@@ -1491,7 +1509,65 @@
"inner": [],
"instance": [],
"events": [],
- "static": []
+ "static": [
+ {
+ "description": "",
+ "tags": [],
+ "loc": {
+ "start": {
+ "line": 73,
+ "column": 2
+ },
+ "end": {
+ "line": 73,
+ "column": 10
+ }
+ },
+ "context": {
+ "loc": {
+ "start": {
+ "line": 73,
+ "column": 2
+ },
+ "end": {
+ "line": 73,
+ "column": 10
+ }
+ }
+ },
+ "augments": [],
+ "errors": [],
+ "examples": [],
+ "params": [],
+ "properties": [],
+ "returns": [],
+ "sees": [],
+ "throws": [],
+ "todos": [],
+ "name": "om1",
+ "kind": "function",
+ "memberof": "o1",
+ "scope": "static",
+ "members": {
+ "global": [],
+ "inner": [],
+ "instance": [],
+ "events": [],
+ "static": []
+ },
+ "path": [
+ {
+ "name": "o1"
+ },
+ {
+ "name": "om1",
+ "kind": "function",
+ "scope": "static"
+ }
+ ],
+ "namespace": "o1.om1"
+ }
+ ]
},
"path": [
{
@@ -1500,57 +1576,6 @@
],
"namespace": "o1"
},
- {
- "description": "",
- "tags": [],
- "loc": {
- "start": {
- "line": 73,
- "column": 2
- },
- "end": {
- "line": 73,
- "column": 10
- }
- },
- "context": {
- "loc": {
- "start": {
- "line": 73,
- "column": 2
- },
- "end": {
- "line": 73,
- "column": 10
- }
- }
- },
- "augments": [],
- "errors": [],
- "examples": [],
- "params": [],
- "properties": [],
- "returns": [],
- "sees": [],
- "throws": [],
- "todos": [],
- "name": "om1",
- "kind": "function",
- "members": {
- "global": [],
- "inner": [],
- "instance": [],
- "events": [],
- "static": []
- },
- "path": [
- {
- "name": "om1",
- "kind": "function"
- }
- ],
- "namespace": "om1"
- },
{
"description": {
"type": "root",
@@ -1703,7 +1728,65 @@
"inner": [],
"instance": [],
"events": [],
- "static": []
+ "static": [
+ {
+ "description": "",
+ "tags": [],
+ "loc": {
+ "start": {
+ "line": 79,
+ "column": 4
+ },
+ "end": {
+ "line": 79,
+ "column": 12
+ }
+ },
+ "context": {
+ "loc": {
+ "start": {
+ "line": 79,
+ "column": 4
+ },
+ "end": {
+ "line": 79,
+ "column": 12
+ }
+ }
+ },
+ "augments": [],
+ "errors": [],
+ "examples": [],
+ "params": [],
+ "properties": [],
+ "returns": [],
+ "sees": [],
+ "throws": [],
+ "todos": [],
+ "name": "om2",
+ "kind": "function",
+ "memberof": "o2",
+ "scope": "static",
+ "members": {
+ "global": [],
+ "inner": [],
+ "instance": [],
+ "events": [],
+ "static": []
+ },
+ "path": [
+ {
+ "name": "o2"
+ },
+ {
+ "name": "om2",
+ "kind": "function",
+ "scope": "static"
+ }
+ ],
+ "namespace": "o2.om2"
+ }
+ ]
},
"path": [
{
@@ -1711,56 +1794,5 @@
}
],
"namespace": "o2"
- },
- {
- "description": "",
- "tags": [],
- "loc": {
- "start": {
- "line": 79,
- "column": 4
- },
- "end": {
- "line": 79,
- "column": 12
- }
- },
- "context": {
- "loc": {
- "start": {
- "line": 79,
- "column": 4
- },
- "end": {
- "line": 79,
- "column": 12
- }
- }
- },
- "augments": [],
- "errors": [],
- "examples": [],
- "params": [],
- "properties": [],
- "returns": [],
- "sees": [],
- "throws": [],
- "todos": [],
- "name": "om2",
- "kind": "function",
- "members": {
- "global": [],
- "inner": [],
- "instance": [],
- "events": [],
- "static": []
- },
- "path": [
- {
- "name": "om2",
- "kind": "function"
- }
- ],
- "namespace": "om2"
}
]
\ No newline at end of file
diff --git a/test/fixture/document-exported.output.md b/test/fixture/document-exported.output.md
index c87825624..67a06f971 100644
--- a/test/fixture/document-exported.output.md
+++ b/test/fixture/document-exported.output.md
@@ -16,11 +16,11 @@
- [y2Default](#y2default)
- [y4](#y4)
- [object](#object)
+ - [method](#method)
+ - [getter](#getter)
+ - [setter](#setter)
- [prop](#prop)
- [func](#func)
-- [method](#method)
-- [getter](#getter)
-- [setter](#setter)
- [f1](#f1)
- [f3](#f3)
- [T](#t)
@@ -28,10 +28,10 @@
- [T4](#t4)
- [f4](#f4)
- [o1](#o1)
-- [om1](#om1)
+ - [om1](#om1)
- [f5](#f5)
- [o2](#o2)
-- [om2](#om2)
+ - [om2](#om2)
## z
@@ -83,20 +83,20 @@ Returns **void**
## object
-### prop
-
-### func
-
-## method
+### method
-## getter
+### getter
-## setter
+### setter
**Parameters**
- `v`
+### prop
+
+### func
+
## f1
## f3
@@ -121,7 +121,7 @@ Type: [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
## o1
-## om1
+### om1
## f5
@@ -133,4 +133,4 @@ f5 comment
## o2
-## om2
+### om2
diff --git a/test/fixture/document-exported.output.md.json b/test/fixture/document-exported.output.md.json
index ad889a0a2..c694294c2 100644
--- a/test/fixture/document-exported.output.md.json
+++ b/test/fixture/document-exported.output.md.json
@@ -389,26 +389,6 @@
{
"depth": 3,
"type": "heading",
- "children": [
- {
- "type": "text",
- "value": "prop"
- }
- ]
- },
- {
- "depth": 3,
- "type": "heading",
- "children": [
- {
- "type": "text",
- "value": "func"
- }
- ]
- },
- {
- "depth": 2,
- "type": "heading",
"children": [
{
"type": "text",
@@ -417,7 +397,7 @@
]
},
{
- "depth": 2,
+ "depth": 3,
"type": "heading",
"children": [
{
@@ -427,7 +407,7 @@
]
},
{
- "depth": 2,
+ "depth": 3,
"type": "heading",
"children": [
{
@@ -473,6 +453,26 @@
}
]
},
+ {
+ "depth": 3,
+ "type": "heading",
+ "children": [
+ {
+ "type": "text",
+ "value": "prop"
+ }
+ ]
+ },
+ {
+ "depth": 3,
+ "type": "heading",
+ "children": [
+ {
+ "type": "text",
+ "value": "func"
+ }
+ ]
+ },
{
"depth": 2,
"type": "heading",
@@ -650,7 +650,7 @@
]
},
{
- "depth": 2,
+ "depth": 3,
"type": "heading",
"children": [
{
@@ -761,7 +761,7 @@
]
},
{
- "depth": 2,
+ "depth": 3,
"type": "heading",
"children": [
{
diff --git a/test/fixture/params.input.js b/test/fixture/params.input.js
index 28bea72b6..4b5d53bc8 100644
--- a/test/fixture/params.input.js
+++ b/test/fixture/params.input.js
@@ -34,6 +34,18 @@ class Foo {
}
}
+/**
+ * Traditional object
+ */
+var TraditionalObject = {
+ /**
+ * This method should acquire the param x
+ */
+ traditionalMethod: function (x) {
+ return x;
+ }
+};
+
/**
* Represents an IPv6 address
*
diff --git a/test/fixture/params.output.json b/test/fixture/params.output.json
index 4cad94599..1f02a2ee2 100644
--- a/test/fixture/params.output.json
+++ b/test/fixture/params.output.json
@@ -809,6 +809,221 @@
],
"namespace": "Foo"
},
+ {
+ "description": {
+ "type": "root",
+ "children": [
+ {
+ "type": "paragraph",
+ "children": [
+ {
+ "type": "text",
+ "value": "Traditional object",
+ "position": {
+ "start": {
+ "line": 1,
+ "column": 1,
+ "offset": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 19,
+ "offset": 18
+ },
+ "indent": []
+ }
+ }
+ ],
+ "position": {
+ "start": {
+ "line": 1,
+ "column": 1,
+ "offset": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 19,
+ "offset": 18
+ },
+ "indent": []
+ }
+ }
+ ],
+ "position": {
+ "start": {
+ "line": 1,
+ "column": 1,
+ "offset": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 19,
+ "offset": 18
+ }
+ }
+ },
+ "tags": [],
+ "loc": {
+ "start": {
+ "line": 37,
+ "column": 0
+ },
+ "end": {
+ "line": 39,
+ "column": 3
+ }
+ },
+ "context": {
+ "loc": {
+ "start": {
+ "line": 40,
+ "column": 0
+ },
+ "end": {
+ "line": 47,
+ "column": 2
+ }
+ }
+ },
+ "augments": [],
+ "errors": [],
+ "examples": [],
+ "params": [],
+ "properties": [],
+ "returns": [],
+ "sees": [],
+ "throws": [],
+ "todos": [],
+ "name": "TraditionalObject",
+ "members": {
+ "global": [],
+ "inner": [],
+ "instance": [],
+ "events": [],
+ "static": [
+ {
+ "description": {
+ "type": "root",
+ "children": [
+ {
+ "type": "paragraph",
+ "children": [
+ {
+ "type": "text",
+ "value": "This method should acquire the param x",
+ "position": {
+ "start": {
+ "line": 1,
+ "column": 1,
+ "offset": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 39,
+ "offset": 38
+ },
+ "indent": []
+ }
+ }
+ ],
+ "position": {
+ "start": {
+ "line": 1,
+ "column": 1,
+ "offset": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 39,
+ "offset": 38
+ },
+ "indent": []
+ }
+ }
+ ],
+ "position": {
+ "start": {
+ "line": 1,
+ "column": 1,
+ "offset": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 39,
+ "offset": 38
+ }
+ }
+ },
+ "tags": [],
+ "loc": {
+ "start": {
+ "line": 41,
+ "column": 2
+ },
+ "end": {
+ "line": 43,
+ "column": 5
+ }
+ },
+ "context": {
+ "loc": {
+ "start": {
+ "line": 44,
+ "column": 2
+ },
+ "end": {
+ "line": 46,
+ "column": 3
+ }
+ }
+ },
+ "augments": [],
+ "errors": [],
+ "examples": [],
+ "params": [
+ {
+ "title": "param",
+ "name": "x",
+ "lineNumber": 44
+ }
+ ],
+ "properties": [],
+ "returns": [],
+ "sees": [],
+ "throws": [],
+ "todos": [],
+ "name": "traditionalMethod",
+ "kind": "function",
+ "memberof": "TraditionalObject",
+ "scope": "static",
+ "members": {
+ "global": [],
+ "inner": [],
+ "instance": [],
+ "events": [],
+ "static": []
+ },
+ "path": [
+ {
+ "name": "TraditionalObject"
+ },
+ {
+ "name": "traditionalMethod",
+ "kind": "function",
+ "scope": "static"
+ }
+ ],
+ "namespace": "TraditionalObject.traditionalMethod"
+ }
+ ]
+ },
+ "path": [
+ {
+ "name": "TraditionalObject"
+ }
+ ],
+ "namespace": "TraditionalObject"
+ },
{
"description": {
"type": "root",
@@ -965,22 +1180,22 @@
],
"loc": {
"start": {
- "line": 37,
+ "line": 49,
"column": 0
},
"end": {
- "line": 48,
+ "line": 60,
"column": 3
}
},
"context": {
"loc": {
"start": {
- "line": 49,
+ "line": 61,
"column": 0
},
"end": {
- "line": 49,
+ "line": 61,
"column": 22
}
}
@@ -1443,22 +1658,22 @@
],
"loc": {
"start": {
- "line": 51,
+ "line": 63,
"column": 0
},
"end": {
- "line": 62,
+ "line": 74,
"column": 3
}
},
"context": {
"loc": {
"start": {
- "line": 63,
+ "line": 75,
"column": 0
},
"end": {
- "line": 65,
+ "line": 77,
"column": 1
}
}
@@ -1903,22 +2118,22 @@
],
"loc": {
"start": {
- "line": 67,
+ "line": 79,
"column": 0
},
"end": {
- "line": 74,
+ "line": 86,
"column": 3
}
},
"context": {
"loc": {
"start": {
- "line": 75,
+ "line": 87,
"column": 0
},
"end": {
- "line": 75,
+ "line": 87,
"column": 37
}
}
@@ -2143,22 +2358,22 @@
],
"loc": {
"start": {
- "line": 77,
+ "line": 89,
"column": 0
},
"end": {
- "line": 82,
+ "line": 94,
"column": 3
}
},
"context": {
"loc": {
"start": {
- "line": 83,
+ "line": 95,
"column": 0
},
"end": {
- "line": 85,
+ "line": 97,
"column": 1
}
}
diff --git a/test/fixture/params.output.md b/test/fixture/params.output.md
index e0395b3fb..aed20ddb1 100644
--- a/test/fixture/params.output.md
+++ b/test/fixture/params.output.md
@@ -7,6 +7,8 @@
- [withDefault](#withdefault)
- [Foo](#foo)
- [method](#method)
+- [TraditionalObject](#traditionalobject)
+ - [traditionalMethod](#traditionalmethod)
- [Address6](#address6)
- [GeoJSONSource](#geojsonsource)
- [myfunc](#myfunc)
@@ -56,6 +58,18 @@ The method
- `x` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Param to method
+## TraditionalObject
+
+Traditional object
+
+### traditionalMethod
+
+This method should acquire the param x
+
+**Parameters**
+
+- `x`
+
## Address6
Represents an IPv6 address
diff --git a/test/fixture/params.output.md.json b/test/fixture/params.output.md.json
index 36439eb13..69bff4d98 100644
--- a/test/fixture/params.output.md.json
+++ b/test/fixture/params.output.md.json
@@ -761,6 +761,133 @@
}
]
},
+ {
+ "depth": 2,
+ "type": "heading",
+ "children": [
+ {
+ "type": "text",
+ "value": "TraditionalObject"
+ }
+ ]
+ },
+ {
+ "type": "paragraph",
+ "children": [
+ {
+ "type": "text",
+ "value": "Traditional object",
+ "position": {
+ "start": {
+ "line": 1,
+ "column": 1,
+ "offset": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 19,
+ "offset": 18
+ },
+ "indent": []
+ }
+ }
+ ],
+ "position": {
+ "start": {
+ "line": 1,
+ "column": 1,
+ "offset": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 19,
+ "offset": 18
+ },
+ "indent": []
+ }
+ },
+ {
+ "depth": 3,
+ "type": "heading",
+ "children": [
+ {
+ "type": "text",
+ "value": "traditionalMethod"
+ }
+ ]
+ },
+ {
+ "type": "paragraph",
+ "children": [
+ {
+ "type": "text",
+ "value": "This method should acquire the param x",
+ "position": {
+ "start": {
+ "line": 1,
+ "column": 1,
+ "offset": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 39,
+ "offset": 38
+ },
+ "indent": []
+ }
+ }
+ ],
+ "position": {
+ "start": {
+ "line": 1,
+ "column": 1,
+ "offset": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 39,
+ "offset": 38
+ },
+ "indent": []
+ }
+ },
+ {
+ "type": "strong",
+ "children": [
+ {
+ "type": "text",
+ "value": "Parameters"
+ }
+ ]
+ },
+ {
+ "ordered": false,
+ "type": "list",
+ "children": [
+ {
+ "type": "listItem",
+ "children": [
+ {
+ "type": "paragraph",
+ "children": [
+ {
+ "type": "inlineCode",
+ "value": "x"
+ },
+ {
+ "type": "text",
+ "value": " "
+ },
+ {
+ "type": "text",
+ "value": " "
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
{
"depth": 2,
"type": "heading",
diff --git a/test/lib/infer/finders.js b/test/lib/infer/finders.js
new file mode 100644
index 000000000..f591ffe0d
--- /dev/null
+++ b/test/lib/infer/finders.js
@@ -0,0 +1,53 @@
+'use strict';
+
+var test = require('tap').test,
+ parse = require('../../../lib/parsers/javascript'),
+ findTarget = require('../../../lib/infer/finders').findTarget;
+
+function toComment(fn) {
+
+ if (typeof fn == 'function') {
+ fn = '(' + fn.toString() + ')';
+ }
+
+ return parse({
+ source: fn
+ }, {})[0];
+}
+
+function evaluate(fn, re) {
+ return toComment(fn);
+}
+
+test('findTarget', function (t) {
+ t.equal(findTarget(toComment(function () {
+ /** Test */
+ var x = 10;
+ }).context.ast).type, 'VariableDeclarator', 'variable declarator');
+
+ t.equal(findTarget(toComment(function () {
+ var z = {};
+
+ /** Test */
+ z.y = 10;
+ }).context.ast).type, 'NumericLiteral', 'assigned object value');
+
+ t.equal(findTarget(toComment(function () {
+ var z = {
+ /** Test */
+ y: 10
+ };
+ }).context.ast).type, 'NumericLiteral', 'object property');
+
+ t.equal(findTarget(toComment(`
+ /** Test */
+ export var z = 10;
+ `).context.ast).type, 'VariableDeclarator', 'variable declarator in export');
+
+ t.equal(findTarget(toComment(`
+ /** Test */
+ export default 10;
+ `).context.ast).type, 'NumericLiteral', 'default export');
+
+ t.end();
+});
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