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

How does exclude work ? #170

Closed
ocombe opened this issue Jan 1, 2016 · 23 comments
Closed

How does exclude work ? #170

ocombe opened this issue Jan 1, 2016 · 23 comments
Labels
question Question about functionality

Comments

@ocombe
Copy link

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
Copy link

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
Copy link

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

@dsebastien
Copy link

Same issue here. Also how to configure multiple exclusions?

@caseyhoward
Copy link
Contributor

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
Copy link
Contributor

@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
Copy link

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
Copy link
Member

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
Copy link

daotoad commented Jun 30, 2016

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

@blakeembrey
Copy link
Member

You are welcome to submit a PR improving the docs.

@YouriT
Copy link

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
Copy link

Zeioth commented Aug 30, 2017

Then there is no way to exclude an entire directory?

@YouriT
Copy link

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
Copy link

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

HTH

@paynoattn
Copy link

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
Copy link

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
Copy link

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?

@connorjclark
Copy link

connorjclark 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
Copy link
Collaborator

@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.

@connorjclark
Copy link

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

@vipetrul
Copy link

It is also possible to specify multiple excludes in cli by specifying several exclude arguments:
typedoc --out docs src --ignoreCompilerErrors --exclude **/*__*/** --exclude **/*.test.tsx

@chetana286
Copy link

is it possible to display specific comments only using typedoc?
I dont want to document variables, functions, classes, just want to display specific comment. Is that possible using Typedoc

@SalahAdDin
Copy link

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?

It is not working at all.

@receptiryaki
Copy link

you can use it like this,

"exclude": "**/+(yourFile.ts|yourAnotherFile.ts|yetAnotherFile.ts)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about functionality
Projects
None yet
Development

No branches or pull requests