gpt4 book ai didi

javascript - 使用 TypeDoc 记录外部类型

转载 作者:可可西里 更新时间:2023-11-01 02:08:22 25 4
gpt4 key购买 nike

我有两个文件,文件 A 和文件 B。文件 A 使用文件 B 中的类。我的目标是在文件 A 的 TypeDoc 输出中引用文件 B 中使用的类的 TypeDoc 输出。我不能似乎是这样做的。

我知道您可以使用带双括号的 TypeDoc 引用同一文件中包含的符号,例如 [[Foo]],但这不适用于像这样的外部类型。

/** Trying to reference [[FileB.InnerClass]] like this doesn't work. */
// This here is what I want to include
export type InnerClass = FileB.InnerClass;

// More code...

这有可能实现吗?

最佳答案

是的,这是可能的。

  1. 更正评论。
  2. 您不必输入文件名,但您必须使用 import
  3. 从文件中导入对象
import { InnerClass } from './FileB';

/**
* See the [[InnerClass]] for more details.
*/
export type innerClass = InnerClass;
  1. 要生成文档,请运行以下命令。

typedef 是全局的时,使用这个命令:

typedoc --out ./docs --target ES6 ./src/

或者当它是本地的时候:

npx typedoc --out ./docs --target ES6 ./src/

  • ./docs 是生成文档的文件夹。

  • ./src/ 是您的代码所在的文件夹。

  • --JavaScript 的目标 ES6 版本。

如果你只想显示没有不同模块的类,使用这个标志--mode file:

npx typedoc --out ./docs --mode file --target ES6 ./src/

有关详细信息,请参阅 documentation .

关于javascript - 使用 TypeDoc 记录外部类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57211393/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com