paths.forEach(function(path) { if (fs.isFile(path)) { r.push(modularizeFile(path, base, optimize)); } else if (fs.isDirectory(path)) { r.push(modularizeDirectory(path, base, optimize)); } });
/** * Create static documentation for a Repository. * * ringo doc.js -s /home/foo/ringojs/modules/ * * You can specify a human readable name for the module which will * be display in the documentation: * * ringo doc.js -s /home/foo/ringojs/modules -n "Ringojs Modules" * * @param args */ function main(args) { /** * Print script help */ function help() { print('Create JsDoc documentation for CommonJs modules.'); print('Usage:'); print(' ringo ' + script + ' -s [sourcepath]'); print('Options:'); print(parser.help()); return; }; var script = args.shift(); var parser = new Parser(); parser.addOption('s', 'source', 'repository', 'Path to repository'); parser.addOption('d', 'directory', 'directory', 'Directory for output files (default: "out")'); parser.addOption('n', 'name', 'name', 'Name of the Repository (default: auto generated from path)'); parser.addOption('q', 'quiet', null, 'Do not output any messages.'); parser.addOption('h', 'help', null, 'Print help message and exit'); var opts = parser.parse(args); if (opts.help) { help(); return; } if (!opts.source) { throw new Error('No source specified.'); } var exportDirectory = join(opts.directory || './out/'); var repository = { path: opts.source, name: opts.name || getRepositoryName(opts.source) }; var quiet = opts.quiet || false; // check if export dir exists & is empty var dest = new Path(exportDirectory); if (dest.exists() && !dest.isDirectory()) { throw new Error(dest + ' exists but is not a directory.'); } else if (dest.isDirectory() && dest.list().length > 0) { throw new Error('Directory ' + dest + ' exists but is not empty'); } // figure out what type of doc we write, single module, multi repos // or single repo if (!isDirectory(repository.path)) { throw new Error('Invalid source specified. Must be directory.'); return; } if (!quiet) print ('Writing to ' + exportDirectory + '...'); copyStaticFiles(exportDirectory); if (!quiet) print(repository.path); writeModuleList(exportDirectory, repository); moduleList(repository.path).forEach(function(module) { if (!quiet) print('\t' + module.id); writeModuleDoc(exportDirectory, repository, module.id); }); if (!quiet) print('Finished writing to ' + exportDirectory); return; };
isDirectory: function(){ return fsbase.isDirectory(this.$path); },