Skip to content

Commit a12fa91

Browse files
committed
Update to be on par with JSDoc features
1 parent ea3582e commit a12fa91

File tree

8 files changed

+92
-6
lines changed

8 files changed

+92
-6
lines changed

fixtures/generators/generator.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Generate numbers in the Fibonacci sequence.
3+
*
4+
* @generator
5+
* @function fibonacci
6+
* @yields {number} The next number in the Fibonacci sequence.
7+
*/
8+
9+
function *fibonacci(n) {
10+
const infinite = !n && n !== 0;
11+
let current = 0;
12+
let next = 1;
13+
14+
while (infinite || n--) {
15+
yield current;
16+
[current, next] = [next, current + next];
17+
}
18+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "docdash",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "A clean, responsive documentation template theme for JSDoc 3 inspired by lodash and minami",
55
"main": "publish.js",
66
"scripts": {

publish.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ function needsSignature(doclet) {
8383
}
8484
}
8585
}
86+
// and namespaces that are functions get a signature (but finding them is a
87+
// bit messy)
88+
else if (doclet.kind === 'namespace' && doclet.meta && doclet.meta.code &&
89+
doclet.meta.code.type && doclet.meta.code.type.match(/[Ff]unction/)) {
90+
needsSig = true;
91+
}
8692

8793
return needsSig;
8894
}
@@ -168,12 +174,13 @@ function addSignatureReturns(f) {
168174
var attribsString = '';
169175
var returnTypes = [];
170176
var returnTypesString = '';
177+
var source = f.yields || f.returns;
171178

172179
// jam all the return-type attributes into an array. this could create odd results (for example,
173180
// if there are both nullable and non-nullable return types), but let's assume that most people
174181
// who use multiple @return tags aren't using Closure Compiler type annotations, and vice-versa.
175-
if (f.returns) {
176-
f.returns.forEach(function(item) {
182+
if (source) {
183+
source.forEach(function(item) {
177184
helper.getAttribs(item).forEach(function(attrib) {
178185
if (attribs.indexOf(attrib) === -1) {
179186
attribs.push(attrib);
@@ -184,8 +191,8 @@ function addSignatureReturns(f) {
184191
attribsString = buildAttribsString(attribs);
185192
}
186193

187-
if (f.returns) {
188-
returnTypes = addNonParamAttributes(f.returns);
194+
if (source) {
195+
returnTypes = addNonParamAttributes(source);
189196
}
190197
if (returnTypes.length) {
191198
returnTypesString = util.format( ' → %s{%s}', attribsString, returnTypes.join('|') );

tmpl/container.tmpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@
9393
<dd><?js if (c.summary) { ?><?js= c.summary ?><?js } ?></dd>
9494
<?js }); ?></dl>
9595
<?js } ?>
96+
97+
<?js
98+
var interfaces = self.find({kind: 'interface', memberof: doc.longname});
99+
if (!isGlobalPage && interfaces && interfaces.length) {
100+
?>
101+
<h3 class="subsection-title">Interfaces</h3>
102+
103+
<dl><?js interfaces.forEach(function(i) { ?>
104+
<dt><?js= self.linkto(i.longname, i.name) ?></dt>
105+
<dd><?js if (i.summary) { ?><?js= i.summary ?><?js } ?></dd>
106+
<?js }); ?></dl>
107+
<?js } ?>
96108

97109
<?js
98110
var mixins = self.find({kind: 'mixin', memberof: doc.longname});

tmpl/mainpage.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ var data = obj;
33
var self = this;
44
?>
55

6+
<?js if (data.kind === 'package') { ?>
7+
<section class="package">
8+
<h3><?js= data.name ?> <?js= data.version ?></h3>
9+
</section>
10+
<?js } ?>
611
<?js if (data.readme) { ?>
712
<section class="readme">
813
<article><?js= data.readme ?></article>

tmpl/method.tmpl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ var self = this;
8787
<?js }); ?></ul>
8888
<?js } ?>
8989

90+
<?js if (data.modifies && modifies.length) {?>
91+
<h5>Modifies:</h5>
92+
<?js if (modifies.length > 1) { ?><ul><?js
93+
modifies.forEach(function(m) { ?>
94+
<li><?js= self.partial('modifies.tmpl', m) ?></li>
95+
<?js });
96+
?></ul><?js } else {
97+
modifies.forEach(function(m) { ?>
98+
<?js= self.partial('modifies.tmpl', m) ?>
99+
<?js });
100+
} } ?>
101+
90102
<?js if (data.exceptions && exceptions.length) { ?>
91103
<h5>Throws:</h5>
92104
<?js if (exceptions.length > 1) { ?><ul><?js
@@ -111,3 +123,14 @@ var self = this;
111123
<?js });
112124
} } ?>
113125

126+
<?js if (data.yields && yields.length) { ?>
127+
<h5>Yields:</h5>
128+
<?js if (yields.length > 1) { ?><ul><?js
129+
yields.forEach(function(r) { ?>
130+
<li><?js= self.partial('returns.tmpl', r) ?></li>
131+
<?js });
132+
?></ul><?js } else {
133+
yields.forEach(function(r) { ?>
134+
<?js= self.partial('returns.tmpl', r) ?>
135+
<?js });
136+
} } ?>

tmpl/modifies.tmpl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?js
2+
var data = obj || {};
3+
?>
4+
5+
<?js if (data.type && data.type.names) {?>
6+
<dl>
7+
<dt>
8+
Type
9+
</dt>
10+
<dd>
11+
<?js= this.partial('type.tmpl', data.type.names) ?>
12+
</dd>
13+
</dl>
14+
<?js } ?>

tmpl/params.tmpl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@
1111
}
1212

1313
if (parentParam && parentParam.name && param.name) {
14-
paramRegExp = new RegExp('^(?:' + parentParam.name + '(?:\\[\\])*)\\.(.+)$');
14+
try {
15+
paramRegExp = new RegExp('^(?:' + parentParam.name + '(?:\\[\\])*)\\.(.+)$');
16+
}
17+
catch (e) {
18+
// there's probably a typo in the JSDoc comment that resulted in a weird
19+
// parameter name
20+
return;
21+
}
1522

1623
if ( paramRegExp.test(param.name) ) {
1724
param.name = RegExp.$1;

0 commit comments

Comments
 (0)