Skip to content

Commit

Permalink
0.1.10 Add -e exclude option for Files / Directories.
Browse files Browse the repository at this point in the history
  • Loading branch information
rottmann committed May 16, 2013
1 parent 2433545 commit 9d428dd
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 18 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.idea/
.settings/
.project
node_modules/
tmp/
doc/
doc/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Creates from input files a documentation in path `doc/`.

## Changelog

* `0.1.10` Add `-e` exclude option for Files / Directories, example `apidoc -e node_modules/`.
* `0.1.10` Fix check for a valid title in Template (Ben S. Stahlhood II https://github.com/apidoc/apidoc/pull/7)
* `0.1.9` Fix for whitespace before comment block (Brandon Hamilton https://github.com/apidoc/apidoc/pull/2)
* `0.1.8` Change templates, enable navigation scroll.
* `0.1.7` Add @apiIgnore. Update grunt Modules.
Expand Down
7 changes: 7 additions & 0 deletions bin/apidoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ var argv = optimist
describe: "RegEx-Filter to select files that should be parsed (many -f can be used)."
})

.option("e", {
alias: "exclude-filters",
"default": "",
describe: "RegEx-Filter to select files / dirs that should not be parsed (many -e can be used).",
})

.option("i", {
alias: "input",
"default": "./",
Expand Down Expand Up @@ -111,6 +117,7 @@ function transformFilters(filters)
} // transformFilters

var defaults = {
excludeFilters: argv["exclude-filters"],
includeFilters: argv["file-filters"],
src: argv["input"],
dest: argv["output"],
Expand Down
1 change: 1 addition & 0 deletions lib/apidoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var colors = require("colors");

// Options
var _defaultOptions = {
excludeFilters: [],
includeFilters: [ ".*\\.js$" ],

src: path.join(__dirname, "../example/"),
Expand Down
41 changes: 30 additions & 11 deletions lib/utils/find_files.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,56 @@
var wrench = require("wrench");

/**
* Sucht rekursiv nach Dateien im Source-Verzeichnis und filtert die gewünschten Dateien aus.
* Search files recursivly and filter by include / exlude filters.
*
* @param {Object[]} options Programmoptionen.
* @param {String} options.src Pfad zu den Quelldateien.
* @param {String[]} options.includeFilters Filterregeln zu verwendende Dateien.
* @param {Object[]} options Options.
* @param {String} options.src Path to source-files.
* @param {String[]} [options.excludeFilters] Exclude Filters.
* @param {String[]} options.includeFilters Include Filters.
* @returns {String[]}
*/
function findFiles(options)
{
var files = [];
try {
// Dateien rekursiv finden
// Find Files
files = wrench.readdirSyncRecursive(options.src);

// RegExp-Filterregeln erstellen
var regExpFilters = [];
// Create RegExp Include Filter List
var regExpIncludeFilters = [];
filters = options.includeFilters;
if(typeof(filters) === "string") filters = [ filters ];
filters.forEach(function(filter) {
regExpFilters.push( new RegExp(filter) );
if(filter.length > 0) regExpIncludeFilters.push( new RegExp(filter) );
}); // forEach

// Filtern mit RegExp-Filterregeln
var length = regExpFilters.length;
// RegExp Include Filter
var length = regExpIncludeFilters.length;
files = files.filter(function(filename) {
for(var i = 0; i < length; i += 1)
{
if(regExpFilters[i].test(filename)) return 1;
if(regExpIncludeFilters[i].test(filename)) return 1;
} // for
return 0;
}); // files.filter

// Create RegExp Exclude Filter List
var regExpExcludeFilters = [];
filters = options.excludeFilters;
if(typeof(filters) === "string") filters = [ filters ];
filters.forEach(function(filter) {
if(filter.length > 0) regExpExcludeFilters.push( new RegExp(filter) );
}); // forEach

// RegExp Exclude Filter
length = regExpExcludeFilters.length;
files = files.filter(function(filename) {
for(var i = 0; i < length; i += 1)
{
if(regExpExcludeFilters[i].test(filename)) return 0;
} // for
return 1;
}); // files.filter
} // try
finally
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apidoc",
"version": "0.1.9",
"version": "0.1.10",
"description": "RESTful web API Documentation Generator",
"author": "Peter Rottmann <[email protected]>",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/api_project.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
define({
"name": "apidoc",
"version": "0.1.9",
"version": "0.1.10",
"description": "RESTful web API Documentation Generator",
"apidoc": "",
"generator": {
"version": "0.1.9",
"version": "0.1.10",
"time": "2013-04-12T16:50:18.630Z"
}
});
4 changes: 2 additions & 2 deletions test/fixtures/api_project.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "apidoc",
"version": "0.1.9",
"version": "0.1.10",
"description": "RESTful web API Documentation Generator",
"apidoc": "",
"generator": {
"version": "0.1.9",
"version": "0.1.10",
"time": "2013-04-12T16:50:18.630Z"
}
}

0 comments on commit 9d428dd

Please sign in to comment.