Added output for returns and params in the default template.

This commit is contained in:
Michael Mathews 2011-01-05 15:26:27 +00:00
parent 6d4c1e61c1
commit ae71115165
5 changed files with 57 additions and 3 deletions

View File

@ -171,7 +171,13 @@
dictionary.defineTag('param', {
mustHaveValue: true,
canHaveType: true,
canHaveName: true
canHaveName: true,
onTagged: function(doclet, tag) {
if (!doclet.params) { doclet.params = []; }
doclet.params.push(tag.value);
return false;
}
});
dictionary.defineTag('private', {
@ -196,7 +202,12 @@
dictionary.defineTag('returns', {
mustHaveValue: true,
canHaveType: true
canHaveType: true,
onTagged: function(doclet, tag) {
doclet.returns = tag.value;
return false;
}
})
.synonym('return');

View File

@ -29,15 +29,26 @@
return !doclet.undocumented;
});
// add template helpers
docSet.doclets.forEach(function(doclet) {
doclet['params?'] = doclet.params && doclet.params.length > 0;
});
docSet.sortByLongname();
var partials = {
param: readFile(BASEDIR + 'templates/default/tmpl/param.mustache'),
returns: readFile(BASEDIR + 'templates/default/tmpl/returns.mustache')
};
// apply template
out = Mustache.to_html(
templates.index,
{
docs: docSet.doclets,
summarize: summarize
}
},
partials
);
if (opts.destination === 'console') {

View File

@ -25,6 +25,11 @@
font-size: 110%;
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Verdana, Tahoma, sans-serif;
}
ol.params {
list-style-type:none;
}
</style>
</head>
@ -39,6 +44,21 @@
</dt>
{{#description}}<dd>
{{#summarize}}{{{description}}}{{/summarize}}
<div class="details">
{{#params?}}
<p>Parameters:</p>
<ol class="params">
{{#params}} {{>param}} {{/params}}
</ol>
{{/params?}}
{{#returns}}
<p>Returns:</p>
<ol class="params">
{{>returns}}
</ol>
{{/returns}}
</div>
</dd>{{/description}}
{{/docs}}
</dl>

View File

@ -0,0 +1,6 @@
<li>
{{#type}}
{ {{#names}}<span class="param-type">{{.}}</span> {{/names}} }
{{/type}}
<span class="param-name">{{name}}</span>
</li>

View File

@ -0,0 +1,6 @@
<li>
{{#type}}
{ {{#names}}<span class="returns-type">{{.}}</span> {{/names}} }
{{/type}}
<span class="returns-desc">{{description}}</span>
</li>