Skip to content

Commit 3052584

Browse files
committed
Handle both flattened and unflattened forms
1 parent 7ff8584 commit 3052584

19 files changed

+476
-14
lines changed

lib/html_helpers.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ function autolink(paths, text) {
8888
* // generates String
8989
*/
9090
function formatType(type, paths) {
91+
if (!type) {
92+
return '';
93+
}
9194
function recurse(element) {
9295
return formatType(element, paths);
9396
}

lib/infer/params.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ module.exports = function inferParams(comment) {
1616

1717
// Ensure that explicitly specified parameters are not overridden
1818
// by inferred parameters
19-
var existingParams = comment.tags.filter(function (tag) {
20-
return tag.title === 'param';
21-
}).reduce(function (memo, param) {
19+
var existingParams = (comment.params || []).reduce(function (memo, param) {
2220
memo[param.name] = param;
2321
return memo;
2422
}, {});
@@ -32,6 +30,14 @@ module.exports = function inferParams(comment) {
3230
name: param.name,
3331
lineNumber: param.loc.start.line
3432
});
33+
if (!comment.params) {
34+
comment.params = [];
35+
}
36+
comment.params.push({
37+
title: 'param',
38+
name: param.name,
39+
lineNumber: param.loc.start.line
40+
});
3541
}
3642
paramOrder.push(param.name);
3743
});
@@ -41,12 +47,15 @@ module.exports = function inferParams(comment) {
4147
// they actually appear in code
4248
comment.tags.sort(function (a, b) {
4349
if (a.title === 'param' && b.title === 'param') {
44-
return paramOrder.indexOf(a.name) -
45-
paramOrder.indexOf(b.name);
50+
return paramOrder.indexOf(a.name) - paramOrder.indexOf(b.name);
4651
}
4752
return 0;
4853
});
4954

55+
(comment.params || []).sort(function (a, b) {
56+
return paramOrder.indexOf(a.name) - paramOrder.indexOf(b.name);
57+
});
58+
5059
this.abort();
5160
}
5261
});

test/fixture/es6.output.custom.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
This function returns the number one.
44

55

6+
**Parameters**
7+
8+
- `a`
9+
10+
- `b`
11+
12+
13+
614
Returns **Number** numberone
715

816

test/fixture/es6.output.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@
5959
],
6060
"name": "multiply",
6161
"kind": "function",
62+
"params": [
63+
{
64+
"title": "param",
65+
"name": "a",
66+
"lineNumber": 5
67+
},
68+
{
69+
"title": "param",
70+
"name": "b",
71+
"lineNumber": 5
72+
}
73+
],
6274
"members": {
6375
"instance": [],
6476
"static": []

test/fixture/es6.output.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
This function returns the number one.
44

55

6+
**Parameters**
7+
8+
- `a`
9+
10+
- `b`
11+
12+
13+
614
Returns **Number** numberone
715

816

test/fixture/es6.output.md.json

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,98 @@
6060
}
6161
}
6262
},
63+
{
64+
"type": "root",
65+
"children": [
66+
{
67+
"type": "strong",
68+
"children": [
69+
{
70+
"type": "text",
71+
"value": "Parameters"
72+
}
73+
]
74+
},
75+
{
76+
"ordered": false,
77+
"type": "list",
78+
"children": [
79+
{
80+
"type": "listItem",
81+
"children": [
82+
{
83+
"type": "paragraph",
84+
"children": [
85+
{
86+
"type": "inlineCode",
87+
"value": "a"
88+
},
89+
{
90+
"type": "text",
91+
"value": " "
92+
},
93+
{
94+
"type": "text",
95+
"value": " "
96+
},
97+
{
98+
"type": "root",
99+
"children": [],
100+
"position": {
101+
"start": {
102+
"line": 1,
103+
"column": 1
104+
},
105+
"end": {
106+
"line": 1,
107+
"column": 1
108+
}
109+
}
110+
}
111+
]
112+
}
113+
]
114+
},
115+
{
116+
"type": "listItem",
117+
"children": [
118+
{
119+
"type": "paragraph",
120+
"children": [
121+
{
122+
"type": "inlineCode",
123+
"value": "b"
124+
},
125+
{
126+
"type": "text",
127+
"value": " "
128+
},
129+
{
130+
"type": "text",
131+
"value": " "
132+
},
133+
{
134+
"type": "root",
135+
"children": [],
136+
"position": {
137+
"start": {
138+
"line": 1,
139+
"column": 1
140+
},
141+
"end": {
142+
"line": 1,
143+
"column": 1
144+
}
145+
}
146+
}
147+
]
148+
}
149+
]
150+
}
151+
]
152+
}
153+
]
154+
},
63155
{
64156
"type": "root",
65157
"children": [

test/fixture/factory.output.custom.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,21 @@ Returns **area** chart
1313

1414

1515

16+
**Parameters**
17+
18+
- `selection`
19+
20+
21+
1622

1723
# data
1824

1925
Sets the chart data.
2026

2127

28+
**Parameters**
29+
30+
- `_`
31+
32+
33+

test/fixture/factory.output.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@
103103
},
104104
"name": "area",
105105
"kind": "class",
106+
"params": [
107+
{
108+
"title": "param",
109+
"name": "selection",
110+
"lineNumber": 10
111+
}
112+
],
106113
"members": {
107114
"instance": [],
108115
"static": []
@@ -156,6 +163,13 @@
156163
"function": null,
157164
"name": "data",
158165
"kind": "function",
166+
"params": [
167+
{
168+
"title": "param",
169+
"name": "_",
170+
"lineNumber": 17
171+
}
172+
],
159173
"memberof": "chart",
160174
"scope": "static",
161175
"members": {

test/fixture/factory.output.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,21 @@ Returns **area** chart
1313

1414

1515

16+
**Parameters**
17+
18+
- `selection`
19+
20+
21+
1622

1723
# data
1824

1925
Sets the chart data.
2026

2127

28+
**Parameters**
29+
30+
- `_`
31+
32+
33+

test/fixture/factory.output.md.json

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,62 @@
161161
"column": 1
162162
}
163163
}
164+
},
165+
{
166+
"type": "root",
167+
"children": [
168+
{
169+
"type": "strong",
170+
"children": [
171+
{
172+
"type": "text",
173+
"value": "Parameters"
174+
}
175+
]
176+
},
177+
{
178+
"ordered": false,
179+
"type": "list",
180+
"children": [
181+
{
182+
"type": "listItem",
183+
"children": [
184+
{
185+
"type": "paragraph",
186+
"children": [
187+
{
188+
"type": "inlineCode",
189+
"value": "selection"
190+
},
191+
{
192+
"type": "text",
193+
"value": " "
194+
},
195+
{
196+
"type": "text",
197+
"value": " "
198+
},
199+
{
200+
"type": "root",
201+
"children": [],
202+
"position": {
203+
"start": {
204+
"line": 1,
205+
"column": 1
206+
},
207+
"end": {
208+
"line": 1,
209+
"column": 1
210+
}
211+
}
212+
}
213+
]
214+
}
215+
]
216+
}
217+
]
218+
}
219+
]
164220
}
165221
]
166222
},
@@ -222,6 +278,62 @@
222278
"column": 21
223279
}
224280
}
281+
},
282+
{
283+
"type": "root",
284+
"children": [
285+
{
286+
"type": "strong",
287+
"children": [
288+
{
289+
"type": "text",
290+
"value": "Parameters"
291+
}
292+
]
293+
},
294+
{
295+
"ordered": false,
296+
"type": "list",
297+
"children": [
298+
{
299+
"type": "listItem",
300+
"children": [
301+
{
302+
"type": "paragraph",
303+
"children": [
304+
{
305+
"type": "inlineCode",
306+
"value": "_"
307+
},
308+
{
309+
"type": "text",
310+
"value": " "
311+
},
312+
{
313+
"type": "text",
314+
"value": " "
315+
},
316+
{
317+
"type": "root",
318+
"children": [],
319+
"position": {
320+
"start": {
321+
"line": 1,
322+
"column": 1
323+
},
324+
"end": {
325+
"line": 1,
326+
"column": 1
327+
}
328+
}
329+
}
330+
]
331+
}
332+
]
333+
}
334+
]
335+
}
336+
]
225337
}
226338
]
227339
}

0 commit comments

Comments
 (0)