summaryrefslogtreecommitdiffstats
path: root/o3d/documentation/jsdoc-toolkit-templates/publish.js
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-14 20:15:54 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-14 20:15:54 +0000
commitac75f7f4418a8ca304dc030695465fab8ef02f6d (patch)
treed9d2921c0936b61dffdf2610abaa0142c9a5ebf1 /o3d/documentation/jsdoc-toolkit-templates/publish.js
parent2e066b3eed13cc1dc502a1f9cc7c1ac3891b0bdc (diff)
downloadchromium_src-ac75f7f4418a8ca304dc030695465fab8ef02f6d.zip
chromium_src-ac75f7f4418a8ca304dc030695465fab8ef02f6d.tar.gz
chromium_src-ac75f7f4418a8ca304dc030695465fab8ef02f6d.tar.bz2
Lots more docs changes.
*) added stylesheet.css, tabs.css, tab_?.gif back in *) refactored so classtree.html splits names that are too long. *) removed constructor docs and source link from o3d docs (vs o3djs docs) *) fixed paths in header.html. They used to be statically included but now that they are used by both o3d and o3djs they needed to have certain paths fixed dynamically. *) Pull in new nixysa. Review URL: http://codereview.chromium.org/155526 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20645 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/documentation/jsdoc-toolkit-templates/publish.js')
-rw-r--r--o3d/documentation/jsdoc-toolkit-templates/publish.js100
1 files changed, 91 insertions, 9 deletions
diff --git a/o3d/documentation/jsdoc-toolkit-templates/publish.js b/o3d/documentation/jsdoc-toolkit-templates/publish.js
index 1040137..41bdf93 100644
--- a/o3d/documentation/jsdoc-toolkit-templates/publish.js
+++ b/o3d/documentation/jsdoc-toolkit-templates/publish.js
@@ -52,7 +52,10 @@ var g_validJSDOCTypes = {
var g_unknownTypes = { };
var g_numErrors = 0;
var g_o3djsMode = false;
+var g_outputMode;
var g_baseURL;
+var g_topURL;
+var g_templates = [];
/**
* Called automatically by JsDoc Toolkit.
@@ -65,12 +68,14 @@ function publish(symbolSet) {
templatesDir: JSDOC.opt.t,
symbolsDir: '',
prefix: JSDOC.opt.D.prefix,
- o3djs: JSDOC.opt.D.o3djs};
+ mode: JSDOC.opt.D.mode};
publish.conf.srcDir = publish.conf.outDir + 'src/';
publish.conf.htmlDir = JSDOC.opt.D.htmlOutDir;
g_baseURL = JSDOC.opt.D.baseURL;
+ g_topURL = JSDOC.opt.D.topURL;
+ g_outputMode = JSDOC.opt.D.mode;
- if (publish.conf.o3djs) {
+ if (publish.conf.mode == 'o3djs') {
g_o3djsMode = true;
}
@@ -112,7 +117,7 @@ function publish(symbolSet) {
System.exit(1);
}
- // some ustility filters
+ // some utility filters
function hasNoParent($) {return ($.memberOf == '')}
function isaFile($) {return ($.is('FILE'))}
function isaClass($) {return ($.is('CONSTRUCTOR') || $.isNamespace)}
@@ -131,6 +136,7 @@ function publish(symbolSet) {
// get a list of all the classes in the symbolset
var classes = symbols.filter(isaClass).sort(makeSortby('alias'));
+ var filteredClasses = [];
// create each of the class pages
for (var i = 0, l = classes.length; i < l; i++) {
@@ -146,6 +152,9 @@ function publish(symbolSet) {
}
print('Generating docs for: ' + symbol.alias);
+
+ filteredClasses.push(symbol);
+
// Comment these lines in to see what data is available to the templates.
//print('----------------------------------------------------------------');
//dumpObject(symbol, 5);
@@ -178,7 +187,7 @@ function publish(symbolSet) {
output);
}
- var classTree = classTreeTemplate.process(classes);
+ var classTree = classTreeTemplate.process(filteredClasses);
IO.saveFile(publish.conf.outDir, 'classtree.html', classTree);
IO.saveFile(publish.conf.htmlDir, 'classtree.html', classTree);
@@ -186,11 +195,11 @@ function publish(symbolSet) {
IO.saveFile(publish.conf.outDir, 'filelist.html', fileList);
IO.saveFile(publish.conf.htmlDir, 'filelist.html', fileList);
- var annotated = annotatedTemplate.process(classes);
+ var annotated = annotatedTemplate.process(filteredClasses);
IO.saveFile(publish.conf.outDir, 'annotated' + publish.conf.ext, annotated);
IO.saveFile(publish.conf.htmlDir, 'annotated.html', annotated);
- var namespaces = namespacesTemplate.process(classes);
+ var namespaces = namespacesTemplate.process(filteredClasses);
IO.saveFile(publish.conf.outDir, 'namespaces' + publish.conf.ext, namespaces);
IO.saveFile(publish.conf.htmlDir, 'namespaces.html', namespaces);
@@ -234,8 +243,18 @@ function makeSortby(attribute) {
* @return {string} contents of file.
*/
function include(path) {
- var path = publish.conf.templatesDir + path;
- return IO.readFile(path);
+ var template = g_templates[path];
+ if (!template) {
+ try {
+ template = new JSDOC.JsPlate(JSDOC.opt.t + path);
+ } catch (e) {
+ generateError('Could not include: ' + path + '\n' + e);
+ template = '';
+ }
+ g_templates[path] = template;
+ }
+ var output = template.process({});
+ return output;
}
/**
@@ -786,8 +805,71 @@ function getQualifiedName(method) {
}
/**
- * Get the base URL for links.
+ * Gets the base URL for links.
*/
function getBaseURL() {
return g_baseURL;
}
+
+/**
+ * Gets the top URL for links.
+ */
+function getTopURL() {
+ return g_topURL;
+}
+
+/**
+ * Returns the output mode.
+ * @return {string} The output mode.
+ */
+function getOutputMode() {
+ return g_outputMode;
+}
+
+/**
+ * Returns true if we should write constructor docs.
+ * @param {!Symbol} symbol The symbol that might have a constructor.
+ * @return {boolean} true if we should write a constructor.
+ */
+function shouldWriteConstructor(symbol) {
+ return g_outputMode != 'o3d' &&
+ !symbol.isPrivate &&
+ !symbol.isBuiltin() &&
+ !symbol.isNamespace &&
+ symbol.is('CONSTRUCTOR');
+}
+
+/**
+ * Splits a camelCase word into an array of word parts.
+ * @param {string} word camelCase word.
+ * @return {!Array.<string>} The word split into word parts.
+ */
+function splitCamelCase(word) {
+ var spacesAdded = word.replace(/([A-Z])/g, ' $1');
+ return spacesAdded.split(' ');
+}
+
+/**
+ * Breaks a word at max_length with hyphens. Assumes word is camelCase
+ * @param {string} word Word to break.
+ * @param {number} maxLength word will continue to be split until no part is
+ * this longer than this if possible.
+ * @param {string} string to use to join split parts.
+ * @return {string} The word split then joined with joinString.
+ */
+function hyphenateWord(word, maxLength, joinString) {
+ var words = splitCamelCase(word);
+ var hyphenated = '';
+ var newWord = '';
+ for (var ii = 0; ii < words.length; ++ii) {
+ var part = words[ii];
+ var temp = newWord + part;
+ if (temp.length > maxLength) {
+ hyphenated += newWord + joinString;
+ newWord = '';
+ }
+ newWord += part;
+ }
+ hyphenated += newWord;
+ return hyphenated;
+}