mcpField
T
typescript-docs

typescript-docs

github.com/giuseppe-trisciuoglio開発3654.2k 回インストール7 週間前に更新
リポジトリ

typescript-docs について

TypeScriptプロジェクトのドキュメント作成ガイドです。APIリファレンス、設計判断、フレームワークの例を整備する開発者向けに、JSDoc、TypeDoc、検証、CI/CD設定を扱います。

主な機能

  1. 01TypeDocによるAPIドキュメント生成
  2. 02JSDocの注釈パターン
  3. 03ADRの作成と管理
  4. 04フレームワーク別の記述パターン
  5. 05ESLintによるドキュメント検証
  6. 06GitHub Actionsのパイプライン

活用シーン

  1. 01TypeScriptのAPIリファレンス生成
  2. 02コードへのJSDoc追加
  3. 03アーキテクチャ判断の記録
  4. 04CI/CDでのドキュメント検証

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill typescript-docs

インストール後、Claude Code で/typescript-docsを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

references/
adr-patterns.md
examples.md
framework-patterns.md
jsdoc-patterns.md
pipeline-setup.md
typedoc-configuration.md
validation.md

詳細

TypeScript ドキュメント

複数の読者層に向けた、階層化アーキテクチャを備えた本番環境向けの TypeScript ドキュメントを生成します。TypeDoc による API ドキュメント、ADR、フレームワーク固有のパターンに対応しています。

概要

インラインドキュメントには JSDoc アノテーションを、API リファレンスの生成には TypeDoc を、設計上の選択の記録には ADR を使用します。

主な機能:

  • TypeDoc の設定と API ドキュメントの生成
  • すべての TypeScript 構文に対応した JSDoc パターン
  • ADR の作成と保守
  • フレームワーク固有のパターン(NestJS、React、Express、Angular、Vue)
  • ドキュメント品質を高める ESLint 検証ルール
  • GitHub Actions パイプラインの設定

使用する場面

API ドキュメント、アーキテクチャ決定記録、コード例、または NestJS、Express、React、Angular、Vue 向けのフレームワーク固有のパターンを作成する場合に、このスキルを使用します。

クイックリファレンス

ツール用途コマンド
TypeDocAPI ドキュメントの生成npx typedoc
CompodocAngular ドキュメントnpx compodoc -p tsconfig.json
ESLint JSDocドキュメントの検証eslint --ext .ts src/
JSDoc タグ
タグ使用例
@paramパラメーターを記述する
@returns戻り値を記述する
@throwsエラー条件を記述する
@exampleコード例を示す
@remarks実装に関する注記を追加する
@see関連項目を相互参照する
@deprecated非推奨の API を示す

手順

1. TypeDoc を設定する
npm install --save-dev typedoc typedoc-plugin-markdown
{
  "entryPoints": ["src/index.ts"],
  "out": "docs/api",
  "theme": "markdown",
  "excludePrivate": true,
  "readme": "README.md"
}
2. JSDoc コメントを追加する
/**
 * Service for managing user authentication
 *
 * @remarks
 * Handles JWT-based authentication with bcrypt password hashing.
 *
 * @example
 * ```typescript
 * const authService = new AuthService(config);
 * const token = await authService.login(email, password);
 * ```
 *
 * @security
 * - Passwords hashed with bcrypt (cost factor 12)
 * - JWT tokens signed with RS256
 */
@Injectable()
export class AuthService {
  /**
   * Authenticates a user and returns access tokens
   * @param credentials - User login credentials
   * @returns Authentication result with tokens
   * @throws {InvalidCredentialsError} If credentials are invalid
   */
  async login(credentials: LoginCredentials): Promise<AuthResult> {
    // Implementation
  }
}
3. ADR を作成する
# ADR-001: TypeScript Strict Mode Configuration

## Status
Accepted

## Context
What is the issue motivating this decision?

## Decision
What change are we proposing?

## Consequences
What becomes easier or more difficult?
4. CI/CD パイプラインを設定する
name: Documentation
on:
  push:
    branches: [main]
    paths: ['src/**', 'docs/**']

jobs:
  generate-docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
      - run: npm ci
      - run: npm run docs:generate
      - run: npm run docs:validate
5. ドキュメントを検証する
{
  "rules": {
    "jsdoc/require-description": "error",
    "jsdoc/require-param-description": "error",
    "jsdoc/require-returns-description": "error",
    "jsdoc/require-example": "warn"
  }
}

検証に失敗した場合: ESLint のエラーを確認し、JSDoc コメントを修正します(説明の不足を補い、記述されていない箇所には @param/@returns/@throws を追加します)。すべてのエラーが解消されるまで eslint --ext .ts src/ を再実行してから、コミットしてください。

例

React フックのドキュメント化
/**
 * Custom hook for fetching paginated data
 *
 * @remarks
 * This hook manages loading states, error handling, and automatic
 * refetching when the page or filter changes.
 *
 * @example
 * ```tsx
 * function UserList() {
 *   const { data, isLoading, error } = usePaginatedData('/api/users', {
 *     page: currentPage,
 *     limit: 10
 *   });
 *
 *   if (isLoading) return <Spinner />;
 *   if (error) return <ErrorMessage error={error} />;
 *   return <UserTable users={data.items} />;
 * }
 * ```
 *
 * @param endpoint - API endpoint to fetch from
 * @param options - Pagination and filter options
 * @returns Paginated response with items and metadata
 */
export function usePaginatedData<T>(
  endpoint: string,
  options: PaginationOptions
): UsePaginatedDataResult<T> {
  // Implementation
}
ユーティリティ関数のドキュメント化
/**
 * Validates email addresses using RFC 5322 specification
 *
 * @param email - Email address to validate
 * @returns True if email format is valid
 *
 * @example
 * ```typescript
 * isValidEmail('[email protected]'); // true
 * isValidEmail('invalid-email');      // false
 * ```
 *
 * @performance
 * O(n) where n is the email string length
 *
 * @see {@link https://tools.ietf.org/html/rfc5322} RFC 5322 Specification
 */
export function isValidEmail(email: string): boolean {
  const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
  return emailRegex.test(email);
}
NestJS コントローラーのドキュメント化
/**
 * REST API endpoints for user management
 *
 * @remarks
 * All endpoints require authentication via Bearer token.
 * Rate limiting: 100 requests per minute per user.
 *
 * @example
 * ```bash
 * curl -H "Authorization: Bearer <token>" https://api.example.com/users/123
 * ```
 *
 * @security
 * - All endpoints use HTTPS
 * - JWT tokens expire after 1 hour
 * - Sensitive data is redacted from logs
 */
@Controller('users')
export class UsersController {
  /**
   * Retrieves a user by ID
   * @param id - User UUID
   * @returns User profile (password excluded)
   */
  @Get(':id')
  async getUser(@Param('id') id: string): Promise<UserProfile> {
    // Implementation
  }
}

ベストプラクティス

  1. 公開 API を記述する:すべての公開メソッド、クラス、インターフェースを記述します
  2. @example を使用する:複雑な関数には実行可能な例を示します
  3. @throws を含める:発生する可能性のあるすべてのエラーを記述します
  4. @see を追加する:関連する関数や型を相互参照します
  5. @remarks を使用する:実装の詳細や注記を追加します
  6. ジェネリクスを記述する:ジェネリック制約と使用方法を説明します
  7. パフォーマンスに関する注記を含める:時間計算量と空間計算量を記述します
  8. セキュリティに関する警告を追加する:セキュリティ上の注意点を明示します
  9. 最新の状態を保つ:コードの変更時にドキュメントも更新します
  10. 自明なコードは説明しない:何をするかではなく、なぜそうするかに重点を置きます

制約と警告

  • プライベートメンバー:@private を使用するか、TypeDoc の出力から除外します
  • 複雑な型:ジェネリック制約と型パラメーターを記述します
  • 破壊的変更:移行方法を示して @deprecated を使用します
  • セキュリティ情報:ドキュメントにシークレットや認証情報を記載しないでください
  • リンクの有効性:@see の参照先が有効な場所であることを確認します
  • コード例:すべての例を実行およびテストできる状態にします
  • バージョン管理:ドキュメントをコードのバージョンと同期させます

参考資料

コメント