From 2d71ff9c9e861229b5ded29ba8fddc369ba3066b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 7 Jun 2011 10:28:18 +0100 Subject: [PATCH] JSDocs: Move Utils.publishMenu() funcitonality to Render.classes(), but have it not render the template yet, as it is requied by both docs and templatedocs, through the index rendering functions Render.index() (previoulsy Render.menu()) and Render.indexjs (previously Render.packagesjs). --- .../jsdoc-toolkit/templates/jsdoc/publish.js | 8 +-- .../templates/jsdoc/src/Render.js | 67 +++++++++++++++++-- .../templates/jsdoc/src/Utils.js | 48 ------------- .../templates/jsdoc/static/index.html | 2 +- .../templates/{packages.tmpl => index.tmpl} | 2 +- .../templates/jsdoc/templates/indexjs.tmpl | 1 + .../templates/jsdoc/templates/packagesjs.tmpl | 1 - 7 files changed, 67 insertions(+), 62 deletions(-) rename build/jsdoc-toolkit/templates/jsdoc/templates/{packages.tmpl => index.tmpl} (95%) create mode 100644 build/jsdoc-toolkit/templates/jsdoc/templates/indexjs.tmpl delete mode 100644 build/jsdoc-toolkit/templates/jsdoc/templates/packagesjs.tmpl diff --git a/build/jsdoc-toolkit/templates/jsdoc/publish.js b/build/jsdoc-toolkit/templates/jsdoc/publish.js index 8f99b934..3df38877 100644 --- a/build/jsdoc-toolkit/templates/jsdoc/publish.js +++ b/build/jsdoc-toolkit/templates/jsdoc/publish.js @@ -84,9 +84,9 @@ function publish(symbolSet) { } IO.saveFile(publish.conf.packagesDir, name, html); } - if (renderMode == 'docs') - Utils.publishMenu(); - if (renderMode == 'templatedocs') { - IO.saveFile(publish.conf.outDir, 'packages.js', Render.packagesjs()); + if (templatedocs) { + IO.saveFile(publish.conf.outDir, 'packages.js', Render.indexjs()); + } else { + IO.saveFile(publish.conf.classesDir, 'index.html', Render.index()); } } \ No newline at end of file diff --git a/build/jsdoc-toolkit/templates/jsdoc/src/Render.js b/build/jsdoc-toolkit/templates/jsdoc/src/Render.js index 58350eed..a3db82d7 100644 --- a/build/jsdoc-toolkit/templates/jsdoc/src/Render.js +++ b/build/jsdoc-toolkit/templates/jsdoc/src/Render.js @@ -14,9 +14,9 @@ var Render = new function() { example: 'example.tmpl', constructor: 'constructor.tmpl', html: 'html.tmpl', - menu: 'packages.tmpl', - operator: 'operator.tmpl', - packagesjs: 'packagesjs.tmpl' + index: 'index.tmpl', + indexjs: 'indexjs.tmpl', + operator: 'operator.tmpl' }; publish.classes = []; for (var i in templates) { @@ -328,11 +328,64 @@ var Render = new function() { html: function(content) { return templates.html.process(content); }, - menu: function(html) { - return templates.menu.process(html); + classes: function() { + // TODO: Use Template instead? + var renderMode = publish.conf.renderMode; + 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; + } + function getLink(name) { + var link = name; + if (name.indexOf(':') > 0) { + var names = name.split(':'); + name = names[0]; + link = names[1]; + } + if (renderMode == 'docs') { + link += '.html'; + } else if (renderMode == 'templatedocs') { + link = link.toLowerCase(); + link = '/reference/' + (link == '_global_' ? 'global' : link); + } + return '
  • ' + name + '
  • \n'; + } + + function getRuler() { + return '

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

  • \n'; + } + var first = true, + out = ''; + return out; }, - packagesjs: function() { - return templates.packagesjs.process(publish.classes); + index: function(html) { + return templates.index.process(html); + }, + indexjs: function() { + return templates.indexjs.process(publish.classes); } }; }; \ No newline at end of file diff --git a/build/jsdoc-toolkit/templates/jsdoc/src/Utils.js b/build/jsdoc-toolkit/templates/jsdoc/src/Utils.js index 5b937673..55b1ce8a 100644 --- a/build/jsdoc-toolkit/templates/jsdoc/src/Utils.js +++ b/build/jsdoc-toolkit/templates/jsdoc/src/Utils.js @@ -41,54 +41,6 @@ var Utils = { throw Error('Could not delete ' + path); }, - 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; - } - function getLink(name) { - var link = name; - if (name.indexOf(':') > 0) { - var names = name.split(':'); - name = names[0]; - link = names[1]; - } - return '
  • ' + name + '
  • \n'; - } - - function getRuler() { - return '

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

  • \n'; - } - var first = true, - out = ''; - - var classesIndex = Render.menu(out); - IO.saveFile(publish.conf.packagesDir, 'packages.html', classesIndex); - }, - makeSortby: function(attribute) { return function(a, b) { if (a[attribute] != undefined && b[attribute] != undefined) { diff --git a/build/jsdoc-toolkit/templates/jsdoc/static/index.html b/build/jsdoc-toolkit/templates/jsdoc/static/index.html index 022fea4b..b815ec0d 100644 --- a/build/jsdoc-toolkit/templates/jsdoc/static/index.html +++ b/build/jsdoc-toolkit/templates/jsdoc/static/index.html @@ -6,7 +6,7 @@ Paper.js API - + diff --git a/build/jsdoc-toolkit/templates/jsdoc/templates/packages.tmpl b/build/jsdoc-toolkit/templates/jsdoc/templates/index.tmpl similarity index 95% rename from build/jsdoc-toolkit/templates/jsdoc/templates/packages.tmpl rename to build/jsdoc-toolkit/templates/jsdoc/templates/index.tmpl index 16dc4f7e..6063a5a3 100644 --- a/build/jsdoc-toolkit/templates/jsdoc/templates/packages.tmpl +++ b/build/jsdoc-toolkit/templates/jsdoc/templates/index.tmpl @@ -11,6 +11,6 @@

    Paper.js

    -{+ data +} +{+ Render.classes() +} \ No newline at end of file diff --git a/build/jsdoc-toolkit/templates/jsdoc/templates/indexjs.tmpl b/build/jsdoc-toolkit/templates/jsdoc/templates/indexjs.tmpl new file mode 100644 index 00000000..6a9c94aa --- /dev/null +++ b/build/jsdoc-toolkit/templates/jsdoc/templates/indexjs.tmpl @@ -0,0 +1 @@ +createPackage("", {+ JSON.stringify(data) +}, "", {+ JSON.stringify(Render.classes()) +}); \ No newline at end of file diff --git a/build/jsdoc-toolkit/templates/jsdoc/templates/packagesjs.tmpl b/build/jsdoc-toolkit/templates/jsdoc/templates/packagesjs.tmpl deleted file mode 100644 index f0bc06bc..00000000 --- a/build/jsdoc-toolkit/templates/jsdoc/templates/packagesjs.tmpl +++ /dev/null @@ -1 +0,0 @@ -createPackage("Paper", {+ JSON.stringify(data) +}); \ No newline at end of file