diff --git a/build/jsdoc-toolkit/templates/jsdoc/publish.js b/build/jsdoc-toolkit/templates/jsdoc/publish.js index 834a1ac4..2e022408 100644 --- a/build/jsdoc-toolkit/templates/jsdoc/publish.js +++ b/build/jsdoc-toolkit/templates/jsdoc/publish.js @@ -1,3 +1,94 @@ +/** Called automatically by JsDoc Toolkit. */ +function publish(symbolSet) { + publish.conf = { // trailing slash expected for dirs + ext: '.html', + outDir: JSDOC.opt.d || SYS.pwd + '../out/jsdoc/', + templateDir: JSDOC.opt.t || SYS.pwd + '../templates/jsdoc/', + staticDir: (JSDOC.opt.t || SYS.pwd + '../templates/jsdoc/') + 'static/', + symbolsDir: 'packages/', + srcDir: 'symbols/src/' + }; + publish.conf.packagesDir = publish.conf.outDir + 'packages/'; + var templatesDir = publish.conf.templateDir + 'templates/'; + publish.templates = { + _class: 'class.tmpl', + method: 'method.tmpl', + property: 'property.tmpl', + parameters: 'parameters.tmpl', + operators: 'operators.tmpl', + returns: 'returns.tmpl', + seeAlsos: 'see-alsos.tmpl', + example: 'example.tmpl', + constructor: 'constructor.tmpl', + html: 'html.tmpl', + allClasses: 'allClasses.tmpl', + menu: 'packages.tmpl' + }; + + for (var i in publish.templates) { + publish.templates[i] = new JSDOC.JsPlate(templatesDir + + publish.templates[i]); + } + + // Copy over the static files + Utils.copyDirectory( + new java.io.File(publish.conf.staticDir), + new java.io.File(publish.conf.outDir) + ); + + // used to allow Link to check the details of things being linked to + Link.symbolSet = symbolSet; + + // get an array version of the symbolset, useful for filtering + var symbols = symbolSet.toArray(), + files = JSDOC.opt.srcFiles, + aliasSort = Utils.makeSortby('alias'), + classes = symbols.filter(Utils.isaClass).sort(aliasSort); + + // create a filemap in which outfiles must be to be named uniquely, ignoring case + if (JSDOC.opt.u) { + var filemapCounts = {}; + Link.filemap = {}; + for (var i = 0, l = classes.length; i < l; i++) { + var lcAlias = classes[i].alias.toLowerCase(); + + if (!filemapCounts[lcAlias]) { + filemapCounts[lcAlias] = 1; + } else { + filemapCounts[lcAlias]++; + } + + Link.filemap[classes[i].alias] = (filemapCounts[lcAlias] > 1) ? + lcAlias + '_' + filemapCounts[lcAlias] : lcAlias; + } + } + + Link.base = '../'; + + // create each of the class pages + for (var i = 0, l = classes.length; i < l; i++) { + var symbol = classes[i]; + + symbol.events = symbol.getEvents(); // 1 order matters + symbol.methods = symbol.getMethods(); // 2 + for (var j = 0; j < symbol.methods.length; j++) { + var method = symbol.methods[j]; + method.isOperator = Operator.isOperator(method); + } + + Link.currentSymbol= symbol; + var html = publish.templates.html.process({ + content: publish.templates._class.process(symbol), + title: symbol.alias + }) + var name = ((JSDOC.opt.u)? Link.filemap[symbol.alias] : symbol.alias) + + publish.conf.ext; + IO.saveFile(publish.conf.packagesDir, name, html); + } + + Utils.publishMenu(); +} + var Operator = new function() { var operators = { add: '+', subtract: '-', multiply: '*', divide: '/', equals: '==', @@ -28,7 +119,7 @@ var Operator = new function() { } } -var Helpers = { +var Utils = { getSymbolId: function(symbol) { var id = [symbol.name.toLowerCase().replace(/[\^][0-9]/g, '')]; if (symbol.params) { @@ -75,291 +166,203 @@ var Helpers = { })); } return out.join('\n'); - } -}; - -/** Called automatically by JsDoc Toolkit. */ -function publish(symbolSet) { - publish.conf = { // trailing slash expected for dirs - ext: '.html', - outDir: JSDOC.opt.d || SYS.pwd + '../out/jsdoc/', - templateDir: JSDOC.opt.t || SYS.pwd + '../templates/jsdoc/', - staticDir: (JSDOC.opt.t || SYS.pwd + '../templates/jsdoc/') + 'static/', - symbolsDir: 'packages/', - srcDir: 'symbols/src/' - }; - publish.conf.packagesDir = publish.conf.outDir + 'packages/'; - var templatesDir = publish.conf.templateDir + 'templates/'; - publish.templates = { - _class: 'class.tmpl', - method: 'method.tmpl', - property: 'property.tmpl', - parameters: 'parameters.tmpl', - operators: 'operators.tmpl', - returns: 'returns.tmpl', - seeAlsos: 'see-alsos.tmpl', - example: 'example.tmpl', - constructor: 'constructor.tmpl', - html: 'html.tmpl', - allClasses: 'allClasses.tmpl', - menu: 'packages.tmpl' - }; - - for (var i in publish.templates) { - publish.templates[i] = new JSDOC.JsPlate(templatesDir + - publish.templates[i]); - } - - // Copy over the static files - copyDirectory( - new java.io.File(publish.conf.staticDir), - new java.io.File(publish.conf.outDir) - ); - - // used to allow Link to check the details of things being linked to - Link.symbolSet = symbolSet; - - // get an array version of the symbolset, useful for filtering - var symbols = symbolSet.toArray(), - files = JSDOC.opt.srcFiles, - classes = symbols.filter(Helpers.isaClass).sort(makeSortby('alias')); + }, - // create a filemap in which outfiles must be to be named uniquely, ignoring case - if (JSDOC.opt.u) { - var filemapCounts = {}; - Link.filemap = {}; - for (var i = 0, l = classes.length; i < l; i++) { - var lcAlias = classes[i].alias.toLowerCase(); - - if (!filemapCounts[lcAlias]) { - filemapCounts[lcAlias] = 1; - } else { - filemapCounts[lcAlias]++; + stripTags: function(str, tag) { + var tag = tag || '.*?'; // Default: all tags + return str.replace(new RegExp('<' + tag + '>|', 'g'), ''); + }, + + copyDirectory: function(sourceLocation, targetLocation) { + if (sourceLocation.isDirectory()) { + if (!targetLocation.exists()) { + targetLocation.mkdir(); } - - Link.filemap[classes[i].alias] = (filemapCounts[lcAlias] > 1) ? - lcAlias + '_' + filemapCounts[lcAlias] : lcAlias; - } - } - - Link.base = '../'; - // create each of the class pages - for (var i = 0, l = classes.length; i < l; i++) { - var symbol = classes[i]; - - symbol.events = symbol.getEvents(); // 1 order matters - symbol.methods = symbol.getMethods(); // 2 - for (var j = 0; j < symbol.methods.length; j++) { - var method = symbol.methods[j]; - method.isOperator = Operator.isOperator(method); + var children = sourceLocation.list(); + for (var i = 0; i < children.length; i++) { + Utils.copyDirectory(new File(sourceLocation, children[i]), + new File(targetLocation, children[i])); + } + } else { + // Copy the file with FileChannels: + targetLocation.createNewFile(); + var src = new java.io.FileInputStream(sourceLocation).getChannel(); + var dst = new java.io.FileOutputStream(targetLocation).getChannel(); + var amount = dst.transferFrom(src, 0, src.size()); + src.close(); + dst.close(); } - - Link.currentSymbol= symbol; - var html = publish.templates.html.process({ - content: publish.templates._class.process(symbol), - title: symbol.alias - }) - var name = ((JSDOC.opt.u)? Link.filemap[symbol.alias] : symbol.alias) - + publish.conf.ext; - IO.saveFile(publish.conf.packagesDir, name, html); - } - - publishMenu(); -} + }, -function publishMenu() { - load(JSDOC.opt.t + 'classLayout.js'); - function parseClassNames(classNames) { - var out = ''; - for (var i = 0, l = classNames.length; i < l; i++) { - if (typeof classNames[i] == 'string') { - var name = classNames[i]; - out += (name == 'ruler') ? getRuler() : getLink(name); - } else { - for (var j in classNames[i]) { - out += getHeading(j); - out += parseClassNames(classNames[i][j]); + processGroupTitle: function(str, symbol) { + var groupTitle = str.match(/\{@grouptitle ([^}]+)\}/); + if (groupTitle) { + symbol.groupTitle = groupTitle[1]; + str = str.replace(/\{@grouptitle ([^}]+)\}/, ''); + } + return str; + }, + + publishMenu: function() { + load(JSDOC.opt.t + 'classLayout.js'); + function parseClassNames(classNames) { + var out = ''; + for (var i = 0, l = classNames.length; i < l; i++) { + if (typeof classNames[i] == 'string') { + var name = classNames[i]; + out += (name == 'ruler') ? getRuler() : getLink(name); + } else { + for (var j in classNames[i]) { + out += getHeading(j); + out += parseClassNames(classNames[i][j]); + } } } + return out; } - return out; - } - function getLink(name) { - return '
  • ' + name + '
  • '; - } - - function getRuler() { - return '

  • '; - } - - function getHeading(title) { - return '
  • ' + title + '

  • '; - } - var first = true, - out = '