简体   繁体   English

如何使 typedoc 与 deno 一起使用

[英]How to make typedoc works with deno

I am using Deno in one of my projects and I want to generate the documentation with typedoc.我在我的一个项目中使用 Deno,我想用 typedoc 生成文档。 I am facing a lot of problems with dependencies because they do not get resolved correctly, so typedoc fails.我面临着很多依赖关系的问题,因为它们没有得到正确解决,所以 typedoc 失败了。 I have the following tsconfig.json :我有以下tsconfig.json

{
  "compilerOptions": {
    "module": "amd",
    "target": "esnext",
    "baseUrl": ".",
    "paths": {
      "http://*": ["../../../.deno/deps/http/*"],
      "https://*": ["../../../.deno/deps/https/*"],
      "*.ts": ["*"]
    },
    "plugins": [
      {
        "name": "typescript-deno-plugin"
      }
    ]
  }
}

The first two entries in paths resolve the native modules of Deno (like its assertion library). paths的前两个条目解析 Deno 的本机模块(如其断言库)。 The problem comes when I use another library like Cheerio, importing it like this in my deps.ts file:当我使用像deps.ts这样的另一个库时,问题就出现了,在我的deps.ts文件中像这样导入它:

// @deno-types="https://cdn.jsdelivr.net/gh/justjavac/deno_cheerio/cheerio.d.ts"
import cheerio from "https://dev.jspm.io/cheerio/index";

Note: I have to import the types from an external source because the types declared in dev.jspm.io do not work because they include the /// reference directive.注意:我必须从外部源导入类型,因为 dev.jspm.io 中声明的类型不起作用,因为它们包含/// reference指令。

I have the following typedoc.js config file:我有以下typedoc.js配置文件:

// deno-lint-ignore-file
module.exports = {
  out: "./docs-build",
  mode: "file",
};

If I run typedoc src/ , I get the following error:如果我运行typedoc src/ ,我会收到以下错误:

Using TypeScript 4.0.3 from /home/antonio/.nvm/versions/node/v12.18.1/lib/node_modules/typescript/lib
Error: /home/antonio/manga-api/src/deps.ts(8)
 Cannot find module 'https://dev.jspm.io/cheerio/index'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?

Note2: I'm using deno but typedoc is installed with npm globally, along typescript and typescript-deno-plugin .注2:我使用杰诺但typedoc安装有NPM全球范围内,沿typescripttypescript-deno-plugin

Any idea how to make typedoc work correctly with Deno?知道如何使typedoctypedoc一起正常工作吗?

Typedoc won't work with Deno. Typedoc 不适用于 Deno。 Deno supports module resolution and URL resolution, which Node (the current runtime for Typedoc) lacks of. Deno 支持模块解析和 URL 解析,这是 Node(Typedoc 的当前运行时)所缺乏的。 The only way it could work is if Typedoc itself run in Deno, but it doesn't offer support for it at the moment.它可以工作的唯一方法是 Typedoc 本身在 Deno 中运行,但目前它不提供支持。

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

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