diff --git a/templates/twinity/allfiles.tmpl b/templates/twinity/allfiles.tmpl index 7568a0b..168f758 100644 --- a/templates/twinity/allfiles.tmpl +++ b/templates/twinity/allfiles.tmpl @@ -2,55 +2,44 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - - {! Link.base = ""; /* all generated links will be relative to this */ !} + JsDoc Reference - File Index - - - {+include("static/header.html")+} - + {header}
- {+global.conf.classesIndex+} + {index}
-

File Index

- - + {.repeated section files}
-

{+new Link().toSrc(item.alias).withText(item.name)+}

- {+resolveLinks(item.desc)+} +

{link}

+ {.section description}{@}{.end}
- -
Author:
-
{+item.author+}
-
- -
Version:
-
{+item.version+}
-
- {! var locations = item.comment.getTag('location').map(function($){return $.toString().replace(/(^\$ ?| ?\$$)/g, '').replace(/^HeadURL: https:/g, 'http:');}) !} - -
Location:
- -
{+location+}
-
-
+ {.section author} +
Author:
+
{@}
+ {.end} + {.section version} +
Version:
+
{@}
+ {.end} + {.section uris} +
Location:
+ {.repeated section @} +
{@}
+ {.end} + {.end}

-
- -
-
- ©{+copyright+}
- Documentation generated by JsDoc Toolkit {+VERSION+} on {+new Date()+} + {.end}
+ {footer} \ No newline at end of file diff --git a/templates/twinity/dig.js b/templates/twinity/dig.js index c7e4943..eb22ccb 100644 --- a/templates/twinity/dig.js +++ b/templates/twinity/dig.js @@ -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")); -} \ No newline at end of file diff --git a/templates/twinity/index.tmpl b/templates/twinity/index.tmpl index a96c619..7539a28 100644 --- a/templates/twinity/index.tmpl +++ b/templates/twinity/index.tmpl @@ -1,39 +1,29 @@ - - - - JsDoc Reference - Index - - - - - - - {+include("static/header.html")+} - -
- {+global.conf.classesIndex+} -
- -
-

Class Index

- - -
-

{+(new Link().toSymbol(thisClass.alias))+}

- {+resolveLinks(summarize(thisClass.classDesc))+} -
-
-
- -
-
- ©{+copyright+}
- Documentation generated by JsDoc Toolkit {+VERSION+} on {+new Date()+} -
- + + + JsDoc Reference - Index + + + + + {header} +
+ {index} +
+
+

Class Index

+ {.repeated section classes} +
+

{link}

+ {description} +
+
+ {.end} +
+ {footer} + \ No newline at end of file diff --git a/templates/twinity/publish.js b/templates/twinity/publish.js index d766a79..cbc28e8 100644 --- a/templates/twinity/publish.js +++ b/templates/twinity/publish.js @@ -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 "<" + srcFilePath + ">"; - } - } - // create the folders and subfolders to hold the output var symbols = Link.symbolsDir = destination.join("symbols"); var dirs = Link.srcDir = symbols.join("src"); @@ -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); } } @@ -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) ? "" + link + "" : 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; + }) + })); } diff --git a/templates/twinity/utils.js b/templates/twinity/utils.js index b22db77..37a3646 100644 --- a/templates/twinity/utils.js +++ b/templates/twinity/utils.js @@ -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 "";