Tweaks to template.

This commit is contained in:
Michael Mathews 2011-01-07 17:19:06 +00:00
parent 70b4260697
commit af18eca3b2
3 changed files with 26 additions and 22 deletions

View File

@ -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);

View File

@ -5,22 +5,26 @@
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() {
return function(text, render) {
var linkTo,
text = render(text);
if ( !docSet.hasDoc(text) ) { return text; }
linkTo = text.replace(/#/g, '%23');
return '<a href="#' + linkTo + '">' + text + '</a>';
var helpers = {
linkify: function() {
return function(text, render) {
var linkTo,
text = render(text);
if ( !docSet.hasDoc(text) ) { return text; }
linkTo = text.replace(/#/g, '%23');
return '<a href="#' + linkTo + '">' + text + '</a>';
}
}
}
};
function summarize (doclet) {
function summarize(doclet) {
var desc = doclet.description || '';
desc = desc.replace(/<\/?p>/gi, ''); // full text may be HTML, remove P wrapper
desc = trim(desc);
@ -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
);

View File

@ -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>