Skip to content

Commit f9ddb9c

Browse files
authored
Output typedef content in Markdown and HTML. Fixes #359 (#619)
1 parent 6998a05 commit f9ddb9c

14 files changed

+898
-0
lines changed

default_theme/section._

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919

2020
<div class='pre p1 fill-light mt0'><%= signature(section) %></div>
2121

22+
<% if (section.type) { %>
23+
<p>
24+
Type:
25+
<%= formatType(section.type) %>
26+
</p>
27+
<% } %>
28+
2229
<% if (section.augments) { %>
2330
<p>
2431
Extends

lib/output/markdown_ast.js

+9
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ function commentsToAST(comments, options, callback) {
4343
*/
4444
function generate(depth, comment) {
4545

46+
function typeSection(comment) {
47+
return comment.type && u('paragraph', [
48+
u('text', 'Type: ')
49+
].concat(
50+
formatType(comment.type)
51+
));
52+
}
53+
4654
function paramList(params) {
4755
return u('list', { ordered: false }, params.map(function (param) {
4856
return u('listItem', [
@@ -176,6 +184,7 @@ function commentsToAST(comments, options, callback) {
176184
.concat(githubLink(comment))
177185
.concat(augmentsLink(comment))
178186
.concat(comment.description ? comment.description.children : [])
187+
.concat(typeSection(comment))
179188
.concat(paramSection(comment))
180189
.concat(propertySection(comment))
181190
.concat(examplesSection(comment))

test/fixture/document-exported.output.md

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535
# T5
3636

37+
Type: [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
38+
3739
# y2Default
3840

3941
# y4
@@ -68,10 +70,16 @@ Returns **void**
6870

6971
# T
7072

73+
Type: [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)
74+
7175
# T2
7276

77+
Type: [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)
78+
7379
# T4
7480

81+
Type: [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)
82+
7583
# f4
7684

7785
**Parameters**

test/fixture/document-exported.output.md.json

+80
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,26 @@
226226
}
227227
]
228228
},
229+
{
230+
"type": "paragraph",
231+
"children": [
232+
{
233+
"type": "text",
234+
"value": "Type: "
235+
},
236+
{
237+
"href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean",
238+
"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean",
239+
"type": "link",
240+
"children": [
241+
{
242+
"type": "text",
243+
"value": "boolean"
244+
}
245+
]
246+
}
247+
]
248+
},
229249
{
230250
"depth": 1,
231251
"type": "heading",
@@ -483,6 +503,26 @@
483503
}
484504
]
485505
},
506+
{
507+
"type": "paragraph",
508+
"children": [
509+
{
510+
"type": "text",
511+
"value": "Type: "
512+
},
513+
{
514+
"href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number",
515+
"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number",
516+
"type": "link",
517+
"children": [
518+
{
519+
"type": "text",
520+
"value": "number"
521+
}
522+
]
523+
}
524+
]
525+
},
486526
{
487527
"depth": 1,
488528
"type": "heading",
@@ -493,6 +533,26 @@
493533
}
494534
]
495535
},
536+
{
537+
"type": "paragraph",
538+
"children": [
539+
{
540+
"type": "text",
541+
"value": "Type: "
542+
},
543+
{
544+
"href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String",
545+
"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String",
546+
"type": "link",
547+
"children": [
548+
{
549+
"type": "text",
550+
"value": "string"
551+
}
552+
]
553+
}
554+
]
555+
},
496556
{
497557
"depth": 1,
498558
"type": "heading",
@@ -503,6 +563,26 @@
503563
}
504564
]
505565
},
566+
{
567+
"type": "paragraph",
568+
"children": [
569+
{
570+
"type": "text",
571+
"value": "Type: "
572+
},
573+
{
574+
"href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String",
575+
"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String",
576+
"type": "link",
577+
"children": [
578+
{
579+
"type": "text",
580+
"value": "string"
581+
}
582+
]
583+
}
584+
]
585+
},
506586
{
507587
"depth": 1,
508588
"type": "heading",

test/fixture/html/nested.config-output.html

+34
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ <h3 class='fl m0' id='klass'>
258258
<div class='pre p1 fill-light mt0'>new Klass(foo: any)</div>
259259

260260

261+
262+
261263
<p>
262264
Extends
263265

@@ -321,6 +323,8 @@ <h3 class='fl m0' id='klass'>
321323

322324

323325

326+
327+
324328

325329

326330

@@ -396,6 +400,8 @@ <h3 class='fl m0' id='klass'>
396400

397401

398402

403+
404+
399405

400406

401407

@@ -462,6 +468,8 @@ <h3 class='fl m0' id='klass'>
462468

463469

464470

471+
472+
465473

466474

467475

@@ -538,6 +546,8 @@ <h3 class='fl m0' id='klass'>
538546

539547

540548

549+
550+
541551

542552

543553

@@ -612,6 +622,8 @@ <h3 class='fl m0' id='klass'>
612622

613623

614624

625+
626+
615627

616628

617629

@@ -657,6 +669,8 @@ <h3 class='fl m0' id='klass'>
657669

658670

659671

672+
673+
660674

661675

662676

@@ -710,6 +724,8 @@ <h3 class='fl m0' id='klass'>
710724

711725

712726

727+
728+
713729

714730

715731

@@ -770,6 +786,8 @@ <h3 class='fl m0' id='klass'>
770786

771787

772788

789+
790+
773791

774792

775793

@@ -875,6 +893,8 @@ <h3 class='fl m0' id='customerror'>
875893

876894

877895

896+
897+
878898

879899

880900

@@ -949,6 +969,8 @@ <h3 class='fl m0' id='bar'>
949969

950970

951971

972+
973+
952974

953975

954976

@@ -1003,6 +1025,8 @@ <h3 class='fl m0' id='bar'>
10031025

10041026

10051027

1028+
1029+
10061030

10071031

10081032

@@ -1072,6 +1096,8 @@ <h3 class='fl m0' id='bar'>
10721096

10731097

10741098

1099+
1100+
10751101

10761102

10771103

@@ -1125,6 +1151,8 @@ <h3 class='fl m0' id='foo'>
11251151

11261152

11271153

1154+
1155+
11281156

11291157

11301158

@@ -1167,6 +1195,8 @@ <h3 class='fl m0' id='foo'>
11671195

11681196

11691197

1198+
1199+
11701200

11711201

11721202

@@ -1220,6 +1250,8 @@ <h3 class='fl m0' id='customstreams'>
12201250

12211251
<div class='pre p1 fill-light mt0'>customStreams</div>
12221252

1253+
1254+
12231255

12241256

12251257

@@ -1262,6 +1294,8 @@ <h3 class='fl m0' id='customstreams'>
12621294

12631295

12641296

1297+
1298+
12651299

12661300

12671301

0 commit comments

Comments
 (0)