yuidoc.json ignorePaths option does not work #5

Closed
guozheng opened this Issue May 9, 2012 · 10 comments

Projects

None yet

6 participants

@guozheng
guozheng commented May 9, 2012

It seems like there is a bug in validatePaths function in lib/util.js:

if (ignore) {
if (!(ignore instanceof Array)) {
ignore = [ignore];
}
var p = [];
paths.forEach(function(v) {
ignore.forEach(function(i) {
if (v.indexOf(i) === -1) {
p.push(v);
}
});
});
paths = p;
}

So, if ignore array contains at least two paths, for example:
paths = ['a', 'b', 'c']
ignore = ['a', 'b']
When you use the two forEach to check each element in paths, say, you check 'a' from paths against 'a', 'b' in ignore, since 'a'.indexOf('b') will give you -1, 'a' will be added to the final paths array instead of getting filters.

Instead, should do something like this:

if (ignore) {
if (!(ignore instanceof Array)) {
ignore = [ignore];
}
var p = [];
var shouldIgnore = false;
paths.forEach(function(v) {
shouldIgnore = false;
ignore.forEach(function(i) {
if (!shouldIgnore && v.indexOf(i) !== -1) {
shouldIgnore = true;
}
});
if (!shouldIgnore) {
p.push(v);
}
});
paths = p;
}

@davglass davglass was assigned May 9, 2012
@davglass davglass closed this in 1f02000 May 10, 2012
@davglass
Member

I fixed this issue, but your's is different.

ignorePaths is a test on a path coming in as an exploded shell arg telling YUIDoc to ignore that path, it does not check against a subdirectory below that path.

The exclude option (the -x option) is the one you actually want (from our email conversation):

    "exclude": "node_modules,test"

This applies at the file level when YUIDoc is actually about to parse the documentation, so it's not a path, it's a directory or filename.

@guozheng

So, basically, ignorePaths contains string to match paths that you don't want, right. So, if I know the directory names I don't want, it should work as well. Although if the same string appears on paths that I actually want, it will be mistakenly filtered out.

Is it possible to also add this -x as an option to yuidoc.json, I think this option is actually more useful?

@davglass
Member

-x === exclude in the yuidoc.json file, so the option is available like I noted above. Both of your cases work when you use the proper config option.

@guozheng

Ah, my bad. Just tried the exclude option and it works ;-) Can you please add this to the "Using YUIDoc" doc, it is not presented in the options table (I assume all the CLI options like those --xyz corresponds to one option field?).

thanks!

@davglass
Member

Done, it will be in the next build

@totty90
totty90 commented Nov 11, 2014

Still doesn't work

@okuryu
Member
okuryu commented Nov 11, 2014

@totty90 Please file an issue with a reproducible example.

@przmak
przmak commented Oct 15, 2015
{
"options": {
    "ignorePaths": [
      "./app/vendor/",
    ],
    "paths": [
      "./app/",
    ],
 }
}

Can't be more simple... .this doesn't work ofc :)

@okuryu
Member
okuryu commented Nov 9, 2015

@przmak Try exclude option to remove directory.

@gokatz
gokatz commented May 25, 2016

that works for me @okuryu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment