简体   繁体   English

如何从 tsdoc / typedoc 中正确排除测试文件

[英]How to properly exclude test files from tsdoc / typedoc

I am testing out some various documentation engines, and I'd like to try typedoc for our large project.我正在测试一些不同的文档引擎,我想为我们的大型项目尝试 typedoc。 We have various test files ( somefile.test.ts or someotherfile.test.tsx ) throughout our project.我们在整个项目中有各种测试文件( somefile.test.tssomeotherfile.test.tsx )。 I'm struggling to get typedoc to ignore these files.我正在努力让 typedoc 忽略这些文件。 I did npm i -D typedoc , then in my tsconfig.json我做了npm i -D typedoc ,然后在我的 tsconfig.json

{
  "compilerOptions": {
    "configOptions": "some_options"
  },
  "include": ["src"],
  "typedocOptions": {
    "out": "docs",
    "entryPoints": "src/index.tsx",
    "exclude": [
      "**/*.test.ts*",
      "**/*.test.tsx*"
    ]
  }
}

Then I run my npm command "tsdoc": "typedoc" - npm run tsdoc .然后我运行我的 npm 命令"tsdoc": "typedoc" - npm run tsdoc Typedoc runs through my files and finds an absolute ton of typescript linting errors in my testing files, and so it fails to run. Typedoc 遍历我的文件并在我的测试文件中发现大量的 typescript linting 错误,因此它无法运行。 (We recently updated our @types/jest , so eslint and ts are complaining about things like Property 'toEqual' does not exist on type 'Assertion' and Property 'toMatchSnapshot' does not exist on type 'Assertion' . eslint and ts complain about these things, but it doesn't prevent the tests from running. But what is wrong with my typedocOptions that it is not correctly ignoring these files? (我们最近更新了我们的@types/jest ,所以 eslint 和 ts 抱怨诸如Property 'toEqual' does not exist on type 'Assertion'Property 'toMatchSnapshot' does not exist on type 'Assertion' 。eslint 和 ts 抱怨这些东西,但它不会阻止测试运行。但是我的typedocOptions有什么问题,它没有正确忽略这些文件?

This is a total shot in the dark, but I'm going to guess that typedoc runs tsc before it attempts to generate the documentation, to create the linkages between files.这完全是在黑暗中拍摄,但我猜测typedoc在尝试生成文档之前运行tsc以创建文件之间的链接。 It might not get to the point of checking which files to exclude if tsc / eslint are giving it errors.如果tsc / eslint给出错误,它可能无法检查要排除的文件。

I'd recommend looking into why the Jest upgrade is blowing things up.我建议调查一下为什么 Jest 升级会搞砸事情。 Once the compiler/linting errors are gone, I imagine typedoc will cooperate.一旦编译器/ linting 错误消失,我想typedoc会配合。 You could also tell tsc / eslint to ignore those files, but I imagine that not compiling the test files will cause further problems down the line.你也可以告诉tsc / eslint忽略这些文件,但我想不编译测试文件会导致进一步的问题。

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

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