Skip to content

Commit 725ce2e

Browse files
committed
Added parameters to function name with optional brackets.
1 parent c618cdb commit 725ce2e

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

lib/utils.js

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ module.exports.formatStringForName = function (content) {
113113

114114
content = String(content);
115115

116-
content = content.replace(/\.prototype/g, '');
116+
content = content.replace(/\.prototype|\(\)/g, '');
117117

118118
return content;
119119

@@ -136,7 +136,11 @@ module.exports.parseData = function (data, file) {
136136

137137
data.forEach(function (item) {
138138

139-
var method = {};
139+
var method = {},
140+
params = {
141+
required: [],
142+
optional: []
143+
};
140144

141145
if (!item.ignore && item.ctx) {
142146

@@ -185,6 +189,44 @@ module.exports.parseData = function (data, file) {
185189

186190
});
187191

192+
if (method.tags.param) {
193+
194+
method.tags.param.forEach(function (tag) {
195+
196+
if (!tag.name.match(/\./)) {
197+
198+
if (tag.isOptional) {
199+
200+
params.optional.push(tag.name);
201+
202+
} else {
203+
204+
params.required.push(tag.name);
205+
206+
}
207+
208+
}
209+
210+
});
211+
212+
method.params = params.required.join(', ');
213+
214+
if (params.optional.length) {
215+
216+
if (method.params) {
217+
218+
method.params += '[, ' + params.optional.join(', ') + ']';
219+
220+
} else {
221+
222+
method.params += '[' + params.optional.join(', ') + ']';
223+
224+
}
225+
226+
}
227+
228+
}
229+
188230
methods.push(method);
189231

190232
}

templates/bootstrap.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ pre .hljs {
270270
<div class="method scope-{{#if isPrivate}}private{{else}}public{{/if}}">
271271

272272
<h2 id="{{uid}}">
273-
<a href="#{{uid}}" class="permalink">#</a> {{name}}
273+
<a href="#{{uid}}" class="permalink">#</a> {{name}}({{params}})
274274
{{#if isPrivate}}
275275
<small>private {{type}}</small>
276276
{{/if}}

templates/dash/method.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pre .hljs {
3939
<div class="method scope-{{#if isPrivate}}private{{else}}public{{/if}}">
4040

4141
<h2 id="{{uid}}">
42-
{{name}}
42+
{{name}}({{params}})
4343
{{#if isPrivate}}
4444
<small>private {{type}}</small>
4545
{{/if}}

0 commit comments

Comments
 (0)