Skip to content

Commit 8a1a307

Browse files
committed
v1
1 parent 906a386 commit 8a1a307

File tree

13 files changed

+383
-368
lines changed

13 files changed

+383
-368
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ lib-cov
66
*.out
77
*.pid
88
*.gz
9+
/node_modules/
10+
911

1012
pids
1113
logs

LICENSE-MIT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2012 Matt McManus
1+
Copyright (c) 2013 Francois-Guillaume Ribreau
22

33
Permission is hereby granted, free of charge, to any person
44
obtaining a copy of this software and associated documentation

README.md

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# dox-foundation
1+
# doxx
22

3-
Use [dox](https://github.com/visionmedia/dox) to automatically generate beautiful html documentation.
3+
Use [dox](https://github.com/visionmedia/dox) to automatically generate beautiful html documentation. Doxx is a total refactoring of [dox-foundation](https://github.com/punkave/dox-foundation/).
44

5-
Outputted HTML is based on templates and css from [ZURB's Foundation](http://foundation.zurb.com/) and syntax highlighting is done by [Prism.js](http://prismjs.com/).
5+
Outputted HTML is by default based on templates and css from [ZURB's Foundation](http://foundation.zurb.com/) and syntax highlighting is done by [Prism.js](http://prismjs.com/).
66

77
## Installation
8-
Install the module with: `npm install dox-foundation -g`
8+
Install the module with: `npm install doxx -g`
99

1010
## Documentation
1111
```
12-
$ dox-foundation --help
12+
$ doxx --help
1313
14-
Usage: dox-foundation [options]
14+
Usage: doxx [options]
1515
1616
Options:
1717
@@ -27,31 +27,19 @@ $ dox-foundation --help
2727
2828
Examples:
2929
30-
# stdin
31-
$ dox-foundation > myfile.html
32-
33-
# operates over stdio
34-
$ dox-foundation < myfile.js > myfile.html
35-
3630
# parse a whole folder
37-
$ dox-foundation --source lib --target docs
31+
$ doxx --source lib --target docs
3832
```
3933

4034
## Contributing
4135
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt](https://github.com/cowboy/grunt).
4236

4337
## Release History
44-
* *0.0.1* - Initial release
45-
* *0.2.0* - Readable output
46-
* *0.3.0* - Support for folder parsing
47-
* *0.4.0* - Improved project navigation, major refactor of folder code
48-
49-
## Thanks & Contributors
50-
51-
* Thanks to [dox-basic](https://github.com/jepso/dox-basic) for the inspiration and much of the original code.
52-
* [@sdepold](https://github.com/sdepold)
53-
* [@fgribreau](https://twitter.com/fgribreau)
38+
* *0.0.1* - (dox-foundation) Initial release
39+
* *0.2.0* - (dox-foundation) Readable output
40+
* *0.3.0* - (dox-foundation) Support for folder parsing
41+
* *0.4.0* - (dox-foundation) Improved project navigation, major refactor of folder code
42+
* *0.5.0* - Initial release of doxx
5443

5544
## License
56-
Copyright (c) 2012 P'unk Avenue
57-
Licensed under the MIT license.
45+
Copyright (c) 2013 Francois-Guillaume Ribreau

bin/dox-foundation

Lines changed: 0 additions & 104 deletions
This file was deleted.

bin/doxx

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env node
2+
3+
var program = require('commander'),
4+
fs = require('fs'),
5+
path = require('path'),
6+
_ = require('lodash'),
7+
8+
dir = require('../lib/dir'),
9+
parse = require('../lib/parser'),
10+
compile = require('../lib/compile'),
11+
symbols = require('../lib/symbols'),
12+
13+
version = require('../package').version;
14+
15+
/**
16+
* Options & Defaults
17+
*/
18+
var ignoredDirs = 'test,public,static,views,templates';
19+
20+
program
21+
.version(version)
22+
// .option('-r, --raw', 'output \'raw\' comments, leaving the markdown intact')
23+
.option('-d, --debug', 'output parsed comments for debugging')
24+
.option('-t, --title <string>', 'The title for the page produced')
25+
.option('-s, --source <source>', 'The folder which should get parsed')
26+
.option('-i, --ignore <directories>', 'Comma seperated list of directories to ignore. Default: ' + ignoredDirs)
27+
.option('-T, --target <target>', 'The folder which will contain the results. Default: <process.cwd()>/docs')
28+
.option('--template <jade template>', 'The jade template file to use');
29+
30+
function showHelp(){
31+
console.log(' Examples:\n');
32+
console.log(' # parse a whole folder');
33+
console.log(' $ doxx --source ./lib --target ./docs');
34+
}
35+
36+
// examples
37+
program.on('--help', showHelp);
38+
39+
// parse argv
40+
program.parse(process.argv);
41+
42+
if(program.template){
43+
compile.tpl = fs.readFileSync(program.template).toString();
44+
}
45+
46+
if (!program.source) {
47+
console.error(" Error you must define a source\n");
48+
return showHelp();
49+
}
50+
51+
var target = path.resolve(process.cwd(), program.target) || process.cwd() + '/docs',
52+
source = path.resolve(process.cwd(), program.source),
53+
ignore = program.ignore || ignoredDirs;
54+
55+
// Cleanup and turn into an array the ignoredDirs
56+
ignore = ignore.trim().replace(' ','').split(',');
57+
58+
// Find, cleanup and validate all potential files
59+
var files = dir.collectFiles(source, ignore);
60+
61+
dir.createTargetFolders(target, files);
62+
63+
// Parse each file
64+
files = files.map(function(file) {
65+
var dox = parse(path.join(source, file), {});
66+
return {
67+
name: file,
68+
dox: dox,
69+
symbols: symbols(dox)
70+
};
71+
});
72+
73+
// Compute all symboles
74+
var allSymbols = files.reduce(function(m, a, b){
75+
m = (a.symbols || []).concat(b.symbols || []);
76+
return m;
77+
}, []);
78+
79+
// Render and write each file
80+
files.forEach(function(file){
81+
82+
var options = _.extend({}, file, {
83+
title: program.title || require(process.cwd() + '/package').name,
84+
allSymbols: allSymbols
85+
});
86+
87+
var compiled = compile(options);
88+
fs.writeFileSync(path.join(target, file.name+".html"), compiled);
89+
});

grunt.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ module.exports = function(grunt) {
3232

3333
// Default task.
3434
grunt.registerTask('default', 'lint');
35-
36-
};
35+
};

lib/compile.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var jade = require('jade'),
2+
fs = require('fs'),
3+
path = require('path');
4+
_ = require('lodash');
5+
6+
/**
7+
* Compile
8+
* @param {Object} options
9+
* @return {String}
10+
*/
11+
function compile(options){
12+
return jade.compile(compile.tpl,{})(options);
13+
}
14+
15+
/**
16+
* Template used to produce the documentation
17+
*/
18+
compile.tpl = fs.readFileSync(path.resolve(__dirname,'../views/template.jade')).toString();
19+
20+
module.exports = compile;

lib/dir.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
var fs = require('fs'),
2+
path = require('path'),
3+
path = require('path'),
4+
mkdirp = require('mkdirp'),
5+
findit = require('findit'),
6+
_ = require('lodash');
7+
8+
/*
9+
* Create an array of all the right files in the source dir
10+
*/
11+
exports.collectFiles = function(source, options, callback) {
12+
var dirtyFiles = findit.findSync(source), // tee hee!
13+
ignore = options.ignore || [],
14+
files = [];
15+
16+
dirtyFiles.forEach(function(file){
17+
file = path.relative(source, file);
18+
19+
var doNotIgnore = _.all(ignore, function(d){
20+
// return true if no part of the path is in the ignore list
21+
return (file.indexOf(d) === -1);
22+
});
23+
24+
if ((file.substr(-2) === 'js') && doNotIgnore) {
25+
files.push(file);
26+
}
27+
});
28+
29+
return files;
30+
};
31+
32+
/*
33+
* Make sure the folder structure in target mirrors source
34+
*/
35+
exports.createTargetFolders = function(target, files) {
36+
var folders = [];
37+
38+
files.forEach(function(file){
39+
var folder = file.substr(0, file.lastIndexOf('/'));
40+
41+
if ((folder !== '') && (folders.indexOf(folder) === -1)) {
42+
folders.push(folder);
43+
mkdirp.sync(target + '/' + folder);
44+
}
45+
});
46+
};

0 commit comments

Comments
 (0)