mcpField
C
code-documenter

code-documenter

github.com/jeffallan開発12.1k5.8k 回インストール今日更新
リポジトリ

code-documenter について

Code Documenterは、コードやAPIのドキュメント、ガイド、ドキュメントサイトを作成する開発者向けのスキルです。未記述箇所の特定から形式の統一、サンプルの検証、カバレッジ報告までの手順を示します。

主な機能

  1. 01Docstringとインラインドキュメント
  2. 02OpenAPI、Swagger、JSDoc仕様
  3. 03RESTとGraphQLのAPIドキュメント
  4. 04開発者向けガイドとドキュメントサイト
  5. 05サンプル検証とカバレッジ報告

活用シーン

  1. 01公開関数やクラスのドキュメント作成
  2. 02サービスのAPI仕様書作成
  3. 03セットアップガイドやチュートリアルの執筆
  4. 04サンプルとドキュメントカバレッジの確認

インストール

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

$npx skills add https://github.com/jeffallan/claude-skills --skill code-documenter

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

同梱ファイル

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

references/
api-docs-fastapi-django.md
api-docs-nestjs-express.md
coverage-reports.md
documentation-systems.md
interactive-api-docs.md
python-docstrings.md
typescript-jsdoc.md
user-guides-tutorials.md

詳細

コードドキュメント作成

インラインドキュメント、API 仕様、ドキュメントサイト、開発者向けガイドを専門とするドキュメント作成ツールです。

このスキルを使う場面

  • 関数、クラス、モジュールに docstring を追加する
  • OpenAPI/Swagger 仕様や JSDoc アノテーションを作成する
  • REST または GraphQL エンドポイントの API ドキュメントを作成する
  • ドキュメントサイトや開発者向けポータルを構築する
  • 入門ガイド、チュートリアル、ユーザーガイドを作成する

基本的なワークフロー

  1. 確認 - 希望する形式と除外項目を尋ねます
  2. 検出 - 言語とフレームワークを特定します
  3. 分析 - ドキュメントがないコードを探します
  4. ドキュメント作成 - 一貫した形式を適用します
  5. 検証 - すべてのコード例がコンパイルまたは実行できることをテストします:
    • Python:doctest ブロックには python -m doctest file.py を使用し、モジュール全体のチェックには pytest --doctest-modules を使用します
    • TypeScript/JavaScript:型付きの例がコンパイルできることを確認するには tsc --noEmit を使用します
    • OpenAPI:npx @redocly/cli lint openapi.yaml で仕様を検証します
    • 検証に失敗した場合:例を修正して再検証してから、「レポート」の手順に進みます
  6. レポート - カバレッジの概要を生成します

クイックリファレンスの例

Google スタイルの Docstring(Python)
def fetch_user(user_id: int, active_only: bool = True) -> dict:
    """Fetch a single user record by ID.

    Args:
        user_id: Unique identifier for the user.
        active_only: When True, raise an error for inactive users.

    Returns:
        A dict containing user fields (id, name, email, created_at).

    Raises:
        ValueError: If user_id is not a positive integer.
        UserNotFoundError: If no matching user exists.
    """
NumPy スタイルの Docstring(Python)
def compute_similarity(vec_a: np.ndarray, vec_b: np.ndarray) -> float:
    """Compute cosine similarity between two vectors.

    Parameters
    ----------
    vec_a : np.ndarray
        First input vector, shape (n,).
    vec_b : np.ndarray
        Second input vector, shape (n,).

    Returns
    -------
    float
        Cosine similarity in the range [-1, 1].

    Raises
    ------
    ValueError
        If vectors have different lengths.
    """
JSDoc(TypeScript)
/**
 * Fetches a paginated list of products from the catalog.
 *
 * @param {string} categoryId - The category to filter by.
 * @param {number} [page=1] - Page number (1-indexed).
 * @param {number} [limit=20] - Maximum items per page.
 * @returns {Promise<ProductPage>} Resolves to a page of product records.
 * @throws {NotFoundError} If the category does not exist.
 *
 * @example
 * const page = await fetchProducts('electronics', 2, 10);
 * console.log(page.items);
 */
async function fetchProducts(
  categoryId: string,
  page = 1,
  limit = 20
): Promise<ProductPage> { ... }

リファレンスガイド

状況に応じて詳細なガイダンスを読み込みます:

トピックリファレンス読み込むタイミング
Python の Docstringreferences/python-docstrings.mdGoogle、NumPy、Sphinx の各スタイル
TypeScript の JSDocreferences/typescript-jsdoc.mdJSDoc のパターン、TypeScript
FastAPI/Django APIreferences/api-docs-fastapi-django.mdPython API ドキュメント
NestJS/Express APIreferences/api-docs-nestjs-express.mdNode.js API ドキュメント
カバレッジレポートreferences/coverage-reports.mdドキュメントレポートの生成
ドキュメントシステムreferences/documentation-systems.mdドキュメントサイト、静的サイトジェネレーター、検索、テスト
インタラクティブ API ドキュメントreferences/interactive-api-docs.mdOpenAPI 3.1、ポータル、GraphQL、WebSocket、gRPC、SDK
ユーザーガイドとチュートリアルreferences/user-guides-tutorials.md入門、チュートリアル、トラブルシューティング、FAQ

制約事項

必ず行うこと
  • 開始前に希望する形式を尋ねます
  • 適切な API ドキュメント戦略を選ぶため、フレームワークを特定します
  • すべての公開関数/クラスをドキュメント化します
  • パラメーターの型と説明を記載します
  • 例外/エラーをドキュメント化します
  • ドキュメント内のコード例をテストします
  • カバレッジレポートを生成します
必ず行わないこと
  • 尋ねずに docstring の形式を決めつけます
  • フレームワークに適さない API ドキュメント戦略を適用します
  • 不正確または未検証のドキュメントを作成します
  • エラーに関するドキュメントを省略します
  • 明白な getter/setter を冗長にドキュメント化します
  • 保守が難しいドキュメントを作成します

出力形式

タスクに応じて、以下を提供します:

  1. コードドキュメント: ドキュメントを追加したファイル+カバレッジレポート
  2. API ドキュメント: OpenAPI 仕様+ポータル設定
  3. ドキュメントサイト: サイト設定+コンテンツ構成+ビルド手順
  4. ガイド/チュートリアル: 例+図を含む構成済み Markdown

ナレッジリファレンス

Google/NumPy/Sphinx の docstring、JSDoc、OpenAPI 3.0/3.1、AsyncAPI、gRPC/protobuf、FastAPI、Django、NestJS、Express、GraphQL、Docusaurus、MkDocs、VitePress、Swagger UI、Redoc、Stoplight

Synergetic Solutions のプリンシパルコンサルタントである @jeffallan がメンテナンスしています。

ドキュメント

コメント