Skip to content

Commit

Permalink
Removed parentDir method, updated package.json for correct dependenci…
Browse files Browse the repository at this point in the history
…es and updated readme to reflect task changes
  • Loading branch information
Alexander Vassbotn Røyne-Helgesen committed Feb 1, 2013
2 parents eaf6db2 + 6ef52f8 commit 7c9a030
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 32 deletions.
26 changes: 23 additions & 3 deletions README.md
Expand Up @@ -19,22 +19,42 @@ Inside of your grunt file, add:
```javascript
dox: {
files: {
src: ['dir/*', '*.js'],
src: ['js/lib/'],
dest: 'docs'
}
},
```

This will run all of your files through dox and dox-foundation and created a file `docs/api.html`
This will run all of your files in `lib` through dox and dox-foundation and put the output in `docs`.

**Note:** This will completely deleter and recreate the docs folder
Since the `grunt-dox` task is a multi task, you can create several tasks for dox:

```js
dox: {
libdocs :{
files: {
src: ['js/lib/'],
dest: 'docs'
}
},
sourcedocs :{
files: {
src: ['js/src/'],
dest: 'docs'
}
}
},
```

**Note:** This will completely delete and recreate the docs folder

## Contributing
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][grunt].

## Release History
* **0.1.0**: Initial release
* **0.2.0**: Pass multiple files at once. Use dox-foundation for html output
* **0.3.0**: Now relies solely on folder parsing done by dox-foundation v0.4

## License
Copyright (c) 2012 P'unk Ave
Expand Down
4 changes: 2 additions & 2 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "grunt-dox",
"description": "Dox grunt plugin",
"version": "0.3.0",
"version": "0.3.1",
"homepage": "https://github.com/mattmcmanus/grunt-dox",
"author": {
"name": "Matt McManus",
Expand Down Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"dox": "*",
"dox-foundation": "0.2.x",
"dox-foundation": "0.4.x",
"rimraf": "2.x"
},
"devDependencies": {
Expand Down
50 changes: 23 additions & 27 deletions tasks/dox.js
Expand Up @@ -9,8 +9,8 @@
var exec = require('child_process').exec,
fs = require('fs'),
path = require('path'),
rimraf = require('rimraf'),
colors = require('colors');
rimraf = require('rimraf');


module.exports = function(grunt) {

Expand All @@ -23,42 +23,38 @@ module.exports = function(grunt) {

grunt.registerMultiTask('dox', 'Generate dox output ', function() {

var files = this.filesSrc,
dest = this.data.dest;
var dir = this.filesSrc,
dest = this.data.dest,
done = this.async(),
doxCmd = '',
doxPath = path.resolve(__dirname,'../') + path.sep,
_opts = this.options();
doxPath = path.resolve(__dirname,'../'),
_opts = this.options(),
_args = [];

// Absolute path to the formatter
var formatter = [doxPath, 'node_modules', '.bin', 'dox-foundation'].join(path.sep);

// Cleanup any existing docs
rimraf.sync(dest);

if(process.platform == 'win32'){

doxCmd = 'type ' + path.normalize(files) + ' | ' + doxPath + 'node_modules' + path.sep + '.bin' + path.sep + 'dox-foundation';
} else {
_args.push('--source');
_args.push(dir);
_args.push('--target');
_args.push(dest);

doxCmd = 'cat ' + files.join(' ') + ' | ' + doxPath + 'node_modules' + path.sep + '.bin' + path.sep + 'dox-foundation';
// Set options to arguments
if(_opts.title){
_args.push('--title');
_args.push(_opts.title);
}


exec(doxCmd, {maxBuffer: 5000*1024}, function(error, stout, sterr){
grunt.file.write(dest + '/' + 'api.html', stout);

if (!error){

if(_opts.verbose){

grunt.log.writeln('Files \n' + files.join('\n').yellow + ' doxxed.');
}

grunt.log.ok(String(files.length).cyan + ' files doxxed to ' + 'api.html'.yellow);
exec(formatter + ' ' + _args.join(" "), {maxBuffer: 5000*1024}, function(error, stout, sterr){
if (error) grunt.log.error("WARN: "+ error);
if (!error) {
grunt.log.ok('Directory "' + dir + '" doxxed.');
done();
}

if (error) grunt.log.error("WARN: "+ error);

})
});
});

};

0 comments on commit 7c9a030

Please sign in to comment.