Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--exclude option does not work #395

Closed
Lodin opened this issue Jan 28, 2017 · 12 comments
Closed

--exclude option does not work #395

Lodin opened this issue Jan 28, 2017 · 12 comments
Labels
help wanted Contributions are especially encouraged

Comments

@Lodin
Copy link

Lodin commented Jan 28, 2017

Trying to generate documentation for my project I have faced with the problem that typedoc tried to generate documentation for spec.ts files I excluded in the typedoc command in my package.json script section:

{
    "docs": "typedoc --out docs --exclude **/*.spec.ts src",
}

It worked even when I moved my tests from src to the separate test directory. So I assume that specifying a directory as an argument of typedoc command does not work too.

I googled a lot, but found nothing except an old issue that did not help me at all despite I tried all of examples from there.

So I decided to look at the code, and after some investigation found that it might be a problem at this line. When I added an exclude check from here, it compiled as it should, only for non-spec files.

I use the typedoc@0.5.5, typescript@2.2.0-dev.

@ollwenjones
Copy link

Same problem here.

@mjkkirschner
Copy link

same here.

@aciccarello aciccarello added the help wanted Contributions are especially encouraged label Feb 2, 2017
@goodmind
Copy link

goodmind commented Feb 12, 2017

How to do multiple excludes? It seems that this not working:

typedoc --out docs --exclude '**/+(test|node_modules)/**/*.ts' packages/filte
ring --module commonjs

@tonysneed
Copy link

tonysneed commented Sep 11, 2017

I have this:

"docs": "typedoc --out dist/docs --target es6 --theme minimal --mode modules --exclude **/*.spec.ts src",

But my spec files are still included in the docs/modules folder . Any ideas?

Edit: It looks like typedoc is ignoring the --exclude argument and instead relying on tsconfig.json. If I put an exclude section there with a file glob, then typedoc picks it up.

@blakeembrey
Copy link
Member

@tonysneed Are you on Windows? Have you tried quoting the argument like --exclude "**/*.spec.ts"?

@tonysneed
Copy link

@blakeembrey That worked! Thanks!!

@Tokimon
Copy link
Contributor

Tokimon commented Nov 18, 2017

I have the same issue. I have tried basically everything there is to try but it still includes my test files.
I have a simple call: typedoc --out ./docs --exclude "./test/**/*.*". But it totally ignores my exclude settings and keeps including my test files. I have tried: typedoc.json, typedoc.js, typedocOptions and the CLI argument but nothing works. I have even tried to specify the path to my tsconfig (./tsconfig.json that even have the same exclude: ./test/**/*.*) but to no avail. I have no clue what I am doing wrong.

As a side note (and probably another issue); if I have a typedoc.js and run the typedoc command it simply opens my typedoc.js file and stops running.

OS: Windows
Typedoc version: 0.9.0

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 5, 2017

If anyone can provide a repo that can reproduce this issue it would help greatly. As far as I can tell the exclude option works correctly so long as the minimatch glob is set correctly.

A few things to remember:

  1. Always start with **/, the pattern will not match anything if you fail to do this since Typedoc passes the full path of files to Minimatch.
  2. Remember to quote your globs - your shell may be expanding them.

If you aren't sure what will be excluded, I've set up a simple RequireBin demo to demonstrate which patterns do what.

Examples:

  1. Ignore node_modules, tests folder, **/{test,node_modules}/**/*.ts
  2. Ignore node_modules, .spec.ts files, **/{node_modules/**/*,*.spec}.ts
  3. Ignore test files **/.{spec,test}.ts

Edit: December 2018 - The above advice regarding absolute paths will no longer be valid with the next release of TypeDoc. The exclude option has been updated to use the relative path to process.cwd().

@Tokimon
Copy link
Contributor

Tokimon commented Dec 6, 2017

Isn't having to add the **/ in the beginning of your expression a bit atypical? Usually the expression is joined with cwd when using other APIs (Like TypeScript). But maybe there is some reason for doing it like this I have missed. However this confusion seems to be the root of the confusion I think.

Personally I finally dug into your code a found out that I had to add the **/ to the beginning of my expression for it to work. But then it also works great. But it was confusing. Maybe it could be an idea to add it as a comment in the docs?

@dupski
Copy link

dupski commented May 13, 2018

For people having problems with multiple excludes, I got it working with 0.11 using the --options argument and a JS config file.

See #170 (comment)

@balupton
Copy link

Seems there are two issues here:

  1. User error of blobs being interpreted by the shell, instead of by typedoc, which is caused by not wrapping the exclude value in a string.

  2. The request to support multiple --exclude arguments.

For 2, I've created #905 to continue it.

For 1, seems like it (and thus this issue) can be closed.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 31, 2018

Closing this as the original issue is handled by #896 and later issues have been resolved or split into other issues.

@Gerrit0 Gerrit0 closed this as completed Dec 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Contributions are especially encouraged
Projects
None yet
Development

No branches or pull requests