Skip to content

Commit 4e50bf3

Browse files
committed
Tag sections only display where appropriate.
1 parent 989881c commit 4e50bf3

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

lib/helpers.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module.exports = function (hbs) {
22

3+
var context;
4+
35
hbs.registerHelper('ifCond', function (a, b, options) {
46
return a === b ? options.fn(this) : options.inverse(this);
57
});
@@ -12,4 +14,12 @@ module.exports = function (hbs) {
1214
return String(name).replace(/\.prototype/g, '');
1315
});
1416

17+
hbs.registerHelper('registerContext', function () {
18+
context = this;
19+
});
20+
21+
hbs.registerHelper('registerVariable', function (name, value) {
22+
context[name] = value;
23+
});
24+
1525
};

templates/bootstrap.hbs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,20 @@
9999

100100
{{#if ctx}}
101101

102+
{{registerContext this}}
103+
102104
<h2 id="{{formatId ctx.string}}">
103105
<a href="#{{formatId ctx.string}}" class="permalink">#</a> {{formatName ctx.string}}
104106
</h2>
105107

106108
{{{description.summary}}}
107109

110+
{{#each tags}}{{#ifCond type "param"}}
111+
{{registerVariable "displayParameters" true}}
112+
{{/ifCond}}{{/each}}
113+
114+
{{#if displayParameters}}
115+
108116
<section class="parameters">
109117

110118
<h3>Parameters</h3>
@@ -130,6 +138,14 @@
130138

131139
</section>
132140

141+
{{/if}}
142+
143+
{{#each tags}}{{#ifCond type "property"}}
144+
{{registerVariable "displayProperties" true}}
145+
{{/ifCond}}{{/each}}
146+
147+
{{#if displayProperties}}
148+
133149
<section class="properties">
134150

135151
<h3>Properties</h3>
@@ -155,6 +171,8 @@
155171

156172
</section>
157173

174+
{{/if}}
175+
158176
<section class="examples">
159177

160178
<h3>Examples</h3>

templates/markdown.hbs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,40 @@
33
>{{description}}
44

55
{{#each methods}}{{#unless ignore}}{{#if ctx}}
6+
7+
{{registerContext this}}
8+
69
##{{formatName ctx.string}}
710
{{{description.summary}}}
811

12+
{{#each tags}}{{#ifCond type "param"}}
13+
{{registerVariable "displayParameters" true}}
14+
{{/ifCond}}{{/each}}
15+
16+
{{#if displayParameters}}
17+
918
###Parameters
1019

1120
{{#each tags}}{{#ifCond type "param"}}
1221
- **{{name}}** {{#each types}}`{{.}}`{{/each}} {{#if optional}}_Optional_{{/if}} {{{description}}}
1322
{{/ifCond}}{{/each}}
1423

24+
{{/if}}
25+
26+
{{#each tags}}{{#ifCond type "property"}}
27+
{{registerVariable "displayProperties" true}}
28+
{{/ifCond}}{{/each}}
29+
30+
{{#if displayProperties}}
31+
1532
###Properties
1633

1734
{{#each tags}}{{#ifCond type "property"}}
1835
- **{{name}}** {{#each types}}`{{.}}`{{/each}} {{#if optional}}_Optional_{{/if}} {{{description}}}
1936
{{/ifCond}}{{/each}}
2037

38+
{{/if}}
39+
2140
###Examples
2241

2342
{{{description.body}}}

0 commit comments

Comments
 (0)