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.
This commit is contained in:
Jannon 2012-02-22 14:27:06 -08:00
parent 279554f1a3
commit 7b12033b5a
3 changed files with 8 additions and 6 deletions

View File

@ -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 = {};

View File

@ -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<String>}
*/

View File

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