简体   繁体   English

TypeDoc如何定义externalPattern?

[英]TypeDoc how to define externalPattern?

I'm working on app with grunt and typedoc. 我正在使用grunt和typedoc开发应用程序。

I need to prepare documentation using TypeDoc but I have a problem with one scenario. 我需要使用TypeDoc准备文档,但是我遇到一种情况的问题。

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. 我无法将这些文件放入exclude部分,因为这些文件与另一个文件有关。 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 . 如果我试图排除它(将这些文件放入exclude部分), cannot find to xxx into yyy.ts出现错误-类似于cannot find to xxx into yyy.ts其中xxx是我的排除元素,而yyy是与xxx相关的文件。 Those related files are neccessary on this documentation so I can't exclude those too. 这些相关文件在本文档中是必需的,因此我也不能排除这些文件。

I read into TypeDoc documentation about excludeExternals . 我读了有关ExclusionExternals的 TypeDoc文档。 So I thought that if I set up this boolean as true then I can to define externalPattern to exclude my external files. 因此,我认为如果将此布尔值设置为true,则可以定义externalPattern以排除我的外部文件。 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): 这是我在gruntfile.js中的typedoc配置(不包括excludeExternals选项):

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 ... 这是我必须排除的外部文件列表:A.ts,B.ts,C.ts,D.ts ...

And this is my typedoc config into gruntfile.js (with excludeExternals options): 这是我在gruntfile.js中的typedoc配置(带有excludeExternals选项):

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. 我有没有A.ts文件的文档。 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. ). 因此,现在我需要放入一些文件,因此我尝试将诸如**/*/(A|B|C|D).ts放在externalPattern但没有成功(因为在重新编译文档期间出现错误: 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排除外部文件,则应该编写类似以下的模式:

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. 对我有用的是来自gruntfile中正则表达式主题的评论

According to this comment , the right syntax would be **/*/+(A|B|C|D).ts . 根据此评论 ,正确的语法为**/*/+(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"'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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