author | Lennard de Rijk <ljvderijk@gmail.com> |
Sun, 25 Oct 2009 18:45:58 -0700 | |
changeset 3052 | 6907a33ca0a2 |
parent 3041 | c8f47f0b6697 |
permissions | -rw-r--r-- |
3041
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
1 |
/** Called automatically by JsDoc Toolkit. */ |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
2 |
function publish(symbolSet) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
3 |
publish.conf = { // trailing slash expected for dirs |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
4 |
ext: ".html", |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
5 |
outDir: JSDOC.opt.d || SYS.pwd+"../out/jsdoc/", |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
6 |
templatesDir: JSDOC.opt.t || SYS.pwd+"../templates/jsdoc/", |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
7 |
symbolsDir: "symbols/", |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
8 |
srcDir: "symbols/src/" |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
9 |
}; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
10 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
11 |
// is source output is suppressed, just display the links to the source file |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
12 |
if (JSDOC.opt.s && defined(Link) && Link.prototype._makeSrcLink) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
13 |
Link.prototype._makeSrcLink = function(srcFilePath) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
14 |
return "<"+srcFilePath+">"; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
15 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
16 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
17 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
18 |
// create the folders and subfolders to hold the output |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
19 |
IO.mkPath((publish.conf.outDir+"symbols/src").split("/")); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
20 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
21 |
// used to allow Link to check the details of things being linked to |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
22 |
Link.symbolSet = symbolSet; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
23 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
24 |
// create the required templates |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
25 |
try { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
26 |
var classTemplate = new JSDOC.JsPlate(publish.conf.templatesDir+"class.tmpl"); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
27 |
var classesTemplate = new JSDOC.JsPlate(publish.conf.templatesDir+"allclasses.tmpl"); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
28 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
29 |
catch(e) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
30 |
print("Couldn't create the required templates: "+e); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
31 |
quit(); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
32 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
33 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
34 |
// some ustility filters |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
35 |
function hasNoParent($) {return ($.memberOf == "")} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
36 |
function isaFile($) {return ($.is("FILE"))} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
37 |
function isaClass($) {return ($.is("CONSTRUCTOR") || $.isNamespace)} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
38 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
39 |
// get an array version of the symbolset, useful for filtering |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
40 |
var symbols = symbolSet.toArray(); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
41 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
42 |
// create the hilited source code files |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
43 |
var files = JSDOC.opt.srcFiles; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
44 |
for (var i = 0, l = files.length; i < l; i++) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
45 |
var file = files[i]; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
46 |
var srcDir = publish.conf.outDir + "symbols/src/"; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
47 |
makeSrcFile(file, srcDir); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
48 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
49 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
50 |
// get a list of all the classes in the symbolset |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
51 |
var classes = symbols.filter(isaClass).sort(makeSortby("alias")); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
52 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
53 |
// create a filemap in which outfiles must be to be named uniquely, ignoring case |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
54 |
if (JSDOC.opt.u) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
55 |
var filemapCounts = {}; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
56 |
Link.filemap = {}; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
57 |
for (var i = 0, l = classes.length; i < l; i++) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
58 |
var lcAlias = classes[i].alias.toLowerCase(); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
59 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
60 |
if (!filemapCounts[lcAlias]) filemapCounts[lcAlias] = 1; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
61 |
else filemapCounts[lcAlias]++; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
62 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
63 |
Link.filemap[classes[i].alias] = |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
64 |
(filemapCounts[lcAlias] > 1)? |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
65 |
lcAlias+"_"+filemapCounts[lcAlias] : lcAlias; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
66 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
67 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
68 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
69 |
// create a class index, displayed in the left-hand column of every class page |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
70 |
Link.base = "../"; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
71 |
publish.classesIndex = classesTemplate.process(classes); // kept in memory |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
72 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
73 |
// create each of the class pages |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
74 |
for (var i = 0, l = classes.length; i < l; i++) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
75 |
var symbol = classes[i]; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
76 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
77 |
symbol.events = symbol.getEvents(); // 1 order matters |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
78 |
symbol.methods = symbol.getMethods(); // 2 |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
79 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
80 |
var output = ""; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
81 |
output = classTemplate.process(symbol); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
82 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
83 |
IO.saveFile(publish.conf.outDir+"symbols/", ((JSDOC.opt.u)? Link.filemap[symbol.alias] : symbol.alias) + publish.conf.ext, output); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
84 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
85 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
86 |
// regenerate the index with different relative links, used in the index pages |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
87 |
Link.base = ""; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
88 |
publish.classesIndex = classesTemplate.process(classes); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
89 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
90 |
// create the class index page |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
91 |
try { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
92 |
var classesindexTemplate = new JSDOC.JsPlate(publish.conf.templatesDir+"index.tmpl"); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
93 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
94 |
catch(e) { print(e.message); quit(); } |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
95 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
96 |
var classesIndex = classesindexTemplate.process(classes); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
97 |
IO.saveFile(publish.conf.outDir, "index"+publish.conf.ext, classesIndex); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
98 |
classesindexTemplate = classesIndex = classes = null; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
99 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
100 |
// create the file index page |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
101 |
try { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
102 |
var fileindexTemplate = new JSDOC.JsPlate(publish.conf.templatesDir+"allfiles.tmpl"); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
103 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
104 |
catch(e) { print(e.message); quit(); } |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
105 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
106 |
var documentedFiles = symbols.filter(isaFile); // files that have file-level docs |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
107 |
var allFiles = []; // not all files have file-level docs, but we need to list every one |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
108 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
109 |
for (var i = 0; i < files.length; i++) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
110 |
allFiles.push(new JSDOC.Symbol(files[i], [], "FILE", new JSDOC.DocComment("/** */"))); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
111 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
112 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
113 |
for (var i = 0; i < documentedFiles.length; i++) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
114 |
var offset = files.indexOf(documentedFiles[i].alias); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
115 |
allFiles[offset] = documentedFiles[i]; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
116 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
117 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
118 |
allFiles = allFiles.sort(makeSortby("name")); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
119 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
120 |
// output the file index page |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
121 |
var filesIndex = fileindexTemplate.process(allFiles); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
122 |
IO.saveFile(publish.conf.outDir, "files"+publish.conf.ext, filesIndex); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
123 |
fileindexTemplate = filesIndex = files = null; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
124 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
125 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
126 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
127 |
/** Just the first sentence (up to a full stop). Should not break on dotted variable names. */ |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
128 |
function summarize(desc) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
129 |
if (typeof desc != "undefined") |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
130 |
return desc.match(/([\w\W]+?\.)[^a-z0-9_$]/i)? RegExp.$1 : desc; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
131 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
132 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
133 |
/** Make a symbol sorter by some attribute. */ |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
134 |
function makeSortby(attribute) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
135 |
return function(a, b) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
136 |
if (a[attribute] != undefined && b[attribute] != undefined) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
137 |
a = a[attribute].toLowerCase(); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
138 |
b = b[attribute].toLowerCase(); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
139 |
if (a < b) return -1; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
140 |
if (a > b) return 1; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
141 |
return 0; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
142 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
143 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
144 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
145 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
146 |
/** Pull in the contents of an external file at the given path. */ |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
147 |
function include(path) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
148 |
var path = publish.conf.templatesDir+path; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
149 |
return IO.readFile(path); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
150 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
151 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
152 |
/** Turn a raw source file into a code-hilited page in the docs. */ |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
153 |
function makeSrcFile(path, srcDir, name) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
154 |
if (JSDOC.opt.s) return; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
155 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
156 |
if (!name) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
157 |
name = path.replace(/\.\.?[\\\/]/g, "").replace(/[\\\/]/g, "_"); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
158 |
name = name.replace(/\:/g, "_"); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
159 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
160 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
161 |
var src = {path: path, name:name, charset: IO.encoding, hilited: ""}; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
162 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
163 |
if (defined(JSDOC.PluginManager)) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
164 |
JSDOC.PluginManager.run("onPublishSrc", src); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
165 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
166 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
167 |
if (src.hilited) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
168 |
IO.saveFile(srcDir, name+publish.conf.ext, src.hilited); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
169 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
170 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
171 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
172 |
/** Build output for displaying function parameters. */ |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
173 |
function makeSignature(params) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
174 |
if (!params) return "()"; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
175 |
var signature = "(" |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
176 |
+ |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
177 |
params.filter( |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
178 |
function($) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
179 |
return $.name.indexOf(".") == -1; // don't show config params in signature |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
180 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
181 |
).map( |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
182 |
function($) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
183 |
return $.name; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
184 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
185 |
).join(", ") |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
186 |
+ |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
187 |
")"; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
188 |
return signature; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
189 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
190 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
191 |
/** Find symbol {@link ...} strings in text and turn into html links */ |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
192 |
function resolveLinks(str, from) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
193 |
str = str.replace(/\{@link ([^} ]+) ?\}/gi, |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
194 |
function(match, symbolName) { |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
195 |
return new Link().toSymbol(symbolName); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
196 |
} |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
197 |
); |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
198 |
|
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
199 |
return str; |
c8f47f0b6697
JSDocToolkit 2.3.0 added to create documentation for JS files.
Mario Ferraro <fadinlight@gmail.com>
parents:
diff
changeset
|
200 |
} |