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.

This commit is contained in:
Michael Mathews 2011-01-09 14:39:44 +00:00
parent 2f60a28619
commit e51f8533bd
4 changed files with 39 additions and 9 deletions

View File

@ -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"
]
],
}

17
main.js
View File

@ -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?
}
}
}

View File

@ -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

View File

@ -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( '<jsdoc>\n' + xml.convert(root) + '\n</jsdoc>' );
}
else {
dump(root);
}
}
else {
print('The only -d destination option currently supported is "console"!');
}
}
function graft(parentNode, childNodes, parentLongname, parentName) {