mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
(function() {
|
|
|
|
include('templates/lib/janl/mustache.js');
|
|
|
|
publish = function(docSet, opts) {
|
|
var out = '',
|
|
templates = {
|
|
index: readFile(BASEDIR + 'templates/default/tmpl/index.html')
|
|
};
|
|
|
|
function summarize () {
|
|
return function(text, render) {
|
|
var summary = trim(text);
|
|
|
|
summary = render(text);
|
|
summary = summary.replace(/<\/?p>/gi, ''); // text may be HTML
|
|
|
|
/^(.*?(\.$|\.\s|\n|\r|$|<br>))/.test(summary);
|
|
return RegExp.$1? RegExp.$1 : summary;
|
|
}
|
|
};
|
|
|
|
function trim(text) {
|
|
return text.replace(/^\s+|\s+$/g, '');
|
|
}
|
|
|
|
// remove undocumented symbols from the output
|
|
docSet.doclets = docSet.doclets.filter(function(doclet) {
|
|
return !doclet.undocumented;
|
|
});
|
|
|
|
// apply template
|
|
out = Mustache.to_html(
|
|
templates.index,
|
|
{
|
|
docs: docSet.doclets,
|
|
summarize: summarize
|
|
}
|
|
);
|
|
|
|
if (opts.destination === 'console') {
|
|
print(out);
|
|
}
|
|
else {
|
|
print('The only -d destination option currently supported is "console"!');
|
|
}
|
|
}
|
|
|
|
})(); |