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 {
|
try {
|
||||||
var f = new Function('require', 'exports', 'module', fileContent),
|
var f = new Function('require', 'exports', 'module', fileContent),
|
||||||
exports = require.cache[path] || {},
|
exports = require.cache[path] || {},
|
||||||
module = { id: id, uri: path };
|
module = { id: id, uri: path, exports: exports };
|
||||||
|
|
||||||
require.cache[id] = exports;
|
require.cache[id] = exports;
|
||||||
f.call({}, require, exports, module);
|
f.call({}, require, exports, module);
|
||||||
|
|||||||
@ -5,22 +5,26 @@
|
|||||||
publish = function(docSet, opts) {
|
publish = function(docSet, opts) {
|
||||||
var out = '',
|
var out = '',
|
||||||
templates = {
|
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 = {
|
||||||
return function(text, render) {
|
linkify: function() {
|
||||||
var linkTo,
|
return function(text, render) {
|
||||||
text = render(text);
|
var linkTo,
|
||||||
|
text = render(text);
|
||||||
if ( !docSet.hasDoc(text) ) { return text; }
|
|
||||||
|
if ( !docSet.hasDoc(text) ) { return text; }
|
||||||
linkTo = text.replace(/#/g, '%23');
|
|
||||||
return '<a href="#' + linkTo + '">' + text + '</a>';
|
linkTo = text.replace(/#/g, '%23');
|
||||||
|
return '<a href="#' + linkTo + '">' + text + '</a>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
function summarize (doclet) {
|
function summarize(doclet) {
|
||||||
var desc = doclet.description || '';
|
var desc = doclet.description || '';
|
||||||
desc = desc.replace(/<\/?p>/gi, ''); // full text may be HTML, remove P wrapper
|
desc = desc.replace(/<\/?p>/gi, ''); // full text may be HTML, remove P wrapper
|
||||||
desc = trim(desc);
|
desc = trim(desc);
|
||||||
@ -44,8 +48,8 @@
|
|||||||
|
|
||||||
// add template helpers
|
// add template helpers
|
||||||
docSet.doclets.forEach(function(doclet) {
|
docSet.doclets.forEach(function(doclet) {
|
||||||
doclet['params?'] = doclet.params && doclet.params.length > 0;
|
doclet.hasParams = doclet.params && doclet.params.length > 0;
|
||||||
doclet['borrowed?'] = doclet.borrowed && doclet.borrowed.length > 0;
|
doclet.hasBorrowed = doclet.borrowed && doclet.borrowed.length > 0;
|
||||||
|
|
||||||
summarize(doclet);
|
summarize(doclet);
|
||||||
});
|
});
|
||||||
@ -53,8 +57,8 @@
|
|||||||
docSet.sortByLongname();
|
docSet.sortByLongname();
|
||||||
|
|
||||||
var partials = {
|
var partials = {
|
||||||
param: readFile(BASEDIR + 'templates/default/tmpl/param.mustache'),
|
param: templates.param,
|
||||||
returns: readFile(BASEDIR + 'templates/default/tmpl/returns.mustache')
|
returns: templates.returns
|
||||||
};
|
};
|
||||||
|
|
||||||
// apply template
|
// apply template
|
||||||
@ -62,7 +66,7 @@
|
|||||||
templates.index,
|
templates.index,
|
||||||
{
|
{
|
||||||
docs: docSet.doclets,
|
docs: docSet.doclets,
|
||||||
linkify: linkify
|
linkify: helpers.linkify
|
||||||
},
|
},
|
||||||
partials
|
partials
|
||||||
);
|
);
|
||||||
|
|||||||
@ -63,19 +63,19 @@
|
|||||||
</div>
|
</div>
|
||||||
{{/description}}
|
{{/description}}
|
||||||
|
|
||||||
{{#borrowed?}}
|
{{#hasBorrowed}}
|
||||||
<h3>Mixes In:</h3>
|
<h3>Mixes In:</h3>
|
||||||
<ol class="borrows detail-list">
|
<ol class="borrows detail-list">
|
||||||
{{#borrowed}} <li>{{#linkify}}{{from}}{{/linkify}}</li> {{/borrowed}}
|
{{#borrowed}} <li>{{#linkify}}{{from}}{{/linkify}}</li> {{/borrowed}}
|
||||||
</ol>
|
</ol>
|
||||||
{{/borrowed?}}
|
{{/hasBorrowed}}
|
||||||
|
|
||||||
{{#params?}}
|
{{#hasParams}}
|
||||||
<h3>Parameters:</h3>
|
<h3>Parameters:</h3>
|
||||||
<ol class="params detail-list">
|
<ol class="params detail-list">
|
||||||
{{#params}} {{>param}} {{/params}}
|
{{#params}} {{>param}} {{/params}}
|
||||||
</ol>
|
</ol>
|
||||||
{{/params?}}
|
{{/hasParams}}
|
||||||
|
|
||||||
{{#returns}}
|
{{#returns}}
|
||||||
<h3>Returns:</h3>
|
<h3>Returns:</h3>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user