Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for @requires and @member #36

Merged
merged 8 commits into from
Aug 18, 2014
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions jsdox.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,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 @@ -182,6 +184,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 @@ -197,6 +202,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 @@ -281,7 +292,6 @@ function generateForDir(filename, destination, 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
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
14 changes: 9 additions & 5 deletions templates/function.mustache
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{#moduleName}}{{moduleName}}.{{/moduleName}}{{#className}}{{className}}.{{/className}}{{name}}({{#paramsString}}{{paramsString}}{{/paramsString}}) {{#version}}{{version}}{{/version}}
{{#className}}{{className}}.{{/className}}{{name}} {{#version}}{{version}}{{/version}}
-----------------------------
{{#description}}
{{{description}}}
Expand All @@ -10,16 +10,20 @@ Deprecated: {{{deprecated}}}
{{/deprecated}}
{{#hasParams}}
**Parameters**

{{/hasParams}}
```
{{#params}}
**{{name}}**: {{#typesString}}{{typesString}}, {{/typesString}}{{#description}}{{{description}}}{{/description}}
{{name}}: {{#typesString}}{{typesString}}, {{/typesString}}{{#description}}{{{description}}}{{/description}}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrjoelkemp looks like we need that way to customize the templates rather sooner than later.

{{/params}}
```
{{/hasParams}}
{{#fires}}
**Fires**: {{.}}

{{/fires}}
{{#returns}}
**Returns**: {{#typesString}}{{typesString}}, {{/typesString}}{{#description}}{{{description}}}{{/description}}
**Returns**: {{#typesString}}{{typesString}}{{/typesString}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason to remove the description?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not removed, it's useful:

{{#returns}}
Returns: {{#typesString}}{{typesString}}{{/typesString}}

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

{{/returns}}

```
{{#description}}{{{description}}}{{/description}}
```
{{/returns}}