Skip to content

Commit

Permalink
porting index pages to the json-template as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Feb 1, 2010
1 parent 909c52a commit b3590ae
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 198 deletions.
57 changes: 23 additions & 34 deletions templates/twinity/allfiles.tmpl
Expand Up @@ -2,55 +2,44 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset={+encoding+}" />
{! Link.base = ""; /* all generated links will be relative to this */ !}
<meta http-equiv="content-type" content="text/html; charset={encoding}" />
<title>JsDoc Reference - File Index</title>
<meta name="generator" content="JsDoc Toolkit" />

<style type="text/css">
{+include("static/default.css")+}
{style}
</style>
</head>

<body>
{+include("static/header.html")+}

{header}
<div id="index">
{+global.conf.classesIndex+}
{index}
</div>

<div id="content">
<h1 class="classTitle">File Index</h1>

<for each="item" in="data">
{.repeated section files}
<div>
<h2>{+new Link().toSrc(item.alias).withText(item.name)+}</h2>
<if test="item.desc">{+resolveLinks(item.desc)+}</if>
<h2>{link}</h2>
{.section description}{@}{.end}
<dl>
<if test="item.author">
<dt class="heading">Author:</dt>
<dd>{+item.author+}</dd>
</if>
<if test="item.version">
<dt class="heading">Version:</dt>
<dd>{+item.version+}</dd>
</if>
{! var locations = item.comment.getTag('location').map(function($){return $.toString().replace(/(^\$ ?| ?\$$)/g, '').replace(/^HeadURL: https:/g, 'http:');}) !}
<if test="locations.length">
<dt class="heading">Location:</dt>
<for each="location" in="locations">
<dd><a href="{+location+}">{+location+}</a></dd>
</for>
</if>
{.section author}
<dt class="heading">Author:</dt>
<dd>{@}</dd>
{.end}
{.section version}
<dt class="heading">Version:</dt>
<dd>{@}</dd>
{.end}
{.section uris}
<dt class="heading">Location:</dt>
{.repeated section @}
<dd><a href="{@}">{@}</a></dd>
{.end}
{.end}
</dl>
</div>
<hr />
</for>

</div>
<div class="fineprint" style="clear:both">
<if test="copyright">&copy;{+copyright+}<br /></if>
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> {+VERSION+} on {+new Date()+}
{.end}
</div>
{footer}
</body>
</html>
74 changes: 0 additions & 74 deletions templates/twinity/dig.js
Expand Up @@ -197,77 +197,3 @@ var Class = exports.Class = function Class(symbol, data) {
return events(symbol, methods(symbol, properties(symbol, constructor(symbol, extend(symbol, type(symbol))))));
};

exports.toJSON = function toJSON(symbol) {
var data = {};
var alias = data.alias = symbol.alias;
var isBuiltin = data.isBuiltin = symbol.isBuiltin();
var isClass = data.isClass = !(data.isNamespace = symbol.isNamespace);
var isFunction = data.isFunction = (!isClass && symbol.is("FUNCTION"));
var type = "";
if (isBuiltin) type += "Built-In ";
if (isClass) type += "Class "
else {
if (isFunction) type += "Function ";
type += "Namespace ";
}
data.type = type;
var extend = symbol.augments;
if (extend && extend.length) {
extend = data.extend = extend.map(function($) {
return Link.toSymbol($);
});
data.extendString = extend.join(", ");
}
data.description = UTILS.resolveLinks(symbol.classDesc);
if (!isBuiltin) data.defined = Link().toSrc(symbol.srcFile);
var isPrivate = data.isPrivate = symbol.isPrivate;
var isInner = data.isInner = symbol.isInner;
var isHighlighted = data.isHighlighted = !!symbol.comment.getTag("hilited").length;
if (!symbol.isBuiltin() && (symbol.isNamespace || symbol.is("CONSTRUCTOR"))) {
var constructor = data.classConstructor = {};
constructor.link = Link().toSymbol(alias).inner("constructor");
if (isClass) {
var params = constructor.params = symbol.params;
constructor.paramsString = UTILS.makeSignature(params);
constructor.isPrivate = isPrivate;
constructor.isInner = isInner;
constructor.type = type;
constructor.isHighlighted = isHighlighted;
constructor.decsription = UTILS.resolveLinks(UTILS.summarize(symbol.desc));
}
}
var properties = symbol.properties, l = properties.length;
var ownProperties = [], propertyContributers = [], contributers = {};
while (l--) {
var property = properties[l];
var memberOf = property.memberOf;
if (memberOf == alias && !property.isNamespace) { // own
ownProperties.unshift({
"name": property.name,
"isPrivate": property.isPrivate,
"isInner": property.isInner,
"isStatic": property.isStatic,
"isConstant": property.isConstant,
"memberOf": (property.isStatic && memberOf != GLOBAL)
? property.memberOf : null,
"link": Link().toSymbol(alias).withText(property.name),
"description": UTILS.resolveLinks(UTILS.summarize(property.desc))
});
} else if (memberOf != alias) { // inhereted
var contributer = contributers[memberOf];
if (!contributer) {
propertyContributers.push(contributer = contributers[memberOf] = {});
}
var contributerProperties = contributer.properties;
if (!contributerProperties) {
var contributerProperties = contributer.properties = [];
contributer.link = Link().toSymbol(memberOf);
}
contributerProperties.push(Link().toSymbol(property.alias).withText(property.name));
}
}
if (ownProperties.length) data.ownProperties = ownProperties;
if (propertyContributers.length) data.propertyContributers = propertyContributers;
return data;
//data.methods.filter(function($){return $.memberOf == data.alias && !$.isNamespace}).sort(makeSortby("name"));
}
60 changes: 25 additions & 35 deletions templates/twinity/index.tmpl
@@ -1,39 +1,29 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset={+encoding+}" />

<title>JsDoc Reference - Index</title>
<meta name="generator" content="JsDoc Toolkit" />

<style type="text/css">
{+include("static/default.css")+}
</style>
</head>

<body>
{+include("static/header.html")+}

<div id="index">
{+global.conf.classesIndex+}
</div>

<div id="content">
<h1 class="classTitle">Class Index</h1>

<for each="thisClass" in="data">
<div>
<h2>{+(new Link().toSymbol(thisClass.alias))+}</h2>
{+resolveLinks(summarize(thisClass.classDesc))+}
</div>
<hr />
</for>

</div>
<div class="fineprint" style="clear:both">
<if test="copyright">&copy;{+copyright+}<br /></if>
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> {+VERSION+} on {+new Date()+}
</div>
</body>
<head>
<meta http-equiv="content-type" content="text/html; charset={encoding}" />
<title>JsDoc Reference - Index</title>
<meta name="generator" content="JsDoc Toolkit" />
<style type="text/css">
{style}
</style>
</head>
<body>
{header}
<div id="index">
{index}
</div>
<div id="content">
<h1 class="classTitle">Class Index</h1>
{.repeated section classes}
<div>
<h2>{link}</h2>
{description}
</div>
<hr />
{.end}
</div>
{footer}
</body>
</html>
105 changes: 67 additions & 38 deletions templates/twinity/publish.js
Expand Up @@ -26,13 +26,6 @@ exports.publish = function publish(symbolSet, options) {

var destination = options.destination;

// is source output is suppressed, just display the links to the source file
if (options.includeSource && Link !== undefined && Link.prototype._makeSrcLink) {
Link.prototype._makeSrcLink = function(srcFilePath) {
return "&lt;" + srcFilePath + "&gt;";
}
}

// create the folders and subfolders to hold the output
var symbols = Link.symbolsDir = destination.join("symbols");
var dirs = Link.srcDir = symbols.join("src");
Expand All @@ -52,12 +45,24 @@ exports.publish = function publish(symbolSet, options) {

// get an array version of the symbolset, useful for filtering
var symbols = symbolSet.toArray();

var sources = destination.join("symbols", "src");
// create the hilited source code files
var files = options.files;
if (options.includeSource) {
for (var i = 0, l = files.length; i < l; i++) {
UTILS.makeSrcFile(files[i], destination.join("symbols", "src"), null, options.encoding);
var content, src;
var path = files[i];
var name = path.toString()
.replace(/\.\.?[\\\/]/g, "")
.replace(/[\\\/]/g, "_")
.replace(/\:/g, "_");
plugins.notify("onPublishSrc", (src = {
path: path,
name: name,
charset: encoding,
highlighted: null
}));
if (content = src.highlighted) sources.join(name + extension).write(content);
}
}

Expand Down Expand Up @@ -105,55 +110,79 @@ exports.publish = function publish(symbolSet, options) {

Link.currentSymbol = symbol;
var name = options.uniqueNames ? Link.filemap[symbol.alias] : symbol.alias;
var json = DIG.Class(symbol);
print("\n\n" + JSON.stringify(json) + "\n\n");
destination.join("symbols", name + extension).write(classTemplate.expand({
"encoding": encoding,
"header": header,
"footer": footer,
"style": style,
"index": index,
"symbol": json
encoding: encoding,
header: header,
footer: footer,
style: style,
index: index,
symbol: DIG.Class(symbol)
}));
}

throw "So far"

// regenerate the index with different relative links, used in the index pages
Link.base = "";
// TODO: don't access this damn Link
global.conf.classesIndex = classesTemplate.process(classes);

index = classesTemplate.expand({ // kept in memory
classesLink: classesLink,
filesLink: filesLink,
items: classes.map(function(item) {
var alias = item.alias, link = Link().toClass(alias);
return (alias == GLOBAL) ? "<i>" + link + "</i>" : link;
})
});
// create the class index page
var classesindexTemplate = new JsPlate(template.join("index.tmpl").read().toString(), "index.tmpl");
var classesIndex = classesindexTemplate.process(classes);
destination.join("index" + conf.extension).write(classesIndex);
classesindexTemplate = classesIndex = classes = null;
var classesIndex = Template(template.join("index.tmpl").read().toString());
destination.join("index" + extension).write(classesIndex.expand({
encoding: encoding,
style: style,
header: header,
index: index,
footer: footer,
classes: classes.map(function(symbol) {
return {
link: Link().toSymbol(symbol.alias),
description: UTILS.resolveLinks(UTILS.summarize(symbol.classDesc))
}
})
}));

// create the file index page
var fileindexTemplate = new Template(template.join("allfiles.tmpl").read().toString());

var filesIndex = Template(template.join("allfiles.tmpl").read().toString());
var documentedFiles = symbols.filter(isaFile); // files that have file-level docs
var allFiles = []; // not all files have file-level docs, but we need to list every one

for (var i = 0; i < files.length; i++) {
allFiles.push(new Symbol(files[i], [], "FILE", new DocComment("/** */")));
}

for (var i = 0; i < documentedFiles.length; i++) {
var offset = files.indexOf(documentedFiles[i].alias);
allFiles[offset] = documentedFiles[i];
}

allFiles = allFiles.sort(makeSortby("name"));
allFiles = allFiles.sort(UTILS.makeSortby("name"));

// output the file index page
var filesIndex = fileindexTemplate.expand({
title: new Link().toFile("files.html").withText("File Index"),
files: allFiles
});
destination.join("files" + conf.extension).write(filesIndex);
fileindexTemplate = filesIndex = files = null;
destination.join("files" + extension).write(filesIndex.expand({
encoding: encoding,
style: style,
header: header,
index: index,
footer: footer,
// title: Link().toFile("files.html").withText("File Index"),
files: allFiles.map(function(symbol) {
var file = {
link: Link().toSrc(symbol.alias).withText(symbol.name)
};
if (symbol.desc) file.description = symbol.desc;
if (symbol.author) file.author = symbol.author;
if (symbol.version) file.version = symbol.version;
var uris = symbol.comment.getTag('location');
if (uris && uris.length) file.uris = uris.map(function(uri) {
return uri.toString()
.replace(/(^\$ ?| ?\$$)/g, '')
.replace(/^HeadURL: https:/g, 'http:');
});
return file;
})
}));
}


17 changes: 0 additions & 17 deletions templates/twinity/utils.js
Expand Up @@ -17,23 +17,6 @@ exports.makeSortby = function makeSortby(attribute) {
}
}
};
/** Turn a raw source file into a code-hilited page in the docs. */
exports.makeSrcFile = function makeSrcFile(path, destination, name, encoding) {
var content, src;
if (!name) {
name = path.toString()
.replace(/\.\.?[\\\/]/g, "")
.replace(/[\\\/]/g, "_")
.replace(/\:/g, "_");
}
plugins.notify("onPublishSrc", (src = {
path: path,
name: name,
charset: encoding,
highlighted: null
}));
if (content = src.highlighted) destination.join(name).write(content);
};
/** Build output for displaying function parameters. */
exports.makeSignature = function makeSignature(params) {
if (!params) return "";
Expand Down

0 comments on commit b3590ae

Please sign in to comment.