Skip to content

Commit dc897b7

Browse files
committed
Merge branch 'feature/wiki'
2 parents 4632085 + 7953d17 commit dc897b7

File tree

5 files changed

+105
-22
lines changed

5 files changed

+105
-22
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,20 @@ $ npm install doxdox -g
2121
2222
Options:
2323
24-
-h, --help Display this help message.
25-
-v, --version Display the current installed version.
26-
-t, --title Sets title.
27-
-d, --description Sets description.
28-
-l, --layout Template to render the documentation with.
29-
-p, --package Sets location of package.json file.
30-
-o, --output File to save documentation to. Defaults to stdout.
24+
-h, --help Display this help message.
25+
-v, --version Display the current installed version.
26+
-t, --title Sets title.
27+
-d, --description Sets description.
28+
-l, --layout Template to render the documentation with.
29+
-p, --package Sets location of package.json file.
30+
-o, --output File to save documentation to. Defaults to stdout.
3131
3232
Available Layouts:
3333
3434
- Bootstrap (default) (http://getbootstrap.com/)
3535
- Markdown (http://daringfireball.net/projects/markdown/)
3636
- Dash (http://kapeli.com/docsets/)
37+
- Wiki (https://help.github.com/articles/about-github-wikis/)
3738
```
3839

3940
## Examples:

bin/doxdox

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,19 @@ while (args.length) {
7575
process.stdout.write('\n');
7676
process.stdout.write(chalk.blue(' Usage:') + ' doxdox <path> [options]' + '\n\n');
7777
process.stdout.write(' Options:' + '\n\n');
78-
process.stdout.write(chalk.yellow(' -h, --help') + '\t\tDisplay this help message.' + '\n');
79-
process.stdout.write(chalk.yellow(' -v, --version') + '\t\tDisplay the current installed version.' + '\n');
80-
process.stdout.write(chalk.yellow(' -t, --title') + '\t\tSets title.' + '\n');
81-
process.stdout.write(chalk.yellow(' -d, --description') + '\tSets description.' + '\n');
82-
process.stdout.write(chalk.yellow(' -l, --layout') + '\t\tTemplate to render the documentation with.' + '\n');
83-
process.stdout.write(chalk.yellow(' -p, --package') + '\t\tSets location of package.json file.' + '\n');
84-
process.stdout.write(chalk.yellow(' -o, --output') + '\t\tFile to save documentation to. Defaults to stdout.' + '\n');
78+
process.stdout.write(chalk.yellow(' -h, --help') + '\t\t\tDisplay this help message.' + '\n');
79+
process.stdout.write(chalk.yellow(' -v, --version') + '\t\t\tDisplay the current installed version.' + '\n');
80+
process.stdout.write(chalk.yellow(' -t, --title') + '\t\t\tSets title.' + '\n');
81+
process.stdout.write(chalk.yellow(' -d, --description') + '\t\tSets description.' + '\n');
82+
process.stdout.write(chalk.yellow(' -l, --layout') + '\t\t\tTemplate to render the documentation with.' + '\n');
83+
process.stdout.write(chalk.yellow(' -p, --package') + '\t\t\tSets location of package.json file.' + '\n');
84+
process.stdout.write(chalk.yellow(' -o, --output') + '\t\t\tFile to save documentation to. Defaults to stdout.' + '\n');
8585
process.stdout.write('\n');
8686
process.stdout.write(' Available Layouts:' + '\n\n');
87-
process.stdout.write(' - Bootstrap (default)\t (http://getbootstrap.com/)' + '\n');
88-
process.stdout.write(' - Markdown\t\t (http://daringfireball.net/projects/markdown/)' + '\n');
89-
process.stdout.write(' - Dash\t\t (http://kapeli.com/docsets/)' + '\n');
87+
process.stdout.write(' - Bootstrap (default)\t\t(http://getbootstrap.com/)' + '\n');
88+
process.stdout.write(' - Markdown\t\t\t(http://daringfireball.net/projects/markdown/)' + '\n');
89+
process.stdout.write(' - Dash\t\t\t(http://kapeli.com/docsets/)' + '\n');
90+
process.stdout.write(' - Wiki\t\t\t(https://help.github.com/articles/about-github-wikis/)' + '\n');
9091
process.stdout.write('\n');
9192
process.kill();
9293

lib/doxdox.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ var fs = require('fs'),
99
module.exports.templates = {
1010
bootstrap: require('../templates/bootstrap.hbs'),
1111
markdown: require('../templates/markdown.hbs'),
12-
dash: utils.buildDashDocSet
12+
dash: utils.buildDashDocSet,
13+
wiki: utils.buildWiki
1314
};
1415

1516
module.exports.parseInput = function (input, config, pkg) {
@@ -76,13 +77,13 @@ module.exports.parseScripts = function (scripts, config, pkg) {
7677

7778
});
7879

79-
if (fs.existsSync(path.resolve(config.layout))) {
80+
if (exports.templates[config.layout.toLowerCase()]) {
8081

81-
template = require(path.resolve(config.layout));
82+
template = exports.templates[config.layout.toLowerCase()];
8283

83-
} else if (exports.templates[config.layout.toLowerCase()]) {
84+
} else if (fs.existsSync(path.resolve(config.layout))) {
8485

85-
template = exports.templates[config.layout.toLowerCase()];
86+
template = require(path.resolve(config.layout));
8687

8788
}
8889

lib/utils.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,35 @@ module.exports.buildDashDocSet = function (input) {
9898

9999
};
100100

101+
102+
module.exports.buildWiki = function (input) {
103+
104+
return new Promise(function (resolve) {
105+
106+
var zip = new admzip(),
107+
template = require('../templates/wiki/methods.hbs');
108+
109+
input.uid = module.exports.formatStringForUID(input.title);
110+
111+
input.files.forEach(function (file) {
112+
113+
file.methods.forEach(function (method) {
114+
115+
zip.addFile(
116+
file.name + '/' + method.name + '.md',
117+
template(method)
118+
);
119+
120+
});
121+
122+
});
123+
124+
resolve(zip.toBuffer());
125+
126+
});
127+
128+
};
129+
101130
module.exports.findPackagePath = function (input) {
102131

103132
var pkg,

templates/wiki/methods.hbs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#{{name}}({{params}}) {{#if isPrivate}} _private method_{{/if}}
2+
3+
{{{description}}}
4+
5+
{{{body}}}
6+
7+
{{#if tags.param}}
8+
9+
##Parameters
10+
11+
{{#each tags.param}}
12+
- **{{name}}** {{#each types}}`{{.}}` {{/each}} {{#if isOptional}}_Optional_{{/if}} {{{description}}}
13+
{{/each}}
14+
15+
{{/if}}
16+
17+
{{#if tags.property}}
18+
19+
##Properties
20+
21+
{{#each tags.property}}
22+
- **{{name}}** {{#each types}}`{{.}}` {{/each}} {{#if isOptional}}_Optional_{{/if}} {{{description}}}
23+
{{/each}}
24+
25+
{{/if}}
26+
27+
{{#if tags.example}}
28+
29+
##Examples
30+
31+
{{#each tags.example}}
32+
```javascript
33+
{{{.}}}
34+
```
35+
{{/each}}
36+
37+
{{/if}}
38+
39+
##Returns
40+
41+
{{#if tags.return}}
42+
43+
{{#each tags.return}}
44+
- {{#each types}}`{{.}}` {{/each}} {{#if isOptional}}_Optional_{{/if}} {{{description}}}
45+
{{/each}}
46+
47+
{{else}}
48+
49+
- `Void`
50+
51+
{{/if}}

0 commit comments

Comments
 (0)