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

How does exclude work ? #170

Closed
ocombe opened this Issue Jan 1, 2016 · 19 comments

Comments

Projects
None yet
@ocombe

ocombe commented Jan 1, 2016

Hello,
I use the command line: typedoc --options typedoc.json --exclude *.spec.ts src/app/

But it generates documentation for my file "src/app/app.spec.ts".
Shouldn't it be excluded ?

@enanox

This comment has been minimized.

enanox commented Jan 21, 2016

Hi, I'm on the same boat as @ocombe.
Is the --exclude pattern a RegExp, or a pattern similar those used in Grunt/Gulp, such as directory/**/*.ext?

@EMarginy

This comment has been minimized.

EMarginy commented Jan 22, 2016

Hi, got the same problem with exclude trying this: typedoc --media modules/ --exclude modules/**/tests/*

@dsebastien

This comment has been minimized.

dsebastien commented Feb 4, 2016

Same issue here. Also how to configure multiple exclusions?

@caseyhoward

This comment has been minimized.

Contributor

caseyhoward commented Mar 21, 2016

I'm having the exact same issue. I want to ignore spec files. "" is not helpful at all without an example of what a "pattern" is.

@caseyhoward

This comment has been minimized.

Contributor

caseyhoward commented Mar 21, 2016

@ocombe I think the following should work:

typedoc --options typedoc.json --exclude **/*.spec.ts src/app/

typedoc uses Minimatch for globs. I believe *.spec.ts will only look for files in the current directory.

@hverlin

This comment has been minimized.

hverlin commented Jun 28, 2016

Hi, you can use for example: "exclude": "**/*+(e2e|spec|index).ts" if you want to have multiple exclusions.

The syntax seems to be +(pattern-list).

@blakeembrey

This comment has been minimized.

Member

blakeembrey commented Jun 28, 2016

Seen here (

exclude = new Minimatch(this.exclude);
), the pattern is a standard minimatch (glob) pattern in Node.js. The existing comments by @caseyhoward should work for you (make sure you quote so it's not automatically expanded by your shell).

@daotoad

This comment has been minimized.

daotoad commented Jun 30, 2016

Changing the docs to say that patterns are "standard" minimatch patterns would be very helpful.

@blakeembrey

This comment has been minimized.

Member

blakeembrey commented Jun 30, 2016

You are welcome to submit a PR improving the docs.

@YouriT

This comment has been minimized.

YouriT commented Aug 16, 2017

I know this has been closed but I think that what would be interesting to know in the docs is what is given to minimatch for testing.

If you pass the whole path to the file, the pattern will be different than if you are passing what comes after path/to/typescript/project/. From my understanding, you make a full resolution and give it to the minimatch pattern but correct me if I'm wrong.

@Zeioth

This comment has been minimized.

Zeioth commented Aug 30, 2017

Then there is no way to exclude an entire directory?

@YouriT

This comment has been minimized.

YouriT commented Aug 30, 2017

@Zeioth yup you can via the pattern.
Example: my tree is like this:

| src
  - File1.ts
  - File2.ts
  | tests
    - Test1.ts
    - Test2.ts

To exclude the tests folder under src you would do (from the working directory): typedoc src --out docs --mode modules --exclude \"**/tests/*.ts\"

@assaf-cream

This comment has been minimized.

assaf-cream commented Aug 31, 2017

I managed to exclude several folders,
The syntax was "**/{folder1,folder2}/*.ts"

HTH

@paynoattn

This comment has been minimized.

paynoattn commented Dec 28, 2017

For whatever reason this only worked for me when I escaped the path like so:
typedoc --out ./docs ./src --exclude \"**/*+(index|.spec|.e2e).ts\". Otherwise it would throw an error.

@dupski

This comment has been minimized.

dupski commented May 13, 2018

Just to add some info to this, if you use typedoc with a javascript config file
(e.g. typedoc --options ./typedoc.js ./src), then you can set an array of exclude paths in the configuration:

typedoc.js:

module.exports = {
    out: './docs/dist/api/',

    readme: 'none',
    includes: './',
    exclude: [
        '**/__tests__/**/*',
        '**/__test_utils__/**/*',
        '**/__fixtures__/**/*',
        '**/testsuite/**/*'
    ],

    mode: 'file',
    excludeExternals: true,
    excludeNotExported: true,
    excludePrivate: true
};
@carlos-algms

This comment has been minimized.

carlos-algms commented Jul 2, 2018

This exclude is not working:

module.exports = {
  mode: 'file',
  out: 'dist/typedoc',
  theme: 'default',
  ignoreCompilerErrors: true,
  excludePrivate: true,
  excludeNotExported: 'true',
  excludeExternals: true,
  target: 'ES5',
  moduleResolution: 'node',
  preserveConstEnums: 'true',
  stripInternal: 'true',
  suppressExcessPropertyErrors: 'true',
  suppressImplicitAnyIndexErrors: 'true',
  module: 'commonjs',
  readme: 'README.md',
  exclude: [
    '**/*.spec.ts',
    '**/*.module.ts',
  ],
};

I don't want to render *.module.ts files because they just import and export things, they don't add nothing to the documentation.

Why the exclude patter is not working?

@Hoten

This comment has been minimized.

Hoten commented Aug 2, 2018

A lot of users in this thread are actually using shell globs.

I'm finding this to not work (shell does not expand the glob with single quotes): --exclude '**/*.d.ts'

Using the shell glob doesn't work either: --exclude **/*.d.ts

If glob patterns are meant to work, it's broken.

@aciccarello

This comment has been minimized.

Collaborator

aciccarello commented Aug 2, 2018

@Hoten it actually supports Minimatch globs. Declarations should be handled differently though. There is the --includeDeclarations flag so it already shouldn't be including those if you don't set the flag. You might want to open another issue with a reproduction if that is not working as expected.

@Hoten

This comment has been minimized.

Hoten commented Aug 2, 2018

Thanks @aciccarello. Yeah, some of us are having issues with declaration files. #820 is the relevant issue.

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