From e51f8533bd948724a08eb03ef337d1fde58c79bb Mon Sep 17 00:00:00 2001 From: Michael Mathews Date: Sun, 9 Jan 2011 14:39:44 +0000 Subject: [PATCH] Added support for the -q --query option to pass in custom options. Added support for haruki to generate XML when the format=xml query option is seen. --- conf.json | 7 +++++-- main.js | 17 ++++++++++++++--- modules/jsdoc/opts/parser.js | 1 + templates/haruki/publish.js | 23 +++++++++++++++++++---- 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/conf.json b/conf.json index 12f16f69..0359208a 100644 --- a/conf.json +++ b/conf.json @@ -2,10 +2,13 @@ "tags": { "allowUnknownTags": true }, + "source": { "includePattern": ".+\\.js(doc)?$" }, + + "//": "Add paths to any plugin files you want applied. like: plugins/markdown.js", "plugins": [ - "plugins/markdown.js" - ] + ], + } \ No newline at end of file diff --git a/main.js b/main.js index 1d1a7c15..1810b1e5 100644 --- a/main.js +++ b/main.js @@ -122,7 +122,17 @@ function main() { env.opts = jsdoc.opts.parser.parse(env.args); - if (env.opts.help) { + if (env.opts.query) { + var q = env.opts.query; + env.opts.query = {}; + var queryString = {}; + q.replace( // thanks Steven Benner + new RegExp("([^?=&]+)(=([^&]*))?", "g"), + function($0, $1, $2, $3) { env.opts.query[$1] = $3; } + ); + } + + if (env.opts.help) { print( jsdoc.opts.parser.help() ); exit(0); } @@ -169,9 +179,10 @@ function main() { if (typeof publish === 'function') { publish( new (require('typicaljoe/taffy'))(docs), - { destination: env.opts.destination } + env.opts ); } - // TODO throw no publish warning? + else { // TODO throw no publish warning? + } } } \ No newline at end of file diff --git a/modules/jsdoc/opts/parser.js b/modules/jsdoc/opts/parser.js index 6ab4a9ea..f0945f74 100644 --- a/modules/jsdoc/opts/parser.js +++ b/modules/jsdoc/opts/parser.js @@ -25,6 +25,7 @@ argsParser.addOption('r', 'recurse', false, 'Recurse into subdirectories when scanning for source code files.'); argsParser.addOption('h', 'help', false, 'Print this message and quit.'); argsParser.addOption('X', 'expel', false, 'Dump all found doclet internals to console and quit.'); + argsParser.addOption('q', 'query', true, 'Provide a querystring to define custom variable names/values to add to the options hash.'); // TODO [-R, recurseonly] = a number representing the depth to recurse diff --git a/templates/haruki/publish.js b/templates/haruki/publish.js index 26f2283d..92799c2d 100644 --- a/templates/haruki/publish.js +++ b/templates/haruki/publish.js @@ -11,15 +11,30 @@ @param {object} opts */ publish = function(data, opts) { - var rootNamespace = {}, + + var root = {}, docs; data.remove({undocumented: true}); docs = data.get(); // <-- an array of Doclet objects - graft(rootNamespace, docs); - - dump(rootNamespace); + graft(root, docs); + + + + if (opts.destination === 'console') { + if (opts.query && opts.query.format === 'xml') { + var xml = require('goessner/json2xml'); + print( '\n' + xml.convert(root) + '\n' ); + } + else { + dump(root); + } + } + else { + print('The only -d destination option currently supported is "console"!'); + } + } function graft(parentNode, childNodes, parentLongname, parentName) {