Fumadocs

Typescript

从 TypeScript 定义生成文档

使用

npm install fumadocs-typescript

UI 集成

它带有 AutoTypeTable 组件。了解更多关于 自动类型表格

MDX 集成

您可以将其用作 remark 插件:

source.config.ts
import { remarkAutoTypeTable, createGenerator } from 'fumadocs-typescript';
import { defineConfig } from 'fumadocs-mdx/config';

const generator = createGenerator();

export default defineConfig({
  mdxOptions: {
    remarkPlugins: [[remarkAutoTypeTable, { generator }]],
  },
});

它为您提供一个 auto-type-table 组件。

您可以像 自动类型表格 那样使用它,但有额外的规则:

  • 属性值必须是字符串。
  • path 接受相对于 MDX 文件本身的路径。
  • 您还需要将 类型表格 添加到 MDX 组件中。
path/to/file.ts
export interface MyInterface {
  name: string;
}
page.mdx
<auto-type-table path="./path/to/file.ts" name="MyInterface" />

注解

隐藏

通过添加 @internal tsdoc 标签来隐藏一个字段。

interface MyInterface {
  /**
   * @internal
   */
  cache: number;
}

指定类型名称

您可以使用 @remarks tsdoc 标签指定类型的名称。

interface MyInterface {
  /**
   * @remarks `timestamp` Returned by API. // [!code highlight]
   */
  time: number;
}

这将使 time 属性的类型显示为 timestamp

How is this guide?

Last updated on