From 7b12033b5a141e53be12cd734df9312eb850bfbb Mon Sep 17 00:00:00 2001 From: Jannon Date: Wed, 22 Feb 2012 14:27:06 -0800 Subject: [PATCH] Always making source file list available to templates Previously, the list of source files was only added to a package doclet and passed through to the templates if there was a package.json specified. Now, that doclet is always added. If there is no package.json, then only the 'files' property of the doclet will be defined. --- jsdoc.js | 10 +++++----- rhino_modules/jsdoc/package.js | 2 ++ templates/default/publish.js | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/jsdoc.js b/jsdoc.js index a0077d33..2703a33f 100644 --- a/jsdoc.js +++ b/jsdoc.js @@ -213,11 +213,11 @@ function main() { docs = app.jsdoc.parser.parse(sourceFiles, env.opts.encoding); - if (packageJson) { - var packageDocs = new (require('jsdoc/package').Package)(packageJson); - packageDocs.files = sourceFiles || []; - docs.push(packageDocs); - } + //The files are ALWAYS useful for the templates to have + //If there is no package.json, just create an empty package + var packageDocs = new (require('jsdoc/package').Package)(packageJson); + packageDocs.files = sourceFiles || []; + docs.push(packageDocs); function indexAll(docs) { var lookupTable = {}; diff --git a/rhino_modules/jsdoc/package.js b/rhino_modules/jsdoc/package.js index 9452a6f4..ef4b8125 100644 --- a/rhino_modules/jsdoc/package.js +++ b/rhino_modules/jsdoc/package.js @@ -15,6 +15,8 @@ @param {string} json - The contents of package.json. */ exports.Package = function(json) { + json = json || "{}"; + /** The source files associated with this package. @type {Array} */ diff --git a/templates/default/publish.js b/templates/default/publish.js index 5741dfa7..c894edfc 100644 --- a/templates/default/publish.js +++ b/templates/default/publish.js @@ -185,7 +185,7 @@ namespaces = find({kind: 'namespace'}); var outdir = opts.destination; - if (packageInfo) { + if (packageInfo && packageInfo.name) { outdir += '/' + packageInfo.name + '/' + packageInfo.version + '/'; } fs.mkPath(outdir);