Skip to content

Commit d37ee30

Browse files
author
Anand Thakker
committed
Add very rudimentary support for @typedef
1 parent 72831ad commit d37ee30

File tree

7 files changed

+129
-1
lines changed

7 files changed

+129
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"JSONStream": "^0.10.0",
2525
"ast-types": "^0.7.2",
2626
"concat-stream": "^1.4.7",
27-
"doctrine": "^0.6.4",
27+
"doctrine": "constellation/doctrine#da4635ec2e9cbb4b593b2bd49584defc5843abd8",
2828
"espree": "^1.12.2",
2929
"extend": "^2.0.0",
3030
"github-url-from-git": "^1.4.0",

share/html/section.hbs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,25 @@
5151
{{/returns}}
5252
{{/if}}
5353

54+
{{#if properties}}
55+
<p>
56+
<table class='table-light overflow-hidden bg-cloudy-light'>
57+
<thead>
58+
<th class='col-3'>property</th>
59+
<th class='col-3'>type</th>
60+
<th class='col-6'>description</th>
61+
</thead>
62+
{{#properties}}
63+
<tr>
64+
<td>{{name}}</td>
65+
<td>{{{format_type type}}}</td>
66+
<td>{{{md description}}}</td>
67+
</tr>
68+
{{/properties}}
69+
</table>
70+
</p>
71+
{{/if}}
72+
5473
{{#if examples}}
5574
<h4>Examples</h4>
5675
{{#each examples ~}}<pre>{{{.}}}</pre>{{/each}}

test/fixture/html/nested.output.files

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,7 @@ section:target {
15051505

15061506

15071507

1508+
15081509
<div class='section-indent'>
15091510
<section id='klass/magic-number'class='mt2 mb2 py1 px3 keyline-top'>
15101511
<h3 class='regular'>
@@ -1522,6 +1523,7 @@ section:target {
15221523

15231524

15241525

1526+
15251527
</section>
15261528
</div>
15271529
<div class='section-indent'>
@@ -1564,6 +1566,7 @@ This is a <a href="doesnot"><code>link to something that does not exist</code></
15641566

15651567

15661568

1569+
15671570
</section>
15681571
</div>
15691572

@@ -1588,6 +1591,7 @@ This is a <a href="doesnot"><code>link to something that does not exist</code></
15881591

15891592
</span>
15901593

1594+
15911595
<h4>Examples</h4>
15921596
<pre>foo.getFoo();</pre>
15931597

@@ -1622,6 +1626,7 @@ like a <a href="klass"><code>klass</code></a></p>
16221626

16231627

16241628

1629+
16251630
</section>
16261631

16271632
</div>

test/fixture/typedef.input.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* A type definition.
3+
* @name MyType
4+
* @typedef {Object} MyType
5+
* @property {number} prop1 - one property
6+
* @property {string} prop2 - another property
7+
*/
8+

test/fixture/typedef.output.custom.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## `MyType`
2+
3+
A type definition.
4+
5+
6+

test/fixture/typedef.output.json

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
[
2+
{
3+
"description": "A type definition.",
4+
"tags": [
5+
{
6+
"title": "name",
7+
"description": null,
8+
"name": "MyType"
9+
},
10+
{
11+
"title": "typedef",
12+
"description": null,
13+
"type": {
14+
"type": "NameExpression",
15+
"name": "Object"
16+
},
17+
"name": "MyType"
18+
},
19+
{
20+
"title": "property",
21+
"description": "one property",
22+
"type": {
23+
"type": "NameExpression",
24+
"name": "number"
25+
},
26+
"name": "prop1"
27+
},
28+
{
29+
"title": "property",
30+
"description": "another property",
31+
"type": {
32+
"type": "NameExpression",
33+
"name": "string"
34+
},
35+
"name": "prop2"
36+
},
37+
{
38+
"title": "kind",
39+
"kind": "typedef"
40+
}
41+
],
42+
"context": {
43+
"loc": {
44+
"start": {
45+
"line": 9,
46+
"column": 0
47+
},
48+
"end": {
49+
"line": 9,
50+
"column": 0
51+
}
52+
},
53+
"file": "fixture/typedef.input.js"
54+
},
55+
"name": "MyType",
56+
"properties": [
57+
{
58+
"title": "property",
59+
"description": "one property",
60+
"type": {
61+
"type": "NameExpression",
62+
"name": "number"
63+
},
64+
"name": "prop1"
65+
},
66+
{
67+
"title": "property",
68+
"description": "another property",
69+
"type": {
70+
"type": "NameExpression",
71+
"name": "string"
72+
},
73+
"name": "prop2"
74+
}
75+
],
76+
"kind": "typedef"
77+
}
78+
]

test/fixture/typedef.output.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## `MyType`
2+
3+
A type definition.
4+
5+
6+
| name | type | description |
7+
| ---- | ---- | ----------- |
8+
| `prop1` | `number` | one property |
9+
| `prop2` | `string` | another property |
10+
11+
12+

0 commit comments

Comments
 (0)