Skip to content

Commit

Permalink
Merge pull request #36 from lemori/just_parse
Browse files Browse the repository at this point in the history
add support for @requires and @member

looks good now, and nice to have travis status too.
  • Loading branch information
psq committed Aug 18, 2014
2 parents ee5d7a3 + 3b2632f commit b449536
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 2 deletions.
42 changes: 42 additions & 0 deletions fixtures/test5.js
Original file line number Diff line number Diff line change
@@ -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;
14 changes: 12 additions & 2 deletions jsdox.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,16 @@ function analyze(ast) {
methods: [],
classes: [],
modules: [],
members: [],
globalModule: null,
globalVariables: [],
description: '',
overview: '',
copyright: '',
license: '',
author: '',
version: ''
version: '',
hasMembers: false
},
currentModule = null,
currentClass = null,
Expand Down Expand Up @@ -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':
Expand All @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
32 changes: 32 additions & 0 deletions sample_output/test5.md
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions templates/file.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@

{{#description}}{{{description}}}{{/description}}

{{#hasRequires}}
**Requires:**

{{#requires}}
+ {{{req}}}
{{/requires}}
{{/hasRequires}}

{{#hasMembers}}
**Members:**

{{#members}}
+ {{{member}}}
{{/members}}
{{/hasMembers}}

---

{{#functions}}
{{> function}}

Expand Down

0 comments on commit b449536

Please sign in to comment.