diff --git a/docs/en/contributing/translation-guide.md b/docs/en/contributing/translation-guide.md
index 1457a183..de1762d4 100644
--- a/docs/en/contributing/translation-guide.md
+++ b/docs/en/contributing/translation-guide.md
@@ -47,7 +47,7 @@ Level descriptions, feature labels and summaries, rule messages, concept titles
```toml title="src/fastapi_fastkit/catalog/i18n/ko.toml"
[levels."hello"]
label = "Hello"
-description = "main.py 하나에 엔드포인트 3개, 메모리 데이터, 테스트가 들어 있습니다."
+description = "main.py 하나에 엔드포인트 3개와 메모리 데이터가 들어 있고, 테스트도 함께 제공됩니다."
```
The overlays feed the generated blocks and the web generator page. To see every key to translate, print the English skeleton:
diff --git a/docs/ja/contributing/code-guidelines.md b/docs/ja/contributing/code-guidelines.md
deleted file mode 100644
index 2a392d64..00000000
--- a/docs/ja/contributing/code-guidelines.md
+++ /dev/null
@@ -1,748 +0,0 @@
-# コードガイドライン
-
-FastAPI-fastkit へ貢献する際のコーディング標準とベストプラクティスをまとめた包括的なガイドです。
-
-## 概要
-
-これらのガイドラインは、FastAPI-fastkit プロジェクト全体でコード品質、一貫性、保守性を保つためのものです。これらの基準に従うことで、読みやすく、保守しやすく、拡張しやすいコードベースが維持できます。
-
-## Python のコードスタイル
-
-### PEP 8 準拠
-
-[PEP 8](https://www.python.org/dev/peps/pep-0008/) に従い、次の固有設定を使用します:
-
-- **行長**: 88 文字 (Black デフォルト)
-- **インデント**: スペース 4 つ (タブ禁止)
-- **末尾カンマ**: 複数行の構造では必須
-- **文字列クオート**: ダブルクオート推奨
-
-### コードフォーマット
-
-自動フォーマットには **Black** を使用します:
-
-```python
-# 良い例 ✅
-def create_project(
- name: str,
- template: str,
- options: Dict[str, Any],
-) -> ProjectResult:
- """Create a new FastAPI project."""
- return ProjectResult(name=name, template=template)
-
-# 悪い例 ❌
-def create_project(name: str, template: str, options: Dict[str,Any])->ProjectResult:
- """Create a new FastAPI project."""
- return ProjectResult(name=name,template=template)
-```
-
-### import の整理
-
-import の整理には **isort** を使用します:
-
-```python
-# 標準ライブラリ
-import os
-import sys
-from pathlib import Path
-from typing import Dict, List, Optional, Union
-
-# サードパーティ
-import click
-import pydantic
-from fastapi import FastAPI
-
-# ローカル
-from fastapi_fastkit.commands import BaseCommand
-from fastapi_fastkit.utils import validation
-from fastapi_fastkit.templates.manager import TemplateManager
-```
-
-## 型ヒント
-
-### 必須の型ヒント
-
-すべての公開関数とメソッドには型ヒントが必要です:
-
-```python
-# 良い例 ✅
-def validate_project_name(name: str) -> bool:
- """Validate project name format."""
- return name.isidentifier() and not name.startswith('_')
-
-def create_files(
- files: List[Path],
- template_data: Dict[str, Any]
-) -> List[Path]:
- """Create files from template data."""
- created_files = []
- for file_path in files:
- # 実装 ...
- created_files.append(file_path)
- return created_files
-
-# 悪い例 ❌
-def validate_project_name(name):
- return name.isidentifier() and not name.startswith('_')
-```
-
-### 複雑な型注釈
-
-複雑な構造には適切な型注釈を使用します:
-
-```python
-from typing import Dict, List, Optional, Union, Tuple, Any
-from pathlib import Path
-
-# 複雑な型のエイリアス
-ProjectConfig = Dict[str, Union[str, bool, List[str]]]
-FileMapping = Dict[Path, str]
-ValidationResult = Tuple[bool, Optional[str]]
-
-def process_template(
- template_path: Path,
- config: ProjectConfig,
- output_dir: Optional[Path] = None,
-) -> ValidationResult:
- """Process template with configuration."""
- # 実装 ...
- return True, None
-```
-
-## 命名規則
-
-### 変数と関数
-
-- 変数と関数には **snake_case**
-- **目的が分かる名前** を付ける
-- **省略形は避ける** (一般的に通じるものを除く)
-
-```python
-# 良い例 ✅
-project_name = "my-api"
-template_directory = Path("templates")
-user_input_data = get_user_input()
-
-def validate_email_address(email: str) -> bool:
- """Validate email address format."""
- return "@" in email and "." in email
-
-# 悪い例 ❌
-proj_nm = "my-api"
-temp_dir = Path("templates")
-usr_data = get_input()
-
-def validate_email(e):
- return "@" in e and "." in e
-```
-
-### クラス
-
-- クラス名には **PascalCase**
-- **記述的かつ具体的** な名前
-
-```python
-# 良い例 ✅
-class SomeClass:
- """Represents example class of FastAPI-fastkit."""
- pass
-
-class SomeClassValidationError(Exception):
- """Raised when example class validation fails."""
- pass
-
-class UserInputHandler:
- """Handles user input validation and processing."""
- pass
-
-# 悪い例 ❌
-class Class:
- pass
-
-class Error(Exception):
- pass
-
-class Handler:
- pass
-```
-
-### 定数
-
-- アンダースコア区切りの **UPPER_CASE**
-- **モジュールレベル** に限定
-
-```python
-# 良い例 ✅
-DEFAULT_TEMPLATE_NAME = "fastapi-default"
-MAX_PROJECT_NAME_LENGTH = 50
-SUPPORTED_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12"]
-
-# 悪い例 ❌
-default_template = "fastapi-default"
-maxLength = 50
-versions = ["3.8", "3.9", "3.10", "3.11", "3.12"]
-```
-
-## ドキュメント標準
-
-### docstring
-
-すべての公開 API には **Google スタイルの docstring** を使用します:
-
-```python
-def create_project_structure(
- project_name: str,
- template_path: Path,
- output_directory: Optional[Path] = None,
- overwrite: bool = False,
-) -> List[Path]:
- """Create project structure from template.
-
- Creates a new FastAPI project structure by copying and processing
- template files. Supports variable substitution and file customization.
-
- Args:
- project_name: Name of the project to create. Must be a valid
- Python identifier.
- template_path: Path to the template directory containing
- source files and configuration.
- output_directory: Directory where project will be created.
- Defaults to current working directory.
- overwrite: Whether to overwrite existing files. If False,
- raises error when files exist.
-
- Returns:
- List of created file paths in order of creation.
-
- Raises:
- ValueError: If project_name is invalid or empty.
- FileExistsError: If output directory exists and overwrite is False.
- TemplateNotFoundError: If template_path doesn't exist.
- PermissionError: If insufficient permissions to create files.
-
- Example:
- ```python
- template_path = Path("templates/fastapi-default")
- created_files = create_project_structure(
- project_name="my-api",
- template_path=template_path,
- output_directory=Path("./projects"),
- overwrite=False
- )
- print(f"Created {len(created_files)} files")
- ```
- """
- # 実装 ...
- pass
-```
-
-### コメント
-
-- **何 (WHAT) ではなく、なぜ (WHY) を説明**
-- **必要最小限** に — コードは自己説明的であるべき
-- **コード変更時にコメントも更新**
-
-```python
-# 良い例 ✅
-def validate_dependencies(requirements: List[str]) -> bool:
- """Validate project dependencies."""
- # 実験的なパッケージを許可するため、開発モードでは検証をスキップする
- if os.getenv("FASTKIT_DEV_MODE"):
- return True
-
- # 既知のセキュリティ脆弱性に対して各要件を確認する
- for requirement in requirements:
- if is_vulnerable_package(requirement):
- return False
-
- return True
-
-# 悪い例 ❌
-def validate_dependencies(requirements: List[str]) -> bool:
- """Validate project dependencies."""
- # dev モードかチェック
- if os.getenv("FASTKIT_DEV_MODE"):
- return True
-
- # 要件をループ
- for requirement in requirements:
- # 脆弱かチェック
- if is_vulnerable_package(requirement):
- return False
-
- # true を返す
- return True
-```
-
-## エラー処理
-
-### 例外処理
-
-- 可能な限り **具体的な例外をキャッチ**
-- **意味のあるエラーメッセージ** を提供
-- **エラーは適切にログ出力**
-
-```python
-# 良い例 ✅
-def load_template_config(template_path: Path) -> Dict[str, Any]:
- """Load template configuration from file."""
- config_file = template_path / "template.yaml"
-
- try:
- with open(config_file, 'r') as f:
- return yaml.safe_load(f)
- except FileNotFoundError:
- raise TemplateNotFoundError(
- f"Template configuration not found: {config_file}"
- )
- except yaml.YAMLError as e:
- raise TemplateConfigError(
- f"Invalid YAML syntax in {config_file}: {e}"
- )
- except PermissionError:
- raise TemplateAccessError(
- f"Permission denied reading {config_file}"
- )
-
-# 悪い例 ❌
-def load_template_config(template_path: Path) -> Dict[str, Any]:
- """Load template configuration from file."""
- config_file = template_path / "template.yaml"
-
- try:
- with open(config_file, 'r') as f:
- return yaml.safe_load(f)
- except Exception as e:
- raise Exception(f"Error loading config: {e}")
-```
-
-### カスタム例外
-
-エラー条件ごとに専用の例外を定義します:
-
-```python
-class FastKitError(Exception):
- """Base exception for FastAPI-fastkit errors."""
- pass
-
-class ProjectCreationError(FastKitError):
- """Raised when project creation fails."""
- pass
-
-class TemplateNotFoundError(FastKitError):
- """Raised when template is not found."""
- pass
-
-class ValidationError(FastKitError):
- """Raised when input validation fails."""
-
- def __init__(self, message: str, field: str = None):
- super().__init__(message)
- self.field = field
-```
-
-## テスト基準
-
-### テスト構造
-
-明快な構成と命名でテストを整理します:
-
-```python
-class TestProjectCreation:
- """Test project creation functionality."""
-
- def test_create_project_with_valid_name(self, tmp_path):
- """Test project creation with valid project name."""
- project_name = "test-project"
- result = create_project(project_name, template="minimal", output=tmp_path)
-
- assert result.success is True
- assert (tmp_path / project_name).exists()
- assert (tmp_path / project_name / "src" / "main.py").exists()
-
- def test_create_project_with_invalid_name(self):
- """Test project creation fails with invalid name."""
- with pytest.raises(ValueError, match="Invalid project name"):
- create_project("invalid-project-name!", template="minimal")
-
- def test_create_project_overwrites_existing(self, tmp_path):
- """Test project creation overwrites existing directory when forced."""
- project_name = "existing-project"
- project_dir = tmp_path / project_name
- project_dir.mkdir()
-
- result = create_project(
- project_name,
- template="minimal",
- output=tmp_path,
- overwrite=True
- )
-
- assert result.success is True
- assert project_dir.exists()
-```
-
-### テストカバレッジ
-
-- 新規コードでは **90% 以上のカバレッジ** を目標に
-- **エッジケースとエラー条件** をテスト
-- **外部依存はモック**
-
-```python
-def test_template_download_with_network_error(mock_requests):
- """Test template download handles network errors gracefully."""
- mock_requests.get.side_effect = requests.ConnectionError("Network unreachable")
-
- with pytest.raises(TemplateDownloadError, match="Network error"):
- download_template("https://example.com/template.zip")
-
-def test_file_creation_with_permission_error(mock_open):
- """Test file creation handles permission errors."""
- mock_open.side_effect = PermissionError("Permission denied")
-
- with pytest.raises(FileCreationError, match="Permission denied"):
- create_file(Path("/restricted/file.py"), content="test")
-```
-
-## import ガイドライン
-
-### import の整理
-
-!!! note
-
- `isort` フォーマッタが自動で import を整えます。`bash scripts/format.sh` を実行するだけで簡単に整理できます。
-
-1. **標準ライブラリ** を最初
-2. **サードパーティ** を次に
-3. **ローカルアプリケーション** を最後に
-4. 各グループの間に **空行 1 行**
-
-```python
-# 標準ライブラリ
-import os
-import sys
-from pathlib import Path
-from typing import Dict, List, Optional
-
-# サードパーティ
-import click
-import pydantic
-import yaml
-from fastapi import FastAPI
-
-# ローカルアプリケーション
-from fastapi_fastkit.commands.base import BaseCommand
-from fastapi_fastkit.utils.validation import validate_project_name
-from fastapi_fastkit.templates import TemplateManager
-```
-
-### import のベストプラクティス
-
-- **ワイルドカード import を避ける** (`from module import *`)
-- 明快さのため **絶対 import を使う**
-- 多数の項目を import するときは **モジュールを import する** (個別項目ではなく)
-
-```python
-# 良い例 ✅
-from fastapi_fastkit.utils import validation, files, formatting
-
-# 良い例 ✅ (少数のみ import する場合)
-from fastapi_fastkit.utils.validation import validate_email, validate_project_name
-
-# 悪い例 ❌
-from fastapi_fastkit.utils.validation import *
-
-# 悪い例 ❌ (多数の項目を import する場合)
-from fastapi_fastkit.utils.validation import (
- validate_email, validate_project_name, validate_template_name,
- validate_dependencies, validate_python_version, validate_directory
-)
-```
-
-## セキュリティガイドライン
-
-### 入力検証
-
-ユーザー入力は常に検証 / サニタイズしてください:
-
-```python
-def validate_project_name(name: str) -> str:
- """Validate and sanitize project name."""
- if not name:
- raise ValueError("Project name cannot be empty")
-
- if not name.isidentifier():
- raise ValueError("Project name must be a valid Python identifier")
-
- if name.startswith('_'):
- raise ValueError("Project name cannot start with underscore")
-
- if len(name) > 50:
- raise ValueError("Project name too long (max 50 characters)")
-
- # 危険な文字を取り除いてサニタイズ
- sanitized = re.sub(r'[^a-zA-Z0-9_-]', '', name)
-
- return sanitized
-```
-
-### ファイル操作
-
-ファイルパスや操作には注意してください:
-
-```python
-def create_file_safely(file_path: Path, content: str, base_dir: Path) -> None:
- """Create file safely within base directory."""
- # ディレクトリトラバーサル攻撃を防ぐためにパスを解決
- resolved_path = file_path.resolve()
- resolved_base = base_dir.resolve()
-
- # ファイルがベースディレクトリ内にあることを確認
- try:
- resolved_path.relative_to(resolved_base)
- except ValueError:
- raise SecurityError(f"File path outside base directory: {file_path}")
-
- # 親ディレクトリを安全に作成
- resolved_path.parent.mkdir(parents=True, exist_ok=True)
-
- # 適切な権限でファイルを書き込み
- resolved_path.write_text(content, encoding='utf-8')
- resolved_path.chmod(0o644) # 所有者は読み書き、それ以外は読み取りのみ
-```
-
-## パフォーマンスガイドライン
-
-### 効率的なコードの書き方
-
-- 大きなデータセットには **ジェネレータを使う**
-- **早すぎる最適化は避ける**
-- **最適化前にプロファイル**
-
-```python
-# 良い例 ✅ — メモリ効率のためのジェネレータ
-def process_large_template(template_files: List[Path]) -> Iterator[ProcessedFile]:
- """Process template files efficiently."""
- for file_path in template_files:
- content = file_path.read_text()
- processed_content = process_template_content(content)
- yield ProcessedFile(path=file_path, content=processed_content)
-
-# 悪い例 ❌ — すべてをメモリにロード
-def process_large_template(template_files: List[Path]) -> List[ProcessedFile]:
- """Process template files."""
- results = []
- for file_path in template_files:
- content = file_path.read_text()
- processed_content = process_template_content(content)
- results.append(ProcessedFile(path=file_path, content=processed_content))
- return results
-```
-
-### キャッシュ
-
-重い処理にはキャッシュを使います:
-
-```python
-from functools import lru_cache
-
-@lru_cache(maxsize=128)
-def get_template_metadata(template_path: Path) -> TemplateMetadata:
- """Get template metadata with caching."""
- config_file = template_path / "template.yaml"
-
- if not config_file.exists():
- return TemplateMetadata(name=template_path.name)
-
- config = yaml.safe_load(config_file.read_text())
- return TemplateMetadata.from_config(config)
-```
-
-## Git コミットガイドライン
-
-### コミットメッセージ形式
-
-Conventional Commits 形式を使います:
-
-```
-type(scope): description
-
-[optional body]
-
-[optional footer]
-```
-
-### コミット種別
-
-- **feat**: 新機能
-- **fix**: バグ修正
-- **docs**: ドキュメント変更
-- **style**: コードスタイル変更 (フォーマットなど)
-- **refactor**: リファクタリング
-- **test**: テストの追加 / 更新
-- **chore**: メンテナンス作業
-
-### 例
-
-```bash
-# 良い例 ✅
-feat(cli): add template validation command
-
-Add new command to validate template structure and configuration.
-The command checks for required files, validates YAML syntax,
-and ensures template follows conventions.
-
-Closes #123
-
-# 良い例 ✅
-fix(templates): handle missing dependency files gracefully
-
-When a template references a requirements file that doesn't exist,
-show a clear error message instead of crashing.
-
-# 悪い例 ❌
-update stuff
-
-# 悪い例 ❌
-Fixed bug
-```
-
-## コードレビューガイドライン
-
-### 著者向け
-
-レビュー依頼前に確認してほしいこと:
-
-1. **すべてのテストを実行** し、通過していることを確認
-2. **コードカバレッジ** が維持されているか確認
-3. 必要に応じて **ドキュメントを更新**
-4. **コミットメッセージ規約** に従う
-5. PR は **小さく、焦点を絞った形** で
-
-### レビュアー向け
-
-コードレビューの際の観点:
-
-1. **機能性** — 意図どおり動作するか?
-2. **テスト** — エッジケースまでカバーされているか?
-3. **ドキュメント** — 明快で最新か?
-4. **コードスタイル** — プロジェクト規約に従っているか?
-5. **セキュリティ** — 潜在的な脆弱性はないか?
-
-### レビューチェックリスト
-
-- [ ] コードがスタイルガイドラインに従っている
-- [ ] テストが十分で、すべて通過している
-- [ ] ドキュメントが更新されている
-- [ ] セキュリティ上の問題がない
-- [ ] パフォーマンス考慮がされている
-- [ ] エラーハンドリングが適切
-- [ ] コミットメッセージが規約に従っている
-
-## ツールと自動化
-
-### Pre-commit フック
-
-基準の徹底に pre-commit フックを使用します:
-
-```yaml
-# .pre-commit-config.yaml
-repos:
-- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v6.0.0
- hooks:
- - id: trailing-whitespace
- - id: end-of-file-fixer
- - id: check-yaml
- - id: check-toml
-
-- repo: local
- hooks:
- - id: format
- name: format
- entry: black --config pyproject.toml --check .
- language: python
- types: [python]
- additional_dependencies: ['black>=24.10.0']
- pass_filenames: false
-
- - id: isort-check
- name: isort check
- entry: isort --sp pyproject.toml --check-only --diff .
- language: python
- types: [python]
- additional_dependencies: ['isort>=5.13.2']
- pass_filenames: false
-
- - id: isort-fix
- name: isort fix
- entry: isort --sp pyproject.toml .
- language: python
- types: [python]
- additional_dependencies: ['isort>=5.13.2']
- pass_filenames: false
-
- - id: black-fix
- name: black fix
- entry: black --config pyproject.toml .
- language: python
- types: [python]
- additional_dependencies: ['black>=24.10.0']
- pass_filenames: false
-
- - id: mypy
- name: mypy
- entry: mypy --config-file pyproject.toml src
- language: python
- types: [python]
- additional_dependencies:
- - mypy>=1.12.0
- - rich>=13.9.2
- - click>=8.1.7
- - pyyaml>=6.0.0
- - types-PyYAML>=6.0.12
- pass_filenames: false
-
-ci:
- autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
- autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate
-```
-
-!!! note
-
- Pre-commit フックは隔離された Python 環境 (`language: python`) を使います。
-
-### IDE 設定
-
-VS Code の推奨設定:
-
-```json
-{
- "python.linting.enabled": true,
- "python.linting.mypyEnabled": true,
- "python.formatting.provider": "black",
- "python.sortImports.path": "isort",
- "editor.formatOnSave": true,
- "editor.codeActionsOnSave": {
- "source.organizeImports": true
- }
-}
-```
-
-## 次のステップ
-
-このガイドラインを把握したら:
-
-1. [開発環境セットアップ](development-setup.md) に従って **開発環境を構築**
-2. **小さな貢献から始めて** 慣れる
-3. 不明点があれば GitHub Discussions で **質問**
-4. ガイドラインの実例を確認するため **既存コードを読む**
-
-!!! tip "クイックリファレンス"
- - `make check-all` でコードがガイドラインに準拠しているか検証
- - 早期発見のため pre-commit フックをセットアップ
- - 迷ったら既存コードを参照
- - コードレビューでの質問もどうぞ気軽に
-
-これらのガイドラインに従うことで、FastAPI-fastkit の高いコード品質が保たれ、誰にとっても協働がしやすくなります! 🚀
diff --git a/docs/ja/contributing/development-setup.md b/docs/ja/contributing/development-setup.md
index 50956266..fc857ddd 100644
--- a/docs/ja/contributing/development-setup.md
+++ b/docs/ja/contributing/development-setup.md
@@ -1,851 +1,161 @@
# 開発環境のセットアップ
-FastAPI-fastkit に貢献するための開発環境を整える包括的なガイドです。
+このページでは、FastAPI-fastkit のリポジトリのセットアップ、テストとチェックの実行、コードのルール、Web ジェネレーターを含むドキュメントのビルド、リリースの準備について説明します。プルリクエストの進め方は、リポジトリにある `CONTRIBUTING.md` を読んでください。
-## 前提条件
+## 必要なもの
-開始前に、次が用意されているか確認してください:
+- Python 3.12 以降(`requires-python = ">=3.12"`)。
+- git。
+- CI のワークフローが使う PDM、または uv。pip でも構いません。
+- Node.js(CI はバージョン 22 を使います)。Web ジェネレーターとコマンドラインの結果を比較するときだけ必要です。
-- **Python 3.12 以上** がインストール済み
-- **Git** がインストールされ設定済み
-- **Python と FastAPI の基礎知識**
-- **テキストエディタまたは IDE** (VS Code、PyCharm など)
+## インストール
-## Makefile による簡単セットアップ
-
-FastAPI-fastkit には、開発環境を簡単に整えるための Makefile が用意されています:
-
-
+リポジトリをクローンし、開発ツールと一緒に fastkit を編集可能モード(editable)でインストールします。
```console
$ git clone https://github.com/bnbong/FastAPI-fastkit.git
$ cd FastAPI-fastkit
-$ make install-dev
-Setting up development environment...
-Creating virtual environment...
-Installing dependencies...
-Installing pre-commit hooks...
-✅ Development environment ready!
-```
-
-
-
-このコマンド 1 つで:
-
-- パッケージを開発用依存関係込みの editable モードでインストール
-- pre-commit フックをセットアップ
-- 開発ツールを設定
-
-!!! note
-
- このコマンドを実行する前に、仮想環境を作成して有効化しておくのが推奨です。
-
-## 手動セットアップ
-
-手動セットアップを好む場合、または Makefile が動作しない環境では:
-
-### 1. リポジトリをクローン
-
-
-
-```console
-$ git clone https://github.com/bnbong/FastAPI-fastkit.git
-$ cd FastAPI-fastkit
-```
-
-
-
-### 2. 仮想環境の作成
-
-
-
-```console
-$ python -m venv .venv
-$ source .venv/bin/activate # Windows の場合: .venv\Scripts\activate
-```
-
-
-
-### 3. 依存関係のインストール
-
-
-
-```console
-# editable モードで開発用依存も含めてインストール
-$ pip install -e ".[dev]"
-
-# あるいは requirements ファイルから
-$ pip install -r requirements.txt
-$ pip install -r requirements-dev.txt
+$ pdm install -G dev -G test-runtime
+$ pdm run pre-commit install
```
-
+uv の場合は `uv sync --extra dev --group test-runtime` を実行します。pip の場合は、仮想環境を作成して有効化してから `make dev-setup` を実行します。このコマンドは pip をアップグレードし、`pip install -e ".[dev]"` で fastkit をインストールし、`requirements-docs.txt` からドキュメント用の依存関係をインストールしてから `pre-commit install` を実行します。実行時のテストには、さらに `pip install --group test-runtime`(pip 25.1 以降)を実行してください。
-### 4. Pre-commit フックの設定
+開発ツールのバージョンは、`pyproject.toml` と 2 つのロックファイルで同じです。black 26.10.1、isort 9.0.1、mypy 2.3.1、ruff 0.17.6 を使います。pre-commit のフックも、black、isort、mypy を同じバージョンに固定しています。pull した後は、`pdm sync -G dev --clean`(または `uv sync --extra dev`)で環境をそろえてください。
-
+生成したアプリケーションを起動するテストには、FastAPI とほかにいくつかのパッケージが必要です。これらは `test-runtime` 依存関係グループに含まれており、インストールされていない場合、それらのテストはスキップされます。CI は `pdm install -G dev -G test-runtime` でこのグループをインストールします。ローカルでは `pdm sync -G dev -G test-runtime --clean`、`uv sync --extra dev --group test-runtime`、`pip install --group test-runtime`(pip 25.1 以降)のいずれかを使えます。
-```console
-$ pre-commit install
-pre-commit installed at .git/hooks/pre-commit
-```
-
-
-
-### 5. インストールの確認
+## テストを実行する
-
+リポジトリのルートで `pytest` を実行すると、テスト全体が実行されます(`testpaths = ["tests"]`)。`extended` のマークが付いたテストは時間のかかるエンドツーエンドのテストなので、変更と確認を繰り返しているあいだは除外してください。
```console
-$ fastkit --version
-fastapi-fastkit, version 1.2.1
-
-$ python -m pytest tests/
-======================== test session starts ========================
-collected 45 items
-tests/test_cli.py::test_init_command PASSED
-tests/test_templates.py::test_template_listing PASSED
-...
-======================== 45 passed in 2.34s ========================
+$ pdm run pytest -m "not extended"
+$ pdm run pytest tests/test_docs -q
```
-
-
-## 開発ツール
-
-開発環境にはコード品質を保つためのツールが含まれます:
-
-### ワンライナーコマンド
+`make test` は `pytest` を実行し、`make test-coverage` はカバレッジ付き(`--cov-fail-under=80`)で実行して `htmlcov/` と `coverage.xml` を書き出します。Test and Coverage ワークフローは、Ubuntu では Python 3.12、3.13、3.14 で、Windows では Python 3.12 と 3.14 でテストを実行します。2 つ目のジョブは、暗黙のテキストエンコーディングをエラーとして扱う設定で実行し、さらに UTF-8 ではない C ロケールでもう一度実行します。
-Makefile を使う:
+## チェック
```console
-$ make format lint
-Running isort...
-Running black...
-Running mypy...
-✅ All checks passed!
-```
-
-付属のスクリプトを使う:
-
-```console
-$ ./scripts/format.sh
-$ ./scripts/lint.sh
-```
-
-### コードフォーマット
-
-**Black** — コードフォーマッタ:
-
-
-
-```console
-$ black src/ tests/
-reformatted src/main.py
-reformatted tests/test_cli.py
+$ make lint
+Running isort check...
+isort --sp pyproject.toml --check .
+Skipped 5 files
+Running black check...
+black --config pyproject.toml --check .
All done! ✨ 🍰 ✨
+253 files would be left unchanged.
+Running mypy check...
+mypy --config-file pyproject.toml src
+Success: no issues found in 98 source files
```
-
-
-**isort** — import ソーター:
-
-
-
-```console
-$ isort src/ tests/
-Fixing import order in src/main.py
-```
-
-
-
-### コードリンティング
-
-**mypy** — 型チェック:
-
-
-
-```console
-$ mypy src/
-Success: no issues found in 12 source files
-```
-
-
-
-## 利用できる Make コマンド
-
-プロジェクトの Makefile は、よくある開発作業に便利なコマンドを提供します:
-
-### セットアップコマンド
-
-| コマンド | 説明 |
-|---|---|
-| `make install` | パッケージを本番モードでインストール |
-| `make install-dev` | 開発用依存関係込みでインストール |
-| `make install-test` | テスト用にインストール (アンインストール + 再インストール) |
-| `make uninstall` | パッケージをアンインストール |
-| `make clean` | ビルド成果物とキャッシュを削除 |
-
-### コード品質コマンド
-
-| コマンド | 説明 |
-|---|---|
-| `make format` | black と isort でコードをフォーマット |
-| `make format-check` | 変更せずにフォーマットを確認 |
-| `make lint` | すべてのリンティング (isort、black、mypy) を実行 |
-
-### テストコマンド
-
-| コマンド | 説明 |
-|---|---|
-| `make test` | すべてのテストを実行 |
-| `make test-verbose` | 詳細出力付きでテスト実行 |
-| `make test-coverage` | カバレッジレポート付きでテスト実行 |
-| `make coverage-report` | 詳細なカバレッジレポートを生成 (FORMAT=html/xml/json/all) |
-
-### テンプレート検査コマンド
-
-| コマンド | 説明 |
-|---|---|
-| `make inspect-templates` | すべてのテンプレートを検査 |
-| `make inspect-templates-verbose` | 詳細出力付きで検査 |
-| `make inspect-template` | 特定のテンプレートを検査 (TEMPLATES パラメータ) |
-
-基盤となるスクリプトには、反復作業中に知っておくと便利なフラグが 3 つあります:
-`--offline` (PyPI の鮮度チェックをスキップ)、`--no-smoke` (生成されたプロジェクトを uvicorn で
-起動する処理をスキップ — 最も時間のかかるステップです)、`--mypy` (生成されたプロジェクトを型チェック。
-時間がかかるためオプトイン) です。各チェックが実際に何を行うかは
-[テンプレート品質保証](../reference/template-quality-assurance.md) を参照してください。
-
-```console
-$ python scripts/inspect-templates.py --templates fastapi-sqlmodel --offline --no-smoke
-```
-
-### 生成コードは Jinja2 フラグメントに置かれる
-
-`fastkit init --interactive` がプロジェクトに書き込むもの — `main.py`、データベースと認証のモジュール、
-Docker ファイル、pytest の設定 — はすべて、Python の文字列から組み立てられるのではなく、
-`src/fastapi_fastkit/fragments/` 配下のテンプレートからレンダリングされます。`main.py.j2` はどの機能も
-ハードコードしていません: `DynamicConfigGenerator` から渡される `import_fragments`、`lifespan_fragments`、
-`setup_fragments` の各リストを順に処理してそれぞれを include するため、機能を自由に組み合わせられます。
-
-機能を追加する手順はおおよそ次のとおりです:
-
-1. 各部品を `main/imports/`、`main/lifespan/`、`main/setup/` のいずれか (または複数) に置きます
- (lifespan のフラグメントはスペース 4 つでインデントし、他の 2 つはインデントしません)。
-2. 該当する設定の参照で条件分岐させたうえで、`DynamicConfigGenerator._main_fragments()` に登録します。
-3. 単独のモジュールの場合は `/.py.j2` を追加し、`self._render(...)` でレンダリングします。
-4. `tests/test_backends/test_project_builder_config_generator.py` の組み合わせマトリクスを拡張します —
- このテストは、レンダリングされたすべての Python ファイルが `ast.parse` でパースできることを検証します。
-
-つまずきやすい制約が 2 つあります: すべてのフラグメントは末尾の改行で終わる必要があり
-(環境は `keep_trailing_newline=True` で構築されています)、`main.py.j2` は `# fastkit:imports` /
-`# fastkit:routes` のアンカーを保持し続ける必要があります — `fastkit addroute` はそこに挿入します。
-
-正式な手順はフラグメント自体のすぐ隣、
-[`src/fastapi_fastkit/fragments/README.md`](https://github.com/bnbong/FastAPI-fastkit/blob/main/src/fastapi_fastkit/fragments/README.md) にあります。
-
-### ドキュメントコマンド
-
-| コマンド | 説明 |
-|---|---|
-| `make serve-docs` | ドキュメントをローカルで配信 |
-| `make build-docs` | ドキュメントをビルド |
-
-### 翻訳コマンド
-
-| コマンド | 説明 |
-|---|---|
-| `make translate` | ドキュメントを翻訳 (LANG、PROVIDER、MODEL パラメータ) |
-
-### 例
-
-
-
-```console
-# コードをフォーマットしてすべてのチェックを実行
-$ make format lint
-Running isort...
-Running black...
-Running mypy...
-✅ All checks passed!
-
-# カバレッジ付きでテスト実行
-$ make test-coverage
-======================== test session starts ========================
-collected 45 items
-tests/test_cli.py::test_init_command PASSED
-...
-======================== 45 passed in 2.34s ========================
-
----------- coverage: platform darwin, python 3.12.1-final-0 ----------
-Name Stmts Miss Cover
---------------------------------------------
-src/main.py 45 2 96%
-src/cli.py 89 5 94%
-src/templates.py 67 3 96%
---------------------------------------------
-TOTAL 201 10 95%
-
-# HTML カバレッジレポートを生成
-$ make coverage-report FORMAT=html
-🌐 Opening HTML coverage report in browser...
-
-# ドキュメントを韓国語へ翻訳
-$ make translate LANG=ko PROVIDER=github MODEL=gpt-4o-mini
-Starting translation...
-Running: python scripts/translate.py --target-lang ko --api-provider github --model gpt-4o-mini
-```
-
-
-
-## プロジェクト構造
-
-開発の前にプロジェクト構造を理解しておきましょう:
-
-```bash
-FastAPI-fastkit/
-├── src/
-│ ├── fastapi_fastkit/
-│ │ ├── __main__.py # アプリのエントリポイント
-│ │ ├── backend/
-│ │ │ ├── inspector.py # FastAPI-fastkit テンプレートインスペクタ
-│ │ │ ├── interactive/
-│ │ │ │ ├── config_builder.py # 対話型モードの設定ビルダー
-│ │ │ │ ├── prompts.py # 対話型モードのプロンプト
-│ │ │ │ ├── selectors.py # 対話型モードのセレクタ
-│ │ │ │ └── validators.py # 対話型モードの入力バリデータ
-│ │ │ ├── main.py # バックエンドのロジックエントリポイント
-│ │ │ ├── package_managers/
-│ │ │ │ ├── base.py # パッケージマネージャーのベースクラス
-│ │ │ │ ├── factory.py # パッケージマネージャーファクトリ
-│ │ │ │ ├── pdm_manager.py # PDM パッケージマネージャー
-│ │ │ │ ├── pip_manager.py # pip パッケージマネージャー
-│ │ │ │ ├── poetry_manager.py # Poetry パッケージマネージャー
-│ │ │ │ └── uv_manager.py # uv パッケージマネージャー
-│ │ │ ├── project_builder/
-│ │ │ │ ├── config_generator.py # 設定ジェネレータ
-│ │ │ │ └── dependency_collector.py # 依存関係収集
-│ │ │ └── transducer.py # プロジェクトビルダー用トランスデューサ
-│ │ ├── cli.py # FastAPI-fastkit のメイン CLI エントリポイント
-│ │ ├── core/
-│ │ │ ├── exceptions.py # 例外処理
-│ │ │ └── settings.py # 設定
-│ │ ├── fastapi_project_template/
-│ │ │ ├── PROJECT_README_TEMPLATE.md # fastkit テンプレート用 README ベース
-│ │ │ ├── README.md # fastkit テンプレートの README
-│ │ │ ├── fastapi-custom-response/
-│ │ │ ├── fastapi-default/
-│ │ │ ├── fastapi-empty/
-│ │ │ ├── fastapi-hello/
-│ │ │ ├── fastapi-mcp/
-│ │ │ ├── fastapi-single-module/
-│ │ │ └── modules/
-│ │ │ ├── api/
-│ │ │ │ └── routes/
-│ │ │ ├── crud/
-│ │ │ └── schemas/
-│ │ ├── py.typed
-│ │ └── utils/
-│ │ ├── logging.py # ロギング設定
-│ │ └── main.py # FastAPI-fastkit のメインエントリポイント
-│ └── logs
-├── tests
-│ ├── conftest.py # pytest 設定
-│ ├── test_backends/
-│ ├── test_cli_operations/
-│ ├── test_core.py
-│ ├── test_rich/
-│ ├── test_templates/
-│ └── test_utils.py
-├── uv.lock
-├── docs/ # ドキュメント
-├── scripts/ # 開発スクリプト
-├── mkdocs.yml
-├── overrides/ # mkdocs オーバーライド
-├── pdm.lock
-├── pyproject.toml
-├── requirements-docs.txt # ドキュメント用依存
-├── requirements.txt # 開発用依存
-├── CHANGELOG.md
-├── CITATION.cff
-├── CODE_OF_CONDUCT.md
-├── CONTRIBUTING.md
-├── LICENSE
-├── MANIFEST.in
-├── Makefile
-├── README.md
-├── SECURITY.md
-└── env.example # 環境変数の例 (翻訳用 AI モデルの env を構成)
-```
-
-### 主要ディレクトリ
-
-- **`src/fastapi_fastkit/`** — メインパッケージのソース
- - **`cli.py`** — メイン CLI のエントリポイント
- - **`backend/`** — コアのバックエンドロジック
- - **`inspection/`** — テンプレート検査パイプライン (context、checks、consistency、freshness、smoke、lint、report)
- - **`inspector.py`** — `inspection/` に対するファサード。従来の import パスのために残されている
- - **`interactive/`** — 対話型モードの構成要素 (プロンプト、セレクタ、バリデータ)
- - **`package_managers/`** — パッケージマネージャー実装 (pip、uv、pdm、poetry)
- - **`project_builder/`** — プロジェクト構築ユーティリティ (フラグメント駆動の設定ジェネレーターを含む)
- - **`scaffolder.py`** — `init` と `startdemo` が共有する生成パイプライン
- - **`transducer.py`** — テンプレートトランスデューサ
- - **`core/`** — コアの設定と例外
- - **`fragments/`** — 生成されるプロジェクトにレンダリングされる Jinja2 フラグメント (前述)
- - **`fastapi_project_template/`** — プロジェクトテンプレート (fastapi-default、fastapi-domain-starter など)
- - **`utils/`** — 共有ユーティリティ
-- **`tests/`** — テストスイート
- - **`test_backends/`** — バックエンド固有のテスト
- - **`test_cli_operations/`** — CLI 操作のテスト
- - **`test_templates/`** — テンプレートシステムのテスト
-- **`docs/`** — ドキュメント (MkDocs)
- - ユーザーガイド、チュートリアル、API リファレンス
-
-## 開発ワークフロー
-
-### 1. 機能ブランチを作成
-
-
-
-```console
-$ git checkout -b feature/add-new-template
-Switched to a new branch 'feature/add-new-template'
-```
-
-
-
-### 2. 変更を実装
-
-コードを編集し、機能を追加・バグを修正します...
-
-### 3. テストとチェックを実行
-
-
-
-```console
-$ make dev-check
-Running all quality checks...
-Running all tests...
-✅ All tests passed!
-```
-
-
-
-### 4. 変更をコミット
-
-pre-commit フックが自動的に実行されます:
-
-
-
-```console
-$ git add .
-$ git commit -m "Add new FastAPI template with authentication"
-format...................................................................Passed
-isort-check..............................................................Passed
-black-fix................................................................Passed
-mypy.....................................................................Passed
-[feature/add-new-template abc1234] Add new FastAPI template with authentication
-```
-
-
-
-### 5. push して PR を作成する
-
-
-
-```console
-$ git push origin feature/add-new-template
-$ gh pr create --title "Add new FastAPI template with authentication"
-```
-
-
-
-## テスト
-
-### テストの実行
-
-**すべてのテスト:**
-
-
-
-```console
-$ make test
-# または
-$ python -m pytest
-```
-
-
-
-**特定のテストファイル:**
-
-
-
-```console
-$ python -m pytest tests/test_cli.py -v
-```
-
-
-
-**カバレッジ付き:**
-
-
-
-```console
-$ make test-coverage
-# または
-$ python -m pytest --cov=src --cov-report=html
-```
-
-
-
-### テストの書き方
-
-新機能を追加する際は、必ずテストも含めてください:
-
-```python
-# tests/test_commands/test_new_feature.py
-import pytest
-from fastapi_fastkit.commands.new_feature import NewFeatureCommand
-
-class TestNewFeatureCommand:
- def test_command_success(self):
- """Test successful command execution"""
- command = NewFeatureCommand()
- result = command.execute(valid_args)
- assert result.success is True
- assert result.message == "Feature executed successfully"
-
- def test_command_validation_error(self):
- """Test command with invalid arguments"""
- command = NewFeatureCommand()
- with pytest.raises(ValueError, match="Invalid argument"):
- command.execute(invalid_args)
-
- def test_command_edge_case(self):
- """Test edge case handling"""
- command = NewFeatureCommand()
- result = command.execute(edge_case_args)
- assert result.success is True
- assert "warning" in result.message.lower()
-```
-
-### テストの種類
+| コマンド | 内容 |
+| --- | --- |
+| `make format` | isort で import を並べ替え、black で整形します。 |
+| `make format-check` | `make format` が何を変更するかを、実際には変更せずに表示します。 |
+| `make lint` | isort と black をチェックモードで実行し、続いて `mypy src`(strict)を実行します。 |
+| `make dev-check` | `make format-check`、`make lint`、`make test` を実行します。 |
+| `make dev-setup` | pip を使って、開発ツール、ドキュメント用の依存関係、pre-commit のフックと一緒に fastkit をインストールします。 |
+| `make help` | すべてのターゲットを一覧表示します。 |
-**単体テスト** — 個別の関数やクラスをテスト:
+pre-commit のフックは、同じ isort、black、mypy のコマンドに加えて、空白、ファイル末尾、YAML、TOML のチェックを実行します。
-```python
-def test_validate_project_name():
- assert validate_project_name("valid-name") is True
- assert validate_project_name("invalid name!") is False
-```
-
-**統合テスト** — コマンドの相互作用をテスト:
-
-```python
-def test_init_command_creates_project(tmp_path):
- result = runner.invoke(cli, ['init'], input='test-project\n...')
- assert result.exit_code == 0
- assert (tmp_path / "test-project").exists()
-```
+## コードのルール
-**エンドツーエンドテスト** — 完全なワークフローをテスト:
+- `src/fastapi_fastkit/` の下のコード(テンプレートを除く)は、テキストファイルの読み書きに `src/fastapi_fastkit/utils/textio.py` を使います。このモジュールは UTF-8 を指定し、改行コードを明示的に保持または設定します。
+- `subprocess` の呼び出しには、必ず `encoding="utf-8", errors="replace"` を渡します。
+- プラットフォームごとの違い(Windows での仮想環境のパス、実行ファイル、コンソールのエンコーディング、ファイルの削除)は、`src/fastapi_fastkit/utils/platform.py` を通して扱います。
+- テストは Windows でも成功する必要があります。`/tmp` をハードコードせず、期待するパスを `/` で連結せず、`chmod` のテストには POSIX 以外でスキップする指定を付けます。Windows 用の分岐をテストするときは、`src/fastapi_fastkit/utils/platform.py` にある判定をパッチしてください。`os.name` は決してパッチしないでください。
+- 各ファイルの改行コードはそのまま保ちます。
+- 新しいコードには、振る舞いを確かめるテストを付けます。
-```python
-def test_full_project_creation_workflow(tmp_path):
- # プロジェクトを作成
- result = runner.invoke(cli, ['init'], input='...')
- assert result.exit_code == 0
+### オプションと生成されるコード
- # ルートを追加
- result = runner.invoke(cli, ['addroute', 'test-project', 'users'])
- assert result.exit_code == 0
+`fastkit init` が提示するオプション、それぞれのパッケージ、オプション同士のルールは `src/fastapi_fastkit/catalog/catalog.toml` で定義されています。新しいオプションは、このファイルの該当する機能グループと、`src/fastapi_fastkit/core/settings.py` にある対応するオプションのリストの両方に追加します。両者が一致しない場合は `tests/test_catalog/test_agreement.py` が失敗します。
- # ファイルが存在することを検証
- assert (tmp_path / "test-project" / "src" / "api" / "routes" / "users.py").exists()
-```
+機能がプロジェクトに追加するファイルは、`src/fastapi_fastkit/fragments/` の下にある Jinja2 テンプレートです。Python で組み立てた文字列は決して使いません。ディレクトリの構成と機能を追加する手順は `src/fastapi_fastkit/fragments/README.md` にまとめてあります。どのフラグメントも改行で終わります。
## ドキュメント
-### ドキュメントをローカルで配信
-
-
+サイトは MkDocs と Material でビルドします。`pdm install -G docs` または `pip install -r requirements-docs.txt` でドキュメント用の依存関係をインストールし、CI と同じ方法でサイトをビルドします。
```console
-$ make serve-docs
-INFO - Building documentation...
-INFO - Cleaning site directory
-INFO - Documentation built in 0.43 seconds
-INFO - [14:30:00] Serving on http://127.0.0.1:8000/
+$ mkdocs build --strict -d site
```
-
-
-### ドキュメントのビルド
-
-
-
-```console
-$ make build-docs
-INFO - Building documentation...
-INFO - Documentation built in 0.43 seconds
-```
-
-
-
-### ドキュメントの書き方
-
-ドキュメントは Markdown で書かれ、MkDocs でビルドされます。例の構造:
-
-**機能ガイドのテンプレート:**
-
-````markdown
-# New Feature Guide
-
-This guide explains how to use the new feature.
-
-## Prerequisites
-
-- FastAPI-fastkit installed
-- Basic Python knowledge
-
-## Usage
-
-
-
-```console
-$ fastkit new-feature --option value
-✅ Feature executed successfully!
-```
-
-
-
-!!! tip "Pro Tip"
- Use `--help` to see all available options.
-````
-
-`mkdocs-material` の詳しい使い方は、[mkdocs-material のドキュメント](https://squidfunk.github.io/mkdocs-material/reference/admonitions/) を参照してください。
-
-## コードスタイルガイドライン
-
-### Python のコードスタイル
+`make serve-docs` を実行すると、編集しているあいだ `http://127.0.0.1:8000/` でサイトを確認できます。`make build-docs` は `--strict` なしでビルドします。英語のページは `docs/en/` にあり、ほかの言語については[翻訳ガイド](translation-guide.md)で説明しています。
-[PEP 8](https://www.python.org/dev/peps/pep-0008/) に従い、次の固有ルールを採用:
+### 生成ブロック
-- **行長**: 88 文字 (Black デフォルト)
-- **import**: isort で整理
-- **型ヒント**: すべての公開関数で必須
-- **docstring**: すべての公開 API で Google スタイル
+リファレンスの表とヘルプテキストは、ページ内の 2 つのコメント行のあいだに置かれ、カタログと CLI からレンダリングされます。
-### 例
-
-```python
-from typing import List, Optional
-from pathlib import Path
-
-def create_project_structure(
- project_name: str,
- template_path: Path,
- output_dir: Optional[Path] = None,
-) -> List[Path]:
- """Create project structure from template.
-
- Args:
- project_name: Name of the project to create
- template_path: Path to the template directory
- output_dir: Output directory, defaults to current directory
-
- Returns:
- List of created file paths
-
- Raises:
- ValueError: If project_name is invalid
- FileNotFoundError: If template_path doesn't exist
- """
- if not project_name.isidentifier():
- raise ValueError(f"Invalid project name: {project_name}")
-
- if not template_path.exists():
- raise FileNotFoundError(f"Template not found: {template_path}")
-
- # 実装 ...
- return created_files
-```
-
-## 環境変数
-
-開発時には次の環境変数を設定できます:
-
-| 変数 | 説明 | デフォルト |
-|---|---|---|
-| `FASTKIT_DEBUG` | デバッグログを有効化 | `False` |
-| `FASTKIT_DEV_MODE` | 開発機能を有効化 | `False` |
-| `FASTKIT_TEMPLATE_DIR` | カスタムテンプレートディレクトリ | 組み込みテンプレート |
-| `FASTKIT_CONFIG_DIR` | 設定ディレクトリ | `~/.fastkit` |
-| `TRANSLATION_API_KEY` | 翻訳 API キー ([Github AI モデルプロバイダ](https://github.com/marketplace/models/azure-openai) を使う場合は GitHub PAT を指定) | `None` |
-
-
-
-```console
-$ export FASTKIT_DEBUG=true
-$ export FASTKIT_DEV_MODE=true
-$ fastkit init
-DEBUG: Loading configuration from /home/user/.fastkit/
-DEBUG: Available templates: ['fastapi-default', ...]
-```
-
-
-
-ほかの環境変数設定については、[@settings.py](https://github.com/bnbong/FastAPI-fastkit/blob/main/src/fastapi_fastkit/core/settings.py) モジュールを参照してください。
-
-## トラブルシューティング
-
-### よくある問題
-
-**1. pre-commit フックが失敗する:**
-
-
-
-```console
-$ git commit -m "Fix bug"
-black....................................................................Failed
-hookid: black
-
-Files were modified by this hook. Additional output:
-
-would reformat src/cli.py
-```
-
-
-
-**解決策:** フォーマッタを実行し、再度コミット:
-
-
-
-```console
-$ make format
-$ git add .
-$ git commit -m "Fix bug"
-```
-
-
-
-**2. 異なる Python バージョンでテストが失敗する:**
-
-**解決策:** tox で複数の Python バージョンをテスト:
-
-
-
-```console
-$ pip install tox
-$ tox
-py38: commands succeeded
-py39: commands succeeded
-py310: commands succeeded
-py311: commands succeeded
-py312: commands succeeded
+```markdown
+
+...
+
```
-
-
-**3. 開発時の import エラー:**
-
-**解決策:** editable モードでインストール:
-
+ブロックの中は決して編集しないでください。カタログ、コマンドのヘルプテキスト、doctor のチェックを変更した後や、ブロック(あいだに何もない 2 つのコメント行)を追加した後は、スクリプトを実行します。
```console
-$ pip install -e .
+$ python scripts/docs_blocks.py
+$ python scripts/docs_blocks.py --check
```
-
-
-### ヘルプ
-
-- **[GitHub Issues](https://github.com/bnbong/FastAPI-fastkit/issues)**: バグ報告と機能リクエスト
-- **[GitHub Discussions](https://github.com/bnbong/FastAPI-fastkit/discussions)**: 質問とアイデア共有
-- **ドキュメント**: [ユーザーガイド](../user-guide/installation.md) を参照
+1 つ目のコマンドは、古くなったブロックをすべて書き直します。`--check` は古くなったブロックを一覧表示して終了ステータス 1 で終了します。どちらも `--lang ko` を付けると 1 つの言語だけを対象にします。古くなったブロックがあるあいだは `tests/test_docs` が失敗します。
-## コントリビュートガイドライン
+### ページのルール
-### PR 提出前
+`tests/test_docs` は英語のページもチェックします。
-1. **すべてのチェックを実行:** `make dev-check`
-2. 必要に応じて **ドキュメントを更新**
-3. 新機能には **テストを追加**
-4. **コミットメッセージ規約に従う**
+- `docs/en/` の下のすべてのページが `mkdocs.yml` の `nav` に含まれ、`nav` のすべての項目に対応するページが存在すること。
+- FastAPI のドキュメントへのリンクが、カタログの概念(生成される `concepts` ブロック)のアドレスか、`tests/test_docs/test_site_structure.py` に列挙されたアドレスを使っていること。
+- プルリクエストや issue の番号を書かないこと。
-### コミットメッセージ形式
+```` ```console ```` ブロックでは、各コマンドの前に `$ ` を付け、行を `# ` で始めないでください。コピーボタンはそのような行をコマンドとしてコピーしてしまいます。コメントはコマンドの後ろに書いてください。
-```
-type(scope): brief description
-
-Longer description if needed
-
-Fixes #123
-```
+### ページを移動または削除するとき
-**種別:**
+`scripts/mkdocs_hooks/redirects.py` の `REDIRECTS` に古いパスを追加し、値に新しいアドレスを指定します。ビルドのたびに、このフックはすべての言語で古いアドレスにページを書き出し、そのページが読者を新しいアドレスへ案内します。`tests/test_docs/test_redirects.py` は、古いパスがページとして残っていないこと、そしてすべてのリダイレクト先が存在することをチェックします。
-- `feat`: 新機能
-- `fix`: バグ修正
-- `docs`: ドキュメント変更
-- `style`: コードスタイル変更
-- `refactor`: リファクタリング
-- `test`: テストの追加・変更
-- `chore`: メンテナンス作業
+### Web ジェネレーターのページ
-**例:**
+`docs/en/start/web-generator.md` のページは、Pyodide を使ってブラウザー上で fastkit を実行します。このページは `scripts/web_generator/build_assets.py` が fastkit の wheel からビルドするファイルを読み込むので、ページをプレビューする前にそれらをビルドしてください。後で説明する比較には Node.js(CI は 22 を使います)が必要です。また、wheel は編集可能モードのインストールを置き換えるため、fastkit を再インストールしてもよい仮想環境が必要です。
+```bash
+python -m pip wheel --no-deps -w dist .
+python -m pip install dist/fastapi_fastkit-*.whl
+python scripts/web_generator/build_assets.py --wheel dist/fastapi_fastkit-*.whl \
+ --out docs/en/assets/fastkit-generator
+make serve-docs
```
-feat(cli): add new template command
-
-Add support for creating projects from custom templates.
-The command accepts a template path and creates a new
-project with the specified configuration.
-
-Fixes #45
-fix(templates): handle missing template files gracefully
+続いて、ローカルサーバーで `/start/web-generator/` を開きます。最初のビルドでは Pyodide を `.cache/web-generator` にダウンロードし、すべてのファイルを固定したチェックサムと照合します(`--no-cache` を付けるとキャッシュを使いません)。`docs/en/assets/fastkit-generator/` と `.cache/web-generator/` は git の管理対象外で、コミットされることはありません。アセットがない場合、ページにはジェネレーターのファイルがビルドされていないというメッセージが表示されます。
-When a template file is missing, show a clear error message
-instead of crashing with a stack trace.
+ページがコマンドラインと同じプロジェクトを作成することを確かめるには、フィクスチャファイルのすべてのケースを、Node 上でページのジェネレーターに通し、インストールした wheel の `fastkit` コマンドにも通します。
-Fixes #67
+```bash
+python scripts/web_generator/compare_with_cli.py \
+ --assets docs/en/assets/fastkit-generator \
+ --cases tests/fixtures/web_generator/cases.json
```
-## リリースプロセス
-
-メンテナー向けのリリース手順:
-
-1. `setup.py` と `__init__.py` で **バージョンを更新**
-2. **CHANGELOG.md を更新**
-3. **リリース PR を作成**
-4. マージ後に **タグを付与**
-5. **GitHub Actions** が自動でビルドおよび公開
-
-
-
-```console
-$ git tag v1.2.0
-$ git push origin v1.2.0
-```
+一部のケースだけを実行するには `--only 01-hello,03-layered` を追加し(フィクスチャにある id を使います)、両方の出力を残すには `--keep DIR` を追加します。ページからダウンロードした zip を 1 つ、その横に表示されたコマンドの結果と比較するには、`compare_with_cli.py --zip demo.zip -- init --project-name demo ...` を使います。ビルドしたサイトをチェックするには、`mkdocs build --strict -d site` を実行してから `python scripts/web_generator/check_site.py site` を実行します。
-
+各言語のページの文字列は `docs/js/web-generator-strings/.json` にあり、レベルと機能のテキストは `src/fastapi_fastkit/catalog/i18n/` にあるカタログのオーバーレイから取得します。すべての言語が同じキーとプレースホルダーを持っていることは `tests/test_docs` がチェックします。
-## 次のステップ
+CI では、`src/`、`docs/`、`README.md`、`CHANGELOG.md`、ドキュメントと Web ジェネレーターのスクリプト、`pyproject.toml`、`mkdocs.yml` のいずれかを変更するプルリクエストと、`main` へのプッシュで Web generator ワークフローが実行されます。このワークフローは wheel とアセットをビルドし、すべてのケースをコマンドラインと比較し、ドキュメントのサイトを strict モードでビルドしてから、7 言語すべてでページをチェックします。ドキュメントのデプロイでは、`mkdocs gh-deploy --strict` で公開する前に、同じビルドと比較をもう一度実行します。
-開発環境が整ったら:
+## プルリクエスト
-1. アーキテクチャを把握するため [**コードベースを探索**](https://github.com/bnbong/FastAPI-fastkit/tree/main/src/fastapi_fastkit) する
-2. **テストスイートを実行** してすべて動作することを確認
-3. GitHub から取り組む [**Issue**](https://github.com/bnbong/FastAPI-fastkit/issues) を選ぶ
-4. ほかの貢献者とつながるため [**Discussions**](https://github.com/bnbong/FastAPI-fastkit/discussions) に参加
+プルリクエストのタイトルは、`CONTRIBUTING.md` に定められたタグ(`[FEAT]`、`[FIX]`、`[DOCS]`、`[STYLE]`、`[TEST]`、`[REFACTOR]`、`[CHORE]`)で始めます。たとえば `[FIX] Fix virtual environment activation in Windows` のように書きます。プッシュする前に `make dev-check` を実行してください。テンプレートを変更するプルリクエストでは、[テンプレートガイド](template-creation-guide.md#checks)で説明しているテンプレートの検査も実行されます。
-Happy coding! 🚀
+## リリース
-!!! tip "開発のヒント"
- - コミット前に `make dev-check` を実行
- - テストを先に書く (TDD アプローチ)
- - コミットは小さく、焦点を絞る
- - 新機能には合わせてドキュメントを更新
+1. `src/fastapi_fastkit/__init__.py` の `__version__` を設定します。パッケージのバージョンはここから読み取られます。
+2. `CHANGELOG.md` に、`## vX.Y.Z` の見出しの下にリリースを追加します。各項目は 1〜2 文で書き、プルリクエストの番号や内部の関数名は書きません。
+3. GitHub でリリースを公開します。すると Distribute ワークフローがリリースのタグを `src/fastapi_fastkit/__init__.py` に書き込み、PDM でパッケージをビルドして PyPI に公開します。
diff --git a/docs/ja/contributing/template-creation-guide.md b/docs/ja/contributing/template-creation-guide.md
index 910cc015..45795cab 100644
--- a/docs/ja/contributing/template-creation-guide.md
+++ b/docs/ja/contributing/template-creation-guide.md
@@ -1,580 +1,182 @@
-# FastAPI テンプレート作成ガイド
+# テンプレートガイド
-FastAPI-fastkit に新しい FastAPI プロジェクトテンプレートを追加するための包括的なガイドです。
+このページでは、同梱のテンプレートの構成、カタログへの登録方法、すべてのテンプレートが従う規約、テンプレートに対して実行されるチェックについて説明します。先に[開発環境のセットアップ](development-setup.md)に従ってリポジトリを準備してください。
-## 🎯 概要
+## テンプレートの構成
-新しいテンプレートの追加は、次の 5 ステップで進めます:
+各テンプレートは `src/fastapi_fastkit/fastapi_project_template/` の下にあるフォルダーで、テンプレート id(`fastapi-`、たとえば `fastapi-auth-jwt`)がフォルダー名になります。同じ場所にある `modules/` はテンプレートではありません。このフォルダーには `fastkit addroute` が書き出すファイルが入っています。
-1. **📋 計画と設計** — テンプレートの目的と構成を定義
-2. **🏗️ テンプレートの実装** — 必要な構造とファイルを作成
-3. **🔍 ローカル検証** — インスペクタでテンプレートを検証
-4. **📚 ドキュメント** — README と利用ガイドを記述
-5. **🚀 提出とレビュー** — PR を作成しコミュニティのレビューを受ける
+名前が `-tpl` で終わるファイルは、fastkit がテンプレートをコピーするときにこの接尾辞が取り除かれます。`src/main.py-tpl` は `src/main.py` に、`.env.example-tpl` は `.env.example` になります。Python のファイルはすべて `.py-tpl` で終わる必要があり、ただの `.py` ファイルがあると検査は失敗します。生成時には、コピーしたファイルの中の 4 つのプレースホルダー、``、``、``、`` が置き換えられます。
-## 📋 ステップ 1: 計画と設計
+テンプレートには、少なくとも次のものが必要です。
-### テンプレートの目的を定義する
+- `README.md-tpl`。
+- `[project].dependencies` に `fastapi` を含む `pyproject.toml-tpl`。
+- `test_*.py-tpl` のモジュールを 1 つ以上含む `tests/` フォルダー。
-新しいテンプレートを作る前に、次の問いに答えてください:
-
-- **このテンプレート固有の価値は何か?**
-- **既存のテンプレートとどう差別化されるか?**
-- **どのユーザー層が想定読者か?**
-- **どんな技術スタックを含めるか?**
-
-### テンプレートの命名規則
+ほとんどのテンプレートには次のファイルも含まれています。`fastapi-default` からコピーして、テンプレートに合わせて変更してください。
+```text
+fastapi-default/
+├── .env.example-tpl
+├── .gitattributes-tpl
+├── .gitignore-tpl
+├── README.md-tpl
+├── pyproject.toml-tpl
+├── requirements-dev.txt-tpl
+├── requirements.txt-tpl
+├── scripts/
+├── src/
+│ ├── api/
+│ ├── core/
+│ ├── crud/
+│ ├── main.py-tpl
+│ ├── mocks/
+│ └── schemas/
+└── tests/
```
-fastapi-{purpose}-{stack}
-```
-
-例:
-- `fastapi-microservice` (マイクロサービステンプレート)
-- `fastapi-graphql` (GraphQL 統合テンプレート)
-- `fastapi-auth-jwt` (JWT 認証テンプレート)
+`template-config.yml-tpl` は省略でき、検査のときにだけ読み込まれます。たとえば `requires_docker: true` を指定するとテンプレートのテストをその Docker Compose 環境の中で実行し、`app_module` はスモークテストで使うアプリケーションを指定します。このファイルが生成されたプロジェクトにコピーされることはありません。
-### 技術スタックの計画
+## テンプレートをカタログに登録する
-含めるメイン技術を事前に定義します:
+`src/fastapi_fastkit/catalog/catalog.toml` に `[[templates]]` のエントリーを追加します。エントリーの順序が、`fastkit list-templates` で表示される順序になります。
-```yaml
-# 例: fastapi-microservice テンプレート
-core_dependencies:
- - fastapi
- - uvicorn
- - pydantic
- - pydantic-settings
-
-additional_features:
- - sqlalchemy (ORM)
- - alembic (マイグレーション)
- - redis (キャッシュ)
- - celery (バックグラウンドタスク)
- - pytest (テスト)
-
-development_tools:
- - black (コードフォーマット)
- - isort (import ソート)
- - mypy (型チェック)
- - pre-commit (Git フック)
+```toml title="src/fastapi_fastkit/catalog/catalog.toml"
+[[templates]]
+id = "fastapi-auth-jwt"
+kind = "example"
+description = "FastAPI JWT Authentication"
+read_first = "Read `src/app/main.py`, then `src/app/domains/auth/` and `src/app/core/security.py`."
+addroute = false
```
-## 🏗️ ステップ 2: テンプレートの実装
+| キー | 意味 |
+| --- | --- |
+| `id` | フォルダー名です。エントリーとフォルダーは過不足なく一致している必要があります。 |
+| `kind` | `level`(レベルから使われる)、`example`(`fastkit init --template` で使われる)、`internal`(同梱されているが選択肢には出さない)のいずれかです。新しいサンプルプロジェクトには `example` を使います。 |
+| `description` | `README.md-tpl` の最初の見出しから `# ` を除いたテキストです。 |
+| `read_first` | Next steps のリストにある「最初に読む」ステップのテキストです。`level` と `example` では必須です。バッククォートで囲んだパスはすべてテンプレート内に存在する必要があります。 |
+| `extend` | 「拡張する」ステップのテキストで、省略できます。 |
+| `concepts` | テンプレートがコメントとして持つ `[[concepts]]` エントリーの id です。該当するものがなければ省略します。 |
+| `addroute` | Next steps のリストで `fastkit addroute` を提案してはいけない場合に `false` にします。既定値は `true` です。 |
-### 必須ディレクトリ構造
+カタログのローダーは、未知のキーと未知の概念 id を受け付けません。エントリーとそのフォルダー、または README の見出しが一致しない場合は `tests/test_catalog/test_agreement.py` が失敗します。翻訳した `description`、`read_first`、`extend` も、各言語の `src/fastapi_fastkit/catalog/i18n/.toml` オーバーレイに追加してください。すべての言語にそろうまで、オーバーレイのテストは失敗します([翻訳ガイド](translation-guide.md#catalog-overlays)を参照してください)。
-```
-fastapi-{template-name}/
-├── src/ # アプリケーションのソース
-│ ├── main.py-tpl # ✅ FastAPI アプリのエントリポイント (必須)
-│ ├── __init__.py-tpl
-│ ├── api/ # API ルーター
-│ │ ├── __init__.py-tpl
-│ │ ├── api.py-tpl # メインの API ルーター
-│ │ └── routes/ # 個別ルート
-│ │ ├── __init__.py-tpl
-│ │ └── items.py-tpl # サンプルルート
-│ ├── core/ # コア設定
-│ │ ├── __init__.py-tpl
-│ │ └── config.py-tpl # 設定管理
-│ ├── crud/ # CRUD ロジック
-│ │ ├── __init__.py-tpl
-│ │ └── items.py-tpl
-│ ├── schemas/ # Pydantic モデル
-│ │ ├── __init__.py-tpl
-│ │ └── items.py-tpl
-│ └── utils/ # ユーティリティ
-│ ├── __init__.py-tpl
-│ └── helpers.py-tpl
-├── tests/ # ✅ テスト (必須)
-│ ├── __init__.py-tpl
-│ ├── conftest.py-tpl # pytest 設定
-│ └── test_items.py-tpl # サンプルテスト
-├── scripts/ # スクリプト
-│ ├── format.sh-tpl # コードフォーマット
-│ ├── lint.sh-tpl # リンティング
-│ ├── run-server.sh-tpl # サーバー起動
-│ └── test.sh-tpl # テスト実行
-├── pyproject.toml-tpl # ✅ 一次メタデータ (PEP 621、必須)
-├── requirements.txt-tpl # 🟡 pyproject が依存関係を宣言する場合は任意
-├── setup.cfg-tpl # 開発ツール設定
-├── README.md-tpl # ✅ プロジェクトドキュメント (必須)
-├── .env-tpl # 環境変数テンプレート
-└── .gitignore-tpl # Git ignore ファイル
-```
+## 規約
-**最低限必要なファイル。** テンプレートは次を提供する必要があります:
+### HTTP API
-- `tests/` ディレクトリ
-- `README.md-tpl`
-- `pyproject.toml-tpl` (PEP 621)
-- `pyproject.toml-tpl` の `[project].dependencies` または `requirements.txt-tpl` に `fastapi` を依存関係として宣言
+業務用のルートを持つテンプレートは、[生成されるプロジェクト](../reference/generated-projects.md#http-api)で説明している API に従います。ルートは `settings.API_V1_PREFIX` の下に置き、ルートパス直下にある `GET /health` は `{"status": "ok"}` を返します。リストは `limit` と `offset` を受け取って `Page[XRead]` を返し、作成時は `Location` 付きの 201、削除時は 204 を返します。`PUT` は置き換え、`PATCH` は部分更新を行い、見つからない場合は 404 と `{"detail": " not found"}` を返します。スキーマ名は `XCreate`、`XUpdate`、`XRead` です。ルーターが持つのは自分のリソースのプレフィックスだけです(`APIRouter(prefix="/items", tags=["items"])`)。
-`requirements.txt-tpl` は、`pyproject.toml-tpl` が `[project].dependencies` を宣言している場合は不要です — ただし、テンプレートが両方を提供する場合は内容が一致している必要があります: 両者の間で依存関係が食い違っていると検査は失敗します。
+テンプレートに `core/pagination.py-tpl` と `core/responses.py-tpl` を含める場合、それらは `fastapi_project_template/modules/core/` にあるファイルとまったく同じでなければなりません。リポジトリのテストがすべてのコピーを比較します。
-**新しいテンプレートは pyproject を第一とし、`setup.py-tpl` を含めてはいけません。** v1.4.0 時点で、同梱テンプレートに `setup.py-tpl` を持つものはありません。リポジトリ外のテンプレートが引き続き動作するよう検査はこのファイルをまだ受け付けますが、これはレガシーな経路です。
+### 設定とシークレット
-**Python 3.12 を一貫してターゲットにする**: `requires-python = ">=3.12"`、black の `target-version = ["py312"]`、mypy の `python_version = "3.12"`、そして Docker のベースイメージには `python:3.12-slim` を使います。検査では 3 つのピン指定が一致しているかを確認します。
+- pydantic-settings を使った 1 つの設定モジュールが、環境変数と `.env` を読み込みます。`SECRET_KEY` のチェックと、公開されているサンプルのキーの一覧は `fastapi-default/src/core/config.py-tpl` からコピーしてください。`ENVIRONMENT=staging` または `production` のとき、アプリケーションは `SECRET_KEY` が未設定、公開済みのキー、または短すぎる(32 バイト未満)場合に起動を拒否します。
+- プレースホルダーの値を入れた `.env.example-tpl` を含め、`.env-tpl` は決して含めません。fastkit はこのファイルから、固有の `SECRET_KEY` を入れた `.env` を作成します。
+- `.gitignore-tpl` は `.env` と `.env.*` を無視し、`!.env.example` で例外として含め直します。
+- `.gitattributes-tpl` は、シェルスクリプト、Docker 関連のファイル、`Makefile`、env ファイルの改行コードを LF に固定します。
+- CORS のオリジンは `BACKEND_CORS_ORIGINS` からだけ取得し、`*` の場合は認証情報(credentials)を無効にします。
-**生成されるプロジェクトのランタイム依存関係として `FastAPI-fastkit` を宣言してはいけません。** CLI は開発ツールです。テンプレートの依存関係リストには、生成されたアプリケーション自体が import するものだけを含めるべきです。
+### 依存関係とツール
-### ファイル作成ガイド
+- どこでも Python 3.12 を対象にします。`requires-python = ">=3.12"`、black の `target-version = ["py312"]`、mypy の `python_version = "3.12"`、Docker のベースイメージには `python:3.12-slim` を使います。検査では最初の 3 つをチェックします。
+- 実行時のパッケージは `[project].dependencies` と `requirements.txt-tpl` に、テストとリントのツールは `dev` 依存関係グループと `requirements-dev.txt-tpl` に入れます。`requirements-dev.txt-tpl` は `-r requirements.txt` で始めます。`Dockerfile-tpl` がインストールするのは `requirements.txt` だけです。`[project].dependencies` のパッケージが `requirements.txt-tpl` に欠けていると、検査は失敗します。
+- `FastAPI-fastkit` を生成されたプロジェクトの依存関係に含めてはいけません。
+- `managed = true` を持つ `[tool.fastapi-fastkit]` テーブルと、`description` の先頭にある `[FastAPI-fastkit templated]` は残してください。ブロックの残りの部分は、生成時に fastkit が埋めます。
+- ツールの設定はすべて `pyproject.toml-tpl` に書きます(`[tool.pytest.ini_options]`、`[tool.coverage.*]`、`[tool.black]`、`[tool.isort]`、`[tool.mypy]`、`[tool.ruff]`)。`setup.cfg-tpl` や `pytest.ini-tpl` を含むテンプレートはありません。`fastapi-hello` 以外のすべてのテンプレートは、`fastkit init --feature tooling=ruff` が書き出すものと同じ `[tool.ruff]` ブロックを含み、生成されたプロジェクトは black、isort、`ruff check`、`ruff format --check` のすべてに通る必要があります。`fastapi-hello` より後のレベルのテンプレートは、`dev` グループに pytest-cov、black、isort、mypy、ruff も含み、カバレッジの設定も持っています。そのため、これらから作成したどのプロジェクトでも `pytest --cov` が動きます。
-#### 1. main.py-tpl の書き方
+### コメント行と README のマーカー
-```python
-"""
-FastAPI アプリのエントリポイント
+- `main.py-tpl` と、リソースのルーターをまとめるモジュールには、`# fastkit:imports` と `# fastkit:routes` のコメント行を残します。`fastkit init` と `fastkit addroute` がその位置にコードを挿入します。
+- `README.md-tpl` には、`` の行をちょうど 1 つ、導入部の後で次の `##` 見出しより前に置き、前後に空行を入れます。生成時に、この行は Next steps のリストに置き換えられます。
-このファイルは、FastAPI-fastkit で作成された プロジェクトの
-メインアプリケーションです。
-"""
-from fastapi import FastAPI
-from fastapi.middleware.cors import CORSMiddleware
+### 概念コメント
-from api.api import api_router
-from core.config import settings
+概念コメントは、テンプレートの中で FastAPI の構成要素が最初に登場する場所で、それを説明するコメントです。コードの直前に 2 行で書きます。
-# FastAPI アプリを作成 (インスペクタの検証で必須)
+```python title="fastapi-default/src/main.py-tpl"
+# `app` is the FastAPI application that uvicorn serves: `uvicorn src.main:app`.
+# https://fastapi.tiangolo.com/tutorial/first-steps/
app = FastAPI(
- title="",
- description="Project created with FastAPI-fastkit",
- version="1.0.0",
-)
-
-# CORS ミドルウェア設定
-app.add_middleware(
- CORSMiddleware,
- allow_origins=["*"],
- allow_credentials=True,
- allow_methods=["*"],
- allow_headers=["*"],
-)
-
-# API ルーターを登録
-app.include_router(api_router, prefix="/api/v1")
-
-@app.get("/")
-async def root():
- """ルートエンドポイント"""
- return {"message": "Hello from !"}
-
-@app.get("/health")
-async def health_check():
- """ヘルスチェックエンドポイント"""
- return {"status": "healthy"}
-
-if __name__ == "__main__":
- import uvicorn
- uvicorn.run(app, host="0.0.0.0", port=8000)
-```
-
-#### 2. pyproject.toml-tpl の書き方 (推奨)
-
-新しいテンプレートは PEP 621 形式の `pyproject.toml-tpl` でメタデータと依存関係を宣言すべきです。最低限、`[project]` セクションに `name`、`version`、`description`、そして `fastapi` を含む `dependencies` リストを公開してください。テンプレートは、`is_fastkit_project()` がユーザーのワークスペース内の無関係な FastAPI プロジェクトと区別できるよう、FastAPI-fastkit の識別マーカーを 2 つ持つ必要があります:
-
-- `description` の `[FastAPI-fastkit templated]` 接頭辞
-- `managed = true` を持つ専用の `[tool.fastapi-fastkit]` テーブル
-
-検出はどちらかのマーカーがあれば成功します (大文字小文字は区別しません)。テンプレートが省略していてもプロジェクト生成時にメタデータ注入が両方を追加しますが、作者は明示的に含めるべきです。
-
-```toml
-[project]
-name = ""
-version = "0.1.0"
-description = "[FastAPI-fastkit templated] "
-authors = [
- {name = "", email = ""},
-]
-readme = "README.md"
-requires-python = ">=3.12"
-dependencies = [
- "fastapi>=0.115.0",
- "uvicorn[standard]>=0.34.0",
- "pydantic>=2.10.0",
- "pydantic-settings>=2.7.0",
- "python-dotenv>=1.0.0",
-]
-
-[project.optional-dependencies]
-dev = [
- "pytest>=8.0.0",
- "httpx>=0.28.0",
-]
-
-[tool.fastapi-fastkit]
-managed = true
-
-[build-system]
-requires = ["hatchling"]
-build-backend = "hatchling.build"
-```
-
-#### 3. requirements.txt-tpl の書き方 (任意)
-
-`pyproject.toml-tpl` が `[project].dependencies` を宣言している場合は任意です。`pip` 中心のワークフローを好むテンプレートでは引き続き有用です。
-
-```txt
-# FastAPI コア依存 (必須)
-fastapi==0.104.1
-uvicorn[standard]==0.24.0
-
-# データ検証
-pydantic==2.5.0
-pydantic-settings==2.1.0
-
-# 環境変数管理
-python-dotenv==1.0.0
-
-# データベース (必要な場合)
-sqlalchemy==2.0.23
-alembic==1.13.0
-
-# 開発ツール
-pytest==7.4.3
-pytest-asyncio==0.21.1
-httpx==0.25.2
-
-# コード品質
-black==23.11.0
-isort==5.12.0
-mypy==1.7.1
-```
-
-#### 4. ルートアンカー
-
-`main.py-tpl` や API 集約モジュールを提供するテンプレートでは、`fastkit addroute` がコードを挿入する場所に印を付けておく必要があります:
-
-```python
-from src.app.api import health
-
-# fastkit:imports
-
-api_router = APIRouter()
-api_router.include_router(health.router)
-
-# fastkit:routes
-```
-
-アンカーがない場合、`addroute` は AST ベースの挿入にフォールバックし、import ブロックとルーター登録の位置を自分で探します — そのためアンカーのないテンプレートでも動作はしますが、結果の予測可能性は下がります。これらのファイルを編集するときは、コメントをそのまま残してください。
-
-#### 5. テストファイルの書き方
-
-```python
-# tests/test_items.py-tpl
-"""
-Items API テストモジュール
-"""
-import pytest
-from fastapi.testclient import TestClient
-from main import app
-
-client = TestClient(app)
-
-def test_read_root():
- """ルートエンドポイントのテスト"""
- response = client.get("/")
- assert response.status_code == 200
- assert "message" in response.json()
-
-def test_health_check():
- """ヘルスチェックのテスト"""
- response = client.get("/health")
- assert response.status_code == 200
- assert response.json() == {"status": "healthy"}
-
-def test_create_item():
- """item 作成のテスト"""
- item_data = {
- "name": "Test Item",
- "description": "Test Description"
- }
- response = client.post("/api/v1/items/", json=item_data)
- assert response.status_code == 200
- data = response.json()
- assert data["name"] == item_data["name"]
- assert data["description"] == item_data["description"]
-
-def test_read_items():
- """item 一覧取得のテスト"""
- response = client.get("/api/v1/items/")
- assert response.status_code == 200
- assert isinstance(response.json(), list)
-```
-
-## 🔍 ステップ 3: ローカル検証
-
-### 自動検証スクリプトの実行
-
-新しいテンプレートが準備できたら、次のコマンドで検証します:
-
-```bash
-# すべてのテンプレートを検証
-make inspect-templates
-
-# 特定のテンプレートだけ検証
-make inspect-template TEMPLATES="fastapi-your-template"
-
-# 詳細出力付きで検証
-python scripts/inspect-templates.py --templates "fastapi-your-template" --verbose
-
-# 高速なローカルループ: ネットワークなし、サーバー起動なし
-python scripts/inspect-templates.py --templates "fastapi-your-template" \
- --offline --no-smoke
-
-# PR を出す前の完全なチェック (生成されたプロジェクトに対する mypy を追加)
-python scripts/inspect-templates.py --templates "fastapi-your-template" --mypy
-```
-
-`--offline` は PyPI での依存関係の鮮度チェックをスキップし、`--no-smoke` は生成されたプロジェクトの起動 (最も時間のかかるステップ) をスキップし、`--mypy` は生成されたプロジェクトを型チェックします。各チェックの内容は [テンプレート品質保証](../reference/template-quality-assurance.md) を参照してください。
-
-!!! note
-
- PR を提出すると、**Template PR Inspection** ワークフローが自動的に走り、テンプレート変更を検証します。フィードバックは PR に直接届きます。
-
-### 検証チェックリスト
-
-インスペクタが自動で確認する項目です:
-
-#### ✅ ファイル構造の検証
-
-- [ ] `tests/` ディレクトリが存在
-- [ ] `README.md-tpl` ファイルが存在
-- [ ] `pyproject.toml-tpl` が存在 (新しいテンプレートには `setup.py-tpl` を含めない)
-
-#### ✅ 拡張子の検証
-
-- [ ] すべての Python ファイルが `.py-tpl` 拡張子
-- [ ] `.py` 拡張子のファイルが存在しない
-
-#### ✅ 依存関係の検証
-
-- [ ] 次のいずれかに `fastapi` が宣言されている:
- - [ ] `pyproject.toml-tpl` の `[project].dependencies` (推奨)
- - [ ] `requirements.txt-tpl`
-- [ ] `requirements.txt-tpl` と `[project].dependencies` が食い違っていない
-- [ ] `FastAPI-fastkit` がランタイム依存関係に **含まれていない**
-
-#### ✅ FastAPI 実装の検証
-
-- [ ] `main.py-tpl` に `FastAPI` import がある
-- [ ] `main.py-tpl` に `app = FastAPI()` のようなアプリ生成がある
-
-#### ✅ テスト実行の検証
-
-- [ ] 仮想環境の作成に成功
-- [ ] 依存関係のインストールに成功
-- [ ] すべての pytest テストが通過
-
-#### ✅ スモークテスト
-
-- [ ] 生成されたプロジェクトが uvicorn で起動する
-- [ ] `/docs` が応答する
-- [ ] `/health` が応答する
-
-uvicorn のターゲットは、生成された `pyproject.toml` の `[tool.fastapi-fastkit].app_module`、次に `template-config.yml` の `app_module`、最後に慣例的な `main.py` の配置場所の順で解決されます。
-
-#### ✅ 設定の一貫性
-
-- [ ] `requires-python`、black の `target-version`、mypy の `python_version` がすべて Python 3.12 を示している
-- [ ] `requirements.txt-tpl` と `[project].dependencies` の間に依存関係の食い違いがない
-- [ ] `FastAPI-fastkit` への自己依存がない
-
-#### ✅ プレースホルダーの残留
-
-- [ ] プロジェクト生成後に `` が残っていない
-
-#### ✅ 自動テンプレートテスト
-
-FastAPI-fastkit には、すべてのテンプレートで包括的テストを走らせる **自動テンプレートテスト** が含まれます:
-
-**テストカバレッジ:**
-
-- ✅ テンプレート生成プロセス
-- ✅ プロジェクトメタデータの注入
-- ✅ 仮想環境のセットアップ
-- ✅ 依存関係のインストール (すべてのパッケージマネージャー)
-- ✅ 基本的なプロジェクト構造の検証
-- ✅ FastAPI プロジェクトの識別
-
-**テストの実行:**
-```console
-# すべてのテンプレートを自動テスト
-$ pytest tests/test_templates/test_all_templates.py -v
-
-# 特定のテンプレートをテスト
-$ pytest tests/test_templates/test_all_templates.py::TestAllTemplates::test_template_creation[your-template-name] -v
```
-**テンプレートテストの自動検出:**
-新しいテンプレートは **設定なしで自動検出** されてテストされます:
+- 1 行目は 1 文で、fastkit には触れません。2 行目は URL だけを書き、その URL はカタログにある `[[concepts]]` エントリーの URL でなければなりません。どちらの行も 88 桁に収めます。
+- 1 つのテンプレートが同じ概念にリンクするのは 1 回までです。`level` テンプレートでは、コメントの id がカタログの `concepts` のリストと一致する必要があります。`example` テンプレートでは、コメントの id がそのリストに含まれている必要があります。
+- このブロックはコードのすぐ上に置きます。import のブロックの中や、デコレーターとその関数のあいだには置きません。
+- `modules/` の下のファイルには概念コメントを書きません。
-1. ✅ **設定不要**: テンプレートを追加 → 自動でテスト
-2. ✅ **一貫したテスト**: すべてのテンプレートに同じ品質基準
-3. ✅ **複数のパッケージマネージャー**: UV、PDM、Poetry、PIP でテスト
-4. ✅ **包括的な検証**: 構造、メタデータ、機能のチェック
+このセクションのルールはすべて `tests/test_templates/test_concept_comments.py` がチェックします。
-**これがあなたにとって意味すること:**
+## チェック {#checks}
-- 🚀 **`FastAPI-fastkit` 本体側にテストファイルを追加する必要なし**: テンプレートは自動でテストされます
-- ⚡ **開発の高速化**: テンプレート内容に集中、テストのお膳立て不要
-- 🛡️ **品質保証**: すべてのテンプレートで一貫したテスト
-- 🔄 **CI/CD 連携**: PR で自動的にテスト
+### ローカルでテンプレートを検査する
-**手動テストもまだ必要なケース:**
+`scripts/inspect-templates.py` は、テンプレートから実際のプロジェクトを(仮想環境なしで)作成し、そのプロジェクトに対して一連のチェックを実行して、最初に失敗したところで止まります。
-- 🧪 **テンプレート固有の機能**: ビジネスロジックや独自機能
-- 🔧 **統合テスト**: 外部サービスや複雑なワークフロー
-- 📱 **エンドツーエンドシナリオ**: ユーザーワークフロー全体
+| ステップ | チェックする内容 |
+| --- | --- |
+| File structure | `tests/`、`README.md-tpl`、`pyproject.toml-tpl` が存在すること。 |
+| File extensions | `-tpl` の付かない `.py` ファイルがないこと。 |
+| Test suite presence | `tests/` の下に `test_*.py-tpl` が 1 つ以上あること。 |
+| Junk files | `.DS_Store`、`__pycache__`、`.venv`、`.pyc` などの不要なファイルがないこと。 |
+| Dependencies | `fastapi` が宣言されていること。 |
+| Configuration consistency | Python 3.12 への固定があること、`[project].dependencies` のパッケージが `requirements.txt-tpl` に欠けていないこと、`FastAPI-fastkit` への依存がないこと。 |
+| FastAPI implementation | 生成されたプロジェクトが `FastAPI(...)` アプリケーションを作成すること。 |
+| Placeholder substitution | 生成されたプロジェクトに `` が残っていないこと。 |
+| Compile check | すべての Python ファイルがコンパイルできること。 |
+| Template tests | 仮想環境を作成し、依存関係をインストールして `scripts/test.sh` を実行します。このスクリプトがない場合は `pytest tests/ -v` を実行します。 |
+| Type check | 生成されたプロジェクトで、テンプレートの mypy の設定を使い、テストも含めて `mypy .` を実行します(`--mypy` を指定した場合のみ)。 |
+| Smoke test | uvicorn でアプリケーションを起動します。`/docs` が 200 を返し、`/health` があればそれも 200 を返す必要があります。 |
+| Dependency freshness | 固定されたバージョンが PyPI の最新リリースより古い場合に警告します(`--offline` を指定するとスキップします)。 |
-**テストのベストプラクティス:**
```console
-# 1. テンプレートをローカルでテスト
-$ fastkit startdemo your-template-name
-
-# 2. 自動テストを実行
-$ pytest tests/test_templates/test_all_templates.py::TestAllTemplates::test_template_creation[your-template-name] -v
-
-# 3. 異なるパッケージマネージャーでテスト
-$ fastkit startdemo your-template-name --package-manager poetry
-$ fastkit startdemo your-template-name --package-manager pdm
-$ fastkit startdemo your-template-name --package-manager uv
-```
-
-### 手動検証チェックリスト
-
-自動検証に加えて、次の項目を手動でチェックしてください:
-
-#### 🔧 コード品質
-
-- [ ] PEP 8 スタイルガイドに従っている
-- [ ] 適切な型ヒントを使用
-- [ ] 意味のある変数名・関数名
-- [ ] 適切なコメントと docstring
-
-#### 🏗️ アーキテクチャ
-
-- [ ] 関心事の分離 (API、ビジネスロジック、データアクセス)
-- [ ] 再利用可能なコンポーネント設計
-- [ ] 拡張可能な構造
-- [ ] セキュリティのベストプラクティス適用
-
-#### 📚 ドキュメント
-
-- [ ] README.md-tpl が PROJECT_README_TEMPLATE.md の形式に従っている
-- [ ] インストール / 実行方法が明記されている
-- [ ] API ドキュメント (OpenAPI/Swagger)
-- [ ] 環境変数の説明
+$ python scripts/inspect-templates.py --help
+usage: inspect-templates.py [-h] [--templates TEMPLATES] [--output OUTPUT]
+ [--verbose] [--offline] [--no-smoke] [--mypy]
-## 📚 ステップ 4: ドキュメント
-
-### README.md-tpl の作成
-
-[PROJECT_README_TEMPLATE.md](https://github.com/bnbong/FastAPI-fastkit/blob/main/src/fastapi_fastkit/fastapi_project_template/PROJECT_README_TEMPLATE.md) のガイドに沿って書いてください。
-
-### テンプレート説明ドキュメントの作成
-
-新しいテンプレートの説明を `src/fastapi_fastkit/fastapi_project_template/README.md` に追加します:
-
-```markdown
-## fastapi-your-template
-
-新しいテンプレートの簡単な説明とユースケースをここに書きます。
-
-### 機能:
-- 機能 1
-- 機能 2
-- 機能 3
-
-### ユースケース:
-- ユースケース 1
-- ユースケース 2
-```
-
-## 🚀 ステップ 5: 提出とレビュー
-
-### PR 作成前のチェックリスト
-
-- [ ] すべての自動検証が通過 (`make inspect-templates`)
-- [ ] コードフォーマット完了 (`make format`)
-- [ ] リンティングチェック通過 (`make lint`)
-- [ ] すべてのテスト通過 (`make test`)
-- [ ] ドキュメント完成
-- [ ] CONTRIBUTING.md ガイドラインに準拠
-
-### PR タイトルと説明
+Inspect FastAPI templates locally
+options:
+ -h, --help show this help message and exit
+ --templates TEMPLATES
+ Specific templates to inspect (comma-separated, leave
+ empty for all)
+ --output OUTPUT Output JSON file for results
+ --verbose Enable verbose output
+ --offline Skip every network lookup (dependency freshness
+ reporting)
+ --no-smoke Skip booting the generated project with uvicorn
+ --mypy Type check the generated project with mypy (slow)
```
-[TEMPLATE] Add fastapi-{template-name} template
-## Overview
-Adds a new {purpose} template.
+テンプレートのテストには、`PATH` 上に uv が必要です。`--output` を指定しない場合、結果は `template_inspection_results.json` に書き出されます。1 つのテンプレートで実行した例を示します。
-## Key Features
-- Feature 1
-- Feature 2
-- Feature 3
-
-## Validation Results
-- [ ] Inspector validation passed
-- [ ] All tests passed
-- [ ] Documentation completed
-
-## Usage Example
-\```bash
-fastkit startdemo
-# Select template: fastapi-{template-name}
-\```
-
-## Related Issues
-Closes #issue-number
+```console
+$ python scripts/inspect-templates.py --templates fastapi-hello --offline --output results.json
+📋 Found 1 templates to inspect: fastapi-hello
+============================================================
+🔍 Inspecting template: fastapi-hello
+...
+✅ fastapi-hello: PASSED
+----------------------------------------
+============================================================
+📊 INSPECTION SUMMARY
+ Total templates: 1
+ ✅ Passed: 1
+ ❌ Failed: 0
+🎉 All templates passed inspection!
+📄 Results saved to: results.json
```
-### レビュープロセス
-
-1. **自動検証**: GitHub Actions がテンプレートを自動検証します
- - **Template PR Inspection**: テンプレートを変更する PR で `inspect-changed-templates.py` を実行
- - **週次検査**: 毎週水曜日にテンプレート全体を検証
-2. **コードレビュー**: メンテナーとコミュニティがコードをレビュー
-3. **テスト**: テンプレートをさまざまな環境でテスト
-4. **ドキュメントレビュー**: ドキュメントの正確性と完全性を確認
-5. **承認とマージ**: すべての要件が満たされたら main ブランチへマージ
-
-!!! note
-
- 検証結果は PR に自動コメントとして届きます。レビュー依頼前に必ず確認してください!
-
-## 🎯 ベストプラクティス
-
-### セキュリティの考慮
-
-- 機密情報は環境変数で管理
-- 適切な CORS 設定
-- 入力データの検証
-- SQL インジェクション対策
-
-### パフォーマンス最適化
-
-- 非同期処理を活用
-- データベースクエリの最適化
-- 適切なキャッシュ戦略
-- レスポンス圧縮の設定
-
-### 保守性
+`make inspect-templates` はすべてのテンプレートを検査し、`make inspect-templates-verbose` はそれに `--verbose` を加えます。`make inspect-template TEMPLATES="fastapi-default,fastapi-hello"` は指定したテンプレートだけを検査します。変更と確認を繰り返しているあいだは、`--offline --no-smoke` を付けるとネットワークへのアクセスと最も時間のかかるステップを省けます。`--mypy` は、生成されたプロジェクト自身が実行するチェックより厳格です。プロジェクトの `scripts/lint.sh` は `mypy src` だけをチェックしますが、`--mypy` はテストの型もチェックします。`fastapi-domain-starter` はほかのステップにはすべて通りますが、テストに型アノテーションがないため `--mypy` では失敗します。
-- 明快なコード構造
-- 包括的なテストカバレッジ
-- 詳細なドキュメント
-- ロギングとモニタリングのセットアップ
+### リポジトリのテスト
-## 🆘 ヘルプが必要な場合
+`pytest` はテンプレートも対象にしています。`tests/test_templates/` は、すべてのテンプレートからプロジェクトを作成し、生成されたプロジェクトにリンターを実行し、requirements ファイルを `pyproject.toml-tpl` と比較し、概念コメントと README のマーカーをチェックします。新しいテンプレートのフォルダーは、これらのテストのほとんどで自動的に対象になります。ただし、`tests/test_templates/test_template_requirements_split.py` はすべてのテンプレートを名前で列挙しているので、ここには自分のテンプレートを追加してください。
-- 📖 [開発環境セットアップガイド](development-setup.md)
-- 📋 [コードガイドライン](code-guidelines.md)
-- 💬 [GitHub Discussions](https://github.com/bnbong/FastAPI-fastkit/discussions)
-- 📧 [メンテナーへ連絡](mailto:bbbong9@gmail.com)
+### CI では
-新しいテンプレートの追加は FastAPI-fastkit コミュニティへの大きな貢献です。
-あなたのアイデアと努力が、ほかの開発者にとって大きな助けになります! 🚀
+- Template PR Inspection ワークフローは、`src/fastapi_fastkit/fastapi_project_template/` の下のファイルを変更するすべてのプルリクエストで `scripts/inspect-changed-templates.py --offline` を実行し、結果をプルリクエストにコメントします。
+- Weekly Template Inspection ワークフローは、毎週水曜日の 00:00 UTC に、依存関係の鮮度チェックも含めてすべてのテンプレートを検査し、失敗したテンプレートがあれば issue を作成します。テンプレートを選んで手動で実行することもできます。
diff --git a/docs/ja/contributing/translation-guide.md b/docs/ja/contributing/translation-guide.md
index da8d57f6..e85a6fea 100644
--- a/docs/ja/contributing/translation-guide.md
+++ b/docs/ja/contributing/translation-guide.md
@@ -1,367 +1,153 @@
# 翻訳ガイド
-このガイドでは、FastAPI-fastkit ドキュメントの翻訳に貢献する方法を説明します。
+このドキュメントは、英語(`en`)、韓国語(`ko`)、日本語(`ja`)、中国語(`zh`)、スペイン語(`es`)、フランス語(`fr`)、ドイツ語(`de`)の 7 言語で公開しています。このページでは、何を翻訳し何を英語のまま残すのか、生成される表、カタログのテキスト、Web ジェネレーターのページをどのように翻訳するのか、そしてテストが翻訳をどのようにチェックするのかを説明します。
-## 原典と翻訳ポリシー
+## 原文は英語です
-> **英語 (`en`) が FastAPI-fastkit ドキュメントの基準となる原文** です。それ以外のロケールは翻訳対象であり、リリース単位またはページ単位で英語より遅れる可能性があります。
->
-> 翻訳されたページが英語ページと食い違う場合は、翻訳が追いつくまで **英語ページを信頼してください**。翻訳は貢献者が到達した範囲でそのまま提供されます — 部分的なカバレッジは通常の状態です。
+すべてのページは、まず `docs/en/` に英語で書きます。各言語には `docs//` の下の同じパスに同じページがあります。たとえば、`docs/en/learn/generate.md` に対応するのは `docs/ko/learn/generate.md` です。すべてのページは 7 言語すべてにそろっている必要があります。英語のページを追加または変更したときは、同じプルリクエストか次のプルリクエストで 6 つの翻訳も更新します。
-このポリシーに対応するユーザー向けページは [翻訳ステータス](../reference/translation-status.md) で、各ロケールの実際の完成度と、未翻訳ページが MkDocs でどう表示されるかが書かれています (要約: 英語にフォールバックします)。
+ある言語にページのファイルがない場合、サイトはその言語のメニューに英語のページを表示します。これを通常の状態とは考えず、埋めるべき欠落として扱ってください。
-リポジトリルートの `CHANGELOG.md` も、正式なリリース履歴として英語のまま維持されます。ロケールが `changelog.md` を持つ場合、そのページは別途翻訳された changelog を維持するのではなく、正式な英語 changelog にリンクするか取り込む形にしてください (今後プロジェクト方針が変わった場合を除く)。
+`CHANGELOG.md` は英語のままにします。各 `docs//changelog.md` には、英語のファイルを取り込む `\{!CHANGELOG.md!}` だけを書きます。
-翻訳を貢献するときは、ステータスページの表も合わせて更新してください。これにより、利用者が言語切替メニューだけでは判断できない実際の利用可否を把握できます。
+## 英語のまま残すもの
-## 概要
+- コマンドラインが出力する内容や尋ねる内容はすべて英語のまま残します。プロンプト、メッセージ、表、ヘルプテキストなどの出力がこれに当たります。読者はページと自分のターミナルを見比べるからです。
+- コマンド、オプション、ファイル名、パス、コード、設定キー、パッケージ名は、コードブロックの中でも外でも英語のまま残します。
+- コードブロックは英語のまま残します。フェンスで囲んだブロックは、コメントや出力例も含めてすべて英語のページとまったく同じにします。
+- `cli` 生成ブロック(CLI リファレンスのページにある `--help` のテキスト)と、`doctor-checks` の表にあるチェックのタイトルは英語のまま残します。スクリプトは、どの言語でもこれらを英語でレンダリングします。
+- 画像の中のテキストは英語のまま残します。画像は `docs/img/` にある共有ファイルで、すべての言語が同じ画像を使います。画像にはリンクするだけにして、翻訳したコピーは決して作らないでください。
+- リンク先と見出しの id は英語のまま残します。一部の見出しの末尾には `{#features}` のような id があります。ほかのページやリダイレクトがこの id にリンクしているためです。見出しのテキストは翻訳し、id はそのまま残してください。サンプルプロジェクトのページにあるテンプレート id の見出し(`## fastapi-auth-jwt {#fastapi-auth-jwt}` など)は変更しません。
-FastAPI-fastkit は、AI を活用してドキュメントを複数言語へ翻訳する自動化システムを使用しています。このシステムは:
+これらを囲む本文、見出し、注記ブロック(admonition)のテキスト、リンクのテキスト、すべての画像の代替テキストは翻訳します。相対リンクはそのまま残してください。パスはどの言語でも同じです。
-- 英語のソースドキュメントを読み込みます
-- AI API (OpenAI または Anthropic) を使ってコンテンツを翻訳します
-- 翻訳結果を言語別ディレクトリへ保存します
-- レビュー用の GitHub Pull Request を作成します
+## 生成ブロック
-自動化はあくまでたたき台を作るだけであり、マージ前には人によるレビューが必要です。AI が生成した翻訳は PR の "draft" として明示し、その言語に十分慣れたレビュアーが確認してから反映してください。
+一部の表は、カタログと CLI から生成されます。ページの中では、これらの表は 2 つのコメント行のあいだに置かれています。
-## 対応言語
-
-下記はドキュメントサイトが現在 **ビルド** しているロケールです。ビルド対象として設定されているだけでは、そのロケールのページが翻訳済みであるとは **限りません** — ロケールごとの実際の完成度は [翻訳ステータス](../reference/translation-status.md) を参照してください。
-
-- 🇰🇷 韓国語 (ko)
-- 🇯🇵 日本語 (ja)
-- 🇨🇳 中国語 (zh)
-- 🇪🇸 スペイン語 (es)
-- 🇫🇷 フランス語 (fr)
-- 🇩🇪 ドイツ語 (de)
-
-## 前提条件
-
-### 1. 翻訳の依存関係をインストール
-
-```bash
-# pip でインストール
-pip install openai anthropic
-
-# または pdm
-pdm install -G translation
-```
-
-### 2. API キーの設定
-
-OpenAI または Anthropic のいずれかの API キーが必要です:
-
-```bash
-# OpenAI 用
-export TRANSLATION_API_KEY="sk-..."
-
-# または Anthropic 用
-export TRANSLATION_API_KEY="sk-ant-..."
+```markdown
+
+...
+
```
-### 3. GitHub CLI のインストール (任意)
-
-PR を自動生成する場合:
-
-```bash
-# macOS
-brew install gh
-
-# Linux
-curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
-echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
-sudo apt update
-sudo apt install gh
-
-# 認証
-gh auth login
-```
-
-## 使い方
-
-### Make コマンドを使う (推奨)
+2 つのコメント行は英語のページからコピーし、そのあいだの内容は決して翻訳も編集もしないでください。そのうえで、自分の言語のブロックをレンダリングします。
-最も簡単な実行方法です:
-
-```bash
-# すべてのドキュメントをすべての言語へ翻訳
-make translate
-
-# 特定の言語へ翻訳
-make translate LANG=ko
-
-# API プロバイダとモデルを指定
-make translate LANG=ko PROVIDER=openai MODEL=gpt-4
-make translate LANG=ko PROVIDER=github MODEL=gpt-4o-mini
+```console
+$ python scripts/docs_blocks.py --lang ko
+$ python scripts/docs_blocks.py --check
```
-### スクリプトを直接使う
+カタログのブロック(`levels`、`features`、`rules`、`package-managers`、`examples`、`concepts`)は、ページの言語のカタログのオーバーレイからテキストを取得します。オーバーレイについては後で説明します。表の決まった文言は、`scripts/docs_blocks.py` の先頭にある `HEADINGS` テーブルから取得します。列見出し、`{when} needs {require}.` のような短い文、リストの区切り記号とつなぎ方(`separator`、`join_or`、`join_and`)がここに入っているため、日本語のように区切りの前後の空白をなくしたい言語にも対応できます。翻訳済みの言語には、`en` のすべてのキーと同じ `{placeholders}` を持つエントリーが必要です。エントリーのない言語には英語の文言が使われます。`cli` ブロックと `doctor-checks` の表にあるチェックのタイトルは、コマンドライン自身のテキストなので英語のまま残ります。
-#### すべてのドキュメントを翻訳
+## カタログのオーバーレイ {#catalog-overlays}
-すべての対応言語へドキュメント全体を翻訳:
+レベルの説明、機能のラベルと概要、ルールのメッセージ、概念のタイトル、Next steps のテキストはカタログから取得します。英語のテキストは `src/fastapi_fastkit/catalog/catalog.toml` にあり、各言語には同じキーを持つオーバーレイが `src/fastapi_fastkit/catalog/i18n/.toml` にあります。
-```bash
-python scripts/translate.py --api-provider openai
+```toml title="src/fastapi_fastkit/catalog/i18n/ko.toml"
+[levels."hello"]
+label = "Hello"
+description = "main.py 하나에 엔드포인트 3개와 메모리 데이터가 들어 있고, 테스트도 함께 제공됩니다."
```
-### 特定の言語へ翻訳
+オーバーレイは、生成ブロックと Web ジェネレーターのページにテキストを提供します。翻訳が必要なキーをすべて確認するには、英語のスケルトンを出力します。
-韓国語のみへ翻訳:
-
-```bash
-python scripts/translate.py --target-lang ko --api-provider openai
+```console
+$ python -m fastapi_fastkit.catalog strings
+[levels."hello"]
+label = "Hello"
+description = "One main.py: 3 endpoints, in-memory data, tests."
+...
```
-### 特定のファイルだけ翻訳
+`tests/test_catalog` がチェックするルールは次のとおりです。
-特定のドキュメントファイルのみ翻訳:
+- オーバーレイはスケルトンのテキストをすべて翻訳し、カタログにないキーを持ちません。
+- id、パッケージ名、URL は決して翻訳せず、バッククォートで囲んだコードは英語とまったく同じにします。
+- `{services}` のようなプレースホルダーは、同じ名前のまま残します。
+- 英語と同じテキストが許されるのは、`tests/test_catalog/test_overlays.py` に列挙されたいくつかの名前(たとえば `Hello` レベルのラベル)だけです。
-```bash
-python scripts/translate.py \
- --target-lang ko \
- --files user-guide/installation.md user-guide/quick-start.md \
- --api-provider openai
-```
+## Web ジェネレーターのページ
-### PR 作成をスキップ
+`docs//start/web-generator.md` は英語のページのコピーで、翻訳するのは次の部分だけです。
-GitHub PR を作らずに翻訳のみ実行:
+- H1 と導入の段落(Pyodide のリンクと `fastkit init ... --no-venv` のコードはそのまま残します)。
+- `