自動型テーブル
TypeScript の型定義からドキュメントを生成します
使い方
npm install fumadocs-typescriptUI との統合
AutoTypeTable コンポーネントが用意されています。詳しくは自動型テーブルを参照してください。
MDX との統合
remarkAutoTypeTable は remark プラグインです。設定に追加してください。
import {
remarkAutoTypeTable,
createGenerator,
createFileSystemGeneratorCache,
} from 'fumadocs-typescript';
import { defineConfig } from 'fumadocs-mdx/config';
const generator = createGenerator({
// 推奨: キャッシュ用のディレクトリを指定します
cache: createFileSystemGeneratorCache('.cache/fumadocs-typescript'),
});
export default defineConfig({
mdxOptions: {
remarkPlugins: [[remarkAutoTypeTable, { generator }]],
},
});これにより、auto-type-table コンポーネントを利用できるようになります。
自動型テーブルと同じように使用できますが、次のルールが追加されます。
- 属性の値は文字列である必要があります。
pathには、MDX ファイル自体からの相対パスを指定します。- MDX コンポーネントに
TypeTableも追加する必要があります。
export interface MyInterface {
name: string;
}<auto-type-table path="./path/to/file.ts" name="MyInterface" />信頼できない値を path に渡さないでください。マシン上の任意の TypeScript ファイルが読み取られるおそれがあります。
アノテーション
非表示にする
フィールドに @internal TSDoc タグを付けると、そのフィールドを非表示にできます。
interface MyInterface {
/**
* @internal
*/
cache: number;
}簡略化された型
TSDoc の @remarks タグを使用すると、型の簡略名を指定できます。
interface MyInterface {
/**
* @remarks `timestamp` API から返されます。 // [!code highlight]
*/
time: number;
}これにより、time プロパティの型が timestamp として表示されます。
完全な型
@fumadocsType TSDoc タグを使用すると、型の完全な名前を指定できます。
interface MyInterface {
/**
* @fumadocsType `MyBeautifulClient` // [!code highlight]
*/
client: MyClient;
}Type Href
型テーブルと組み合わせて使用すると、プロパティから他の場所へリンクできます。
型テーブルはアンカー ID を自動で生成するため、それを使って別の型テーブルへリンクできます。
interface MyInterface {
/**
* @fumadocsHref #type-table-temp.ts-MyClass-test
*/
client: MyClient;
}How is this guide?
最終更新日
