mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
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:
parent
2f60a28619
commit
e51f8533bd
@ -2,10 +2,13 @@
|
|||||||
"tags": {
|
"tags": {
|
||||||
"allowUnknownTags": true
|
"allowUnknownTags": true
|
||||||
},
|
},
|
||||||
|
|
||||||
"source": {
|
"source": {
|
||||||
"includePattern": ".+\\.js(doc)?$"
|
"includePattern": ".+\\.js(doc)?$"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"//": "Add paths to any plugin files you want applied. like: plugins/markdown.js",
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"plugins/markdown.js"
|
],
|
||||||
]
|
|
||||||
}
|
}
|
||||||
15
main.js
15
main.js
@ -122,6 +122,16 @@ function main() {
|
|||||||
|
|
||||||
env.opts = jsdoc.opts.parser.parse(env.args);
|
env.opts = jsdoc.opts.parser.parse(env.args);
|
||||||
|
|
||||||
|
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) {
|
if (env.opts.help) {
|
||||||
print( jsdoc.opts.parser.help() );
|
print( jsdoc.opts.parser.help() );
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -169,9 +179,10 @@ function main() {
|
|||||||
if (typeof publish === 'function') {
|
if (typeof publish === 'function') {
|
||||||
publish(
|
publish(
|
||||||
new (require('typicaljoe/taffy'))(docs),
|
new (require('typicaljoe/taffy'))(docs),
|
||||||
{ destination: env.opts.destination }
|
env.opts
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// TODO throw no publish warning?
|
else { // TODO throw no publish warning?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -25,6 +25,7 @@
|
|||||||
argsParser.addOption('r', 'recurse', false, 'Recurse into subdirectories when scanning for source code files.');
|
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('h', 'help', false, 'Print this message and quit.');
|
||||||
argsParser.addOption('X', 'expel', false, 'Dump all found doclet internals to console 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
|
// TODO [-R, recurseonly] = a number representing the depth to recurse
|
||||||
|
|||||||
@ -11,15 +11,30 @@
|
|||||||
@param {object} opts
|
@param {object} opts
|
||||||
*/
|
*/
|
||||||
publish = function(data, opts) {
|
publish = function(data, opts) {
|
||||||
var rootNamespace = {},
|
|
||||||
|
var root = {},
|
||||||
docs;
|
docs;
|
||||||
|
|
||||||
data.remove({undocumented: true});
|
data.remove({undocumented: true});
|
||||||
docs = data.get(); // <-- an array of Doclet objects
|
docs = data.get(); // <-- an array of Doclet objects
|
||||||
|
|
||||||
graft(rootNamespace, docs);
|
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"!');
|
||||||
|
}
|
||||||
|
|
||||||
dump(rootNamespace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function graft(parentNode, childNodes, parentLongname, parentName) {
|
function graft(parentNode, childNodes, parentLongname, parentName) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user