【问题标题】:Documenting external types with TypeDoc使用 TypeDoc 记录外部类型
【发布时间】:2019-12-04 06:55:12
【问题描述】:

我有两个文件,文件 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...

这有可能实现吗?

【问题讨论】:

    标签: javascript typescript typedoc


    【解决方案1】:

    是的,这是可能的。

    1. 更正评论。
    2. 您不必输入文件名,但必须使用import 从文件中导入对象
    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/ 是您的代码所在的文件夹。

    • --target ES6 JavaScript 版本。

    如果您只想显示没有不同模块的类,请使用此标志--mode file

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

    有关详细信息,请参阅documentation

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-09
    • 1970-01-01
    • 2015-08-27
    • 2015-08-19
    • 1970-01-01
    • 1970-01-01
    • 2020-04-27
    • 2014-11-06
    相关资源
    最近更新 更多