diff --git a/fixtures/test5.js b/fixtures/test5.js new file mode 100644 index 0000000..2e5980f --- /dev/null +++ b/fixtures/test5.js @@ -0,0 +1,42 @@ +/** + @overview This sample will output module requires and members. + @license MIT + @version 0.0.1 + @author lemori +*/ + +/** + init system configuration + @module base + @requires './model/settings' +*/ +var QRCODE_DIR, ROOT, UPLOAD_DIR, init, path, settings; + +path = require('path'); + +settings = require('./model/settings'); + +/** @member */ + +ROOT = '.'; + +/** @member */ + +UPLOAD_DIR = 'upload'; + +/** @member */ + +QRCODE_DIR = 'qrcode'; + + +/** + Read global config from database + @public + @function init + */ + +init = function() { + console.log('init()'); +}; + +exports.init = init; diff --git a/jsdox.js b/jsdox.js index 0f7854e..c7a2a53 100644 --- a/jsdox.js +++ b/jsdox.js @@ -103,6 +103,7 @@ function analyze(ast) { methods: [], classes: [], modules: [], + members: [], globalModule: null, globalVariables: [], description: '', @@ -110,7 +111,8 @@ function analyze(ast) { copyright: '', license: '', author: '', - version: '' + version: '', + hasMembers: false }, currentModule = null, currentClass = null, @@ -185,6 +187,9 @@ function analyze(ast) { case 'member': if (currentClass && tag.undocumented !== true) { currentClass.members.push(tag); + } else if (tag.scope === 'inner' && tag.undocumented !== true) { + result.members.push({member: tag.name}); + result.hasMembers = true; } break; case 'return': @@ -200,6 +205,12 @@ function analyze(ast) { module.functions = []; module.classes = []; module.description = tag.description; + module.requires = tag.requires || []; + module.hasRequires = !!module.requires.length; + module.requires.forEach(function(r, i) { + if (!r) { return ''; } + module.requires[i] = {req: r}; + }); result.modules.push(module); currentModule = module; break; @@ -290,7 +301,6 @@ function generateForDir(filename, destination, templateDir, cb, fileCb) { error = err; } } - if (argv.debug) { console.log(file + ' AST: ', util.inspect(result, false, 20)); console.log(file + ' Analyzed: ', util.inspect(analyze(result), false, 20)); diff --git a/sample_output/test5.md b/sample_output/test5.md new file mode 100644 index 0000000..e31ad0c --- /dev/null +++ b/sample_output/test5.md @@ -0,0 +1,32 @@ +base +=== + +init system configuration + +**Requires:** + ++ module:'./model/settings' + +**Members:** + ++ ROOT ++ UPLOAD_DIR ++ QRCODE_DIR + +--- + +base.init() +----------------------------- +Read global config from database + + + +--- + + + +**License:** MIT lemori + +**Overview:** This sample will output module requires and members. + +**Version:** 0.0.1 diff --git a/templates/file.mustache b/templates/file.mustache index c56eeeb..7adfe48 100644 --- a/templates/file.mustache +++ b/templates/file.mustache @@ -6,6 +6,24 @@ {{#description}}{{{description}}}{{/description}} +{{#hasRequires}} +**Requires:** + +{{#requires}} ++ {{{req}}} +{{/requires}} +{{/hasRequires}} + +{{#hasMembers}} +**Members:** + +{{#members}} ++ {{{member}}} +{{/members}} +{{/hasMembers}} + +--- + {{#functions}} {{> function}}