mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Tweaks to template.
This commit is contained in:
parent
70b4260697
commit
af18eca3b2
2
main.js
2
main.js
@ -28,7 +28,7 @@ function require(id) { // like commonjs
|
||||
try {
|
||||
var f = new Function('require', 'exports', 'module', fileContent),
|
||||
exports = require.cache[path] || {},
|
||||
module = { id: id, uri: path };
|
||||
module = { id: id, uri: path, exports: exports };
|
||||
|
||||
require.cache[id] = exports;
|
||||
f.call({}, require, exports, module);
|
||||
|
||||
@ -5,10 +5,13 @@
|
||||
publish = function(docSet, opts) {
|
||||
var out = '',
|
||||
templates = {
|
||||
index: readFile(BASEDIR + 'templates/default/tmpl/index.html')
|
||||
index: readFile(BASEDIR + 'templates/default/tmpl/index.html'),
|
||||
param: readFile(BASEDIR + 'templates/default/tmpl/param.mustache'),
|
||||
returns: readFile(BASEDIR + 'templates/default/tmpl/returns.mustache')
|
||||
};
|
||||
|
||||
function linkify() {
|
||||
var helpers = {
|
||||
linkify: function() {
|
||||
return function(text, render) {
|
||||
var linkTo,
|
||||
text = render(text);
|
||||
@ -19,6 +22,7 @@
|
||||
return '<a href="#' + linkTo + '">' + text + '</a>';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function summarize(doclet) {
|
||||
var desc = doclet.description || '';
|
||||
@ -44,8 +48,8 @@
|
||||
|
||||
// add template helpers
|
||||
docSet.doclets.forEach(function(doclet) {
|
||||
doclet['params?'] = doclet.params && doclet.params.length > 0;
|
||||
doclet['borrowed?'] = doclet.borrowed && doclet.borrowed.length > 0;
|
||||
doclet.hasParams = doclet.params && doclet.params.length > 0;
|
||||
doclet.hasBorrowed = doclet.borrowed && doclet.borrowed.length > 0;
|
||||
|
||||
summarize(doclet);
|
||||
});
|
||||
@ -53,8 +57,8 @@
|
||||
docSet.sortByLongname();
|
||||
|
||||
var partials = {
|
||||
param: readFile(BASEDIR + 'templates/default/tmpl/param.mustache'),
|
||||
returns: readFile(BASEDIR + 'templates/default/tmpl/returns.mustache')
|
||||
param: templates.param,
|
||||
returns: templates.returns
|
||||
};
|
||||
|
||||
// apply template
|
||||
@ -62,7 +66,7 @@
|
||||
templates.index,
|
||||
{
|
||||
docs: docSet.doclets,
|
||||
linkify: linkify
|
||||
linkify: helpers.linkify
|
||||
},
|
||||
partials
|
||||
);
|
||||
|
||||
@ -63,19 +63,19 @@
|
||||
</div>
|
||||
{{/description}}
|
||||
|
||||
{{#borrowed?}}
|
||||
{{#hasBorrowed}}
|
||||
<h3>Mixes In:</h3>
|
||||
<ol class="borrows detail-list">
|
||||
{{#borrowed}} <li>{{#linkify}}{{from}}{{/linkify}}</li> {{/borrowed}}
|
||||
</ol>
|
||||
{{/borrowed?}}
|
||||
{{/hasBorrowed}}
|
||||
|
||||
{{#params?}}
|
||||
{{#hasParams}}
|
||||
<h3>Parameters:</h3>
|
||||
<ol class="params detail-list">
|
||||
{{#params}} {{>param}} {{/params}}
|
||||
</ol>
|
||||
{{/params?}}
|
||||
{{/hasParams}}
|
||||
|
||||
{{#returns}}
|
||||
<h3>Returns:</h3>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user