From de9378f5c6f54055c421ceb1cc334c0d8f185c25 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Sat, 28 May 2011 19:31:41 +0200 Subject: [PATCH] jsdoc: render menu and move resources into static. --- build/jsdoc-toolkit/app/frame/Link.js | 4 +- build/jsdoc-toolkit/app/plugins/ignore.js | 10 ++ .../templates/jsdoc/classLayout.js | 14 ++ .../jsdoc-toolkit/templates/jsdoc/publish.js | 66 +++++-- .../templates/jsdoc/static/default.css | 162 ------------------ .../templates/jsdoc/static/header.html | 2 - .../templates/jsdoc/static/index.html | 25 +-- .../resources/assets/arrow-close.gif | Bin .../resources/assets/arrow-open.gif | Bin .../{ => static}/resources/assets/dotted.gif | Bin .../resources/assets/paper-gray.gif | Bin .../{ => static}/resources/assets/spacer.gif | Bin .../{ => static}/resources/css/lighter.css | 0 .../{ => static}/resources/css/reference.css | 0 .../{ => static}/resources/css/style.css | 0 .../{ => static}/resources/js/bootstrap.js | 0 .../{ => static}/resources/js/lighter.js | 0 .../{ => static}/resources/js/reference.js | 0 .../templates/jsdoc/templates/index.tmpl | 39 ----- .../templates/jsdoc/templates/packages.tmpl | 16 ++ 20 files changed, 103 insertions(+), 235 deletions(-) create mode 100644 build/jsdoc-toolkit/app/plugins/ignore.js create mode 100644 build/jsdoc-toolkit/templates/jsdoc/classLayout.js delete mode 100644 build/jsdoc-toolkit/templates/jsdoc/static/default.css delete mode 100644 build/jsdoc-toolkit/templates/jsdoc/static/header.html rename build/jsdoc-toolkit/templates/jsdoc/{ => static}/resources/assets/arrow-close.gif (100%) rename build/jsdoc-toolkit/templates/jsdoc/{ => static}/resources/assets/arrow-open.gif (100%) rename build/jsdoc-toolkit/templates/jsdoc/{ => static}/resources/assets/dotted.gif (100%) rename build/jsdoc-toolkit/templates/jsdoc/{ => static}/resources/assets/paper-gray.gif (100%) rename build/jsdoc-toolkit/templates/jsdoc/{ => static}/resources/assets/spacer.gif (100%) rename build/jsdoc-toolkit/templates/jsdoc/{ => static}/resources/css/lighter.css (100%) rename build/jsdoc-toolkit/templates/jsdoc/{ => static}/resources/css/reference.css (100%) rename build/jsdoc-toolkit/templates/jsdoc/{ => static}/resources/css/style.css (100%) rename build/jsdoc-toolkit/templates/jsdoc/{ => static}/resources/js/bootstrap.js (100%) rename build/jsdoc-toolkit/templates/jsdoc/{ => static}/resources/js/lighter.js (100%) rename build/jsdoc-toolkit/templates/jsdoc/{ => static}/resources/js/reference.js (100%) delete mode 100644 build/jsdoc-toolkit/templates/jsdoc/templates/index.tmpl create mode 100644 build/jsdoc-toolkit/templates/jsdoc/templates/packages.tmpl diff --git a/build/jsdoc-toolkit/app/frame/Link.js b/build/jsdoc-toolkit/app/frame/Link.js index 0e8aadf3..be316eb0 100644 --- a/build/jsdoc-toolkit/app/frame/Link.js +++ b/build/jsdoc-toolkit/app/frame/Link.js @@ -82,7 +82,7 @@ Link.symbolNameToLinkName = function(symbol) { var linker = "", ns = ""; - if (symbol.isStatic) linker = "."; + if (symbol.isStatic) linker = "-"; else if (symbol.isInner) linker = "-"; if (symbol.isEvent && !/^event:/.test(symbol.name)) { @@ -137,7 +137,7 @@ Link.prototype._makeSymbolLink = function(alias, parameters) { // it's a symbol in another file if (!linkTo.is("CONSTRUCTOR") && !linkTo.isNamespace) { // it's a method or property linkPath= (Link.filemap) ? Link.filemap[linkTo.memberOf] : - escape(linkTo.memberOf) || "_global_"; + escape(linkTo.memberOf) || "global"; linkPath += publish.conf.ext + "#" + Link.symbolNameToLinkName(linkTo).toLowerCase(); if (parameters) { linkPath += '-' + parameters.replace(/[()]+/g, '').split(', ').join('-').toLowerCase(); diff --git a/build/jsdoc-toolkit/app/plugins/ignore.js b/build/jsdoc-toolkit/app/plugins/ignore.js new file mode 100644 index 00000000..de8eae61 --- /dev/null +++ b/build/jsdoc-toolkit/app/plugins/ignore.js @@ -0,0 +1,10 @@ +JSDOC.PluginManager.registerPlugin( + "JSDOC.ignore", + { + onSymbol: function(symbol) { + if (symbol.comment.getTag('ignore').length) { + symbol.ignore = true; + } + } + } +); \ No newline at end of file diff --git a/build/jsdoc-toolkit/templates/jsdoc/classLayout.js b/build/jsdoc-toolkit/templates/jsdoc/classLayout.js new file mode 100644 index 00000000..d7f95f97 --- /dev/null +++ b/build/jsdoc-toolkit/templates/jsdoc/classLayout.js @@ -0,0 +1,14 @@ +var classLayout = { + 'Paper.js': ['global'], + 'Basic Types': ['Point', 'Size', 'Rectangle', 'Matrix'], + 'Items': ['Item', 'Layer', 'Group', 'Raster', 'PlacedSymbol'], + 'Paths': ['Path', 'CompoundPath', 'Segment', 'Curve', 'PathStyle', 'ruler', + 'CurveLocation'], + 'Tools': ['Tool', 'ToolEvent', 'Key', 'KeyEvent'], + 'Projects': ['Project', 'View', 'Symbol'], + 'Colors': ['Color', 'RGBColor', 'GrayColor', 'HSBColor'], + 'Gradients': ['GradientColor', 'Gradient', 'GradientStop'], + 'Typography': ['TextItem', 'PointText', { + 'Style': ['CharacterStyle', 'ParagraphStyle'] + }] +}; \ No newline at end of file diff --git a/build/jsdoc-toolkit/templates/jsdoc/publish.js b/build/jsdoc-toolkit/templates/jsdoc/publish.js index c024dcbe..01164c53 100644 --- a/build/jsdoc-toolkit/templates/jsdoc/publish.js +++ b/build/jsdoc-toolkit/templates/jsdoc/publish.js @@ -63,13 +63,13 @@ var Helpers = { function publish(symbolSet) { publish.conf = { // trailing slash expected for dirs ext: '.html', - outDir: JSDOC.opt.d || SYS.pwd + '../out/jsdoc/', + outDir: JSDOC.opt.d || SYS.pwd + '../out/jsdoc/', templateDir: JSDOC.opt.t || SYS.pwd + '../templates/jsdoc/', - resourcesDir: (JSDOC.opt.t || SYS.pwd + '../templates/jsdoc/') + 'resources/', - symbolsDir: 'symbols/', - srcDir: 'symbols/src/' + staticDir: (JSDOC.opt.t || SYS.pwd + '../templates/jsdoc/') + 'static/', + symbolsDir: 'symbols/', + srcDir: 'symbols/src/' }; - + publish.conf.packagesDir = publish.conf.outDir + 'packages/'; var templatesDir = publish.conf.templateDir + 'templates/'; publish.templates = { _class: 'class.tmpl', @@ -81,7 +81,7 @@ function publish(symbolSet) { constructor: 'constructor.tmpl', html: 'html.tmpl', allClasses: 'allClasses.tmpl', - classesIndex: 'index.tmpl' + menu: 'packages.tmpl' }; for (var i in publish.templates) { @@ -91,8 +91,8 @@ function publish(symbolSet) { // Copy over the static files copyDirectory( - new java.io.File(publish.conf.resourcesDir), - new java.io.File(publish.conf.outDir + 'resources/') + 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 @@ -143,15 +143,53 @@ function publish(symbolSet) { }) var name = ((JSDOC.opt.u)? Link.filemap[symbol.alias] : symbol.alias) + publish.conf.ext; - IO.saveFile(publish.conf.outDir + 'symbols/', name, html); + IO.saveFile(publish.conf.packagesDir, name, html); } - // regenerate the index with different relative links, used in the index pages - Link.base = ''; - publish.conf.classesIndex = publish.templates.allClasses.process(classes); + 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]); + } + } + } + return out; + } + function getLink(name) { + return '
  • ' + name + '
  • '; + } - var classesIndex = publish.templates.classesIndex.process(classes); - IO.saveFile(publish.conf.outDir, 'index' + publish.conf.ext, classesIndex); + function getRuler() { + return '

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

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