简体   繁体   中英

TypeDoc how to define externalPattern?

I'm working on app with grunt and typedoc.

I need to prepare documentation using TypeDoc but I have a problem with one scenario.

I have to exclude a few files from documentation which are externals libs. I can't put those files into exclude section because those files are relating with another. If I tried to exclude it (by put those files into exclude section) I had a errors - something like cannot find to xxx into yyy.ts - where xxx is my excluded element and yyy is related file with xxx . Those related files are neccessary on this documentation so I can't exclude those too.

I read into TypeDoc documentation about excludeExternals . So I thought that if I set up this boolean as true then I can to define externalPattern to exclude my external files. It's works but only if I put the name of one file - no more.

Do You know how to do it?

It is my typedoc config into gruntfile.js (without excludeExternals options):

typedoc: {
    build: {
        options: {
            module: 'commonjs',
            out: '../Documentation/',
            name: 'MyApp',
            target: 'es5',
            exclude: [
                'node_modules',
                '**/*.d.ts'
            ],
            excludePrivate: true,
            mode: 'file'
        },
        src: [
            ...some source...
        ]
    }
} 

This is list of external files which I have to exclude: A.ts, B.ts, C.ts, D.ts ...

And this is my typedoc config into gruntfile.js (with excludeExternals options):

typedoc: {
    build: {
        options: {
            module: 'commonjs',
            out: '../Documentation/',
            name: 'MyApp',
            target: 'es5',
            exclude: [
                'node_modules',
                '**/*.d.ts'
            ],
            excludeExternals: true,
            externalPattern: '**/*/A.ts',
            excludePrivate: true,
            mode: 'file'
        },
        src: [
            ...some source...
        ]
    }
} 

This config is working well. I have got a documentation without A.ts file. So now I need to put a few files, so I tried to put on externalPattern something like: **/*/(A|B|C|D).ts but without success (because during recompiling of documentation I had error: Process terminated with code 3. 'B' is not recognized as an internal or external command, operable program or batch file. ).

Any ideas?

I found the solution. If I want to exclude externals files using externalPattern I should to write pattern something like that:

externalPattern: "**/*/{A,B,C,D}.ts"

{ } = allows for a comma-separated list of "or" expressions

, = or

Useful for me was this comment from topic about regex in gruntfile.

According to this comment , the right syntax would be **/*/+(A|B|C|D).ts . Also, it looks like you are running into a problem with your shell trying to interpret the pipe characters, so try adding double quotes around the whole thing:

externalPattern: '"**/*/+(A|B|C|D).ts"'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM