📝 docs(playbook): add contributing and multi-language standards

Introduce C++ and Python docs/templates and split .agents rulesets by language (tsl/cpp/python).

Move commit message guidance to CONTRIBUTING.md (full spec remains in docs/common/commit_message.md).
This commit is contained in:
csh
2025-12-14 17:32:50 +08:00
parent 380228caca
commit e504a689dc
47 changed files with 1521 additions and 162 deletions
+65
View File
@@ -0,0 +1,65 @@
# Python 配置清单(Configuration
本文件用于把 Python 工具配置“汇总说明”到一个可读入口。
注意:本 Playbook 将可复制模板放在 `templates/python/`;在目标项目落地时,这些文件通常需要复制到**项目根目录**(工具默认查找位置):
- `pyproject.toml`
- `.flake8`
- `.pylintrc`
- `.pre-commit-config.yaml`
- `.editorconfig`
- `.vscode/settings.json`
## 1) `pyproject.toml`
模板文件:`templates/python/pyproject.toml`
- `tool.black`
- `line-length = 80`
- `target-version = ['py313']`(按项目 Python 版本调整)
- `tool.isort`
- `profile = "google"`
- `line_length = 80`
- `known_third_party` / `known_first_party`:按项目维护
- `tool.mypy`
- `python_version = "3.13"`(按项目调整)
- `ignore_missing_imports = true`(对第三方二进制/无类型库更友好)
- `tool.pytest.ini_options`
- 测试发现与参数(若项目引入 `tests/` 会自动生效)
## 2) `.flake8`
模板文件:`templates/python/.flake8`
- `max-line-length = 80`
- `docstring-convention = google`
-`black` 冲突的规则已屏蔽(例如 `E203``W503`
## 3) `.pylintrc`
模板文件:`templates/python/.pylintrc`
- 命名风格:snake_case / PascalCase 等(对齐 Google Python 风格)
- `max-line-length = 80`
- `init-hook` 将项目根目录加入 `sys.path`(便于本地运行与检查;如项目不需要可移除)
## 4) `.pre-commit-config.yaml`
模板文件:`templates/python/.pre-commit-config.yaml`
- 基础文本检查:尾随空格、文件末尾换行、YAML/TOML 基础校验
- Python`black``isort``flake8`
## 5) `.editorconfig`
模板文件:`templates/python/.editorconfig`
- Python4 空格缩进、行宽 80
- 通用:UTF-8、LF、去尾随空格、文件末尾换行
## 6) `.vscode/settings.json`
模板文件:`templates/python/.vscode/settings.json`
- 保存即格式化、80 列标尺、默认使用 Black formatter、按需组织 import
+14
View File
@@ -0,0 +1,14 @@
# Python 代码风格(Google Python Style Guide
本 Playbook 的 Python 代码风格以 Google Python Style Guide 为基线(基于 PEP 8):
- Google Python Style Guide: https://google.github.io/styleguide/pyguide.html
- PEP 8: https://peps.python.org/pep-0008/
## 项目约定(Project Conventions
- 行宽:80(与 `black`/`flake8`/`pylint` 配置保持一致)
- docstringGoogle 风格(与 `.flake8``docstring-convention = google` 对齐)
- import 顺序:使用 `isort``profile = google`
当既有代码与本约定冲突时,优先保持局部一致性,逐步迁移。
+36
View File
@@ -0,0 +1,36 @@
# Python 工具链(Tooling
本 Playbook 推荐用以下工具保证代码一致性与质量:
- `black`:格式化(行宽 80
- `isort`import 排序(Google profile
- `flake8`:风格检查 + docstring 约定
- `pylint`:静态检查(以 `.pylintrc` 为准,可按项目调整)
- `mypy`:类型检查(可选)
- `pytest`:测试(可选)
- `pre-commit`:在 `git commit` 前自动运行上述检查/格式化(可选,但推荐)
## 常用命令(示例)
安装工具(示例,按项目实际依赖管理方式调整):
```bash
python -m pip install black isort flake8 pylint mypy pytest pre-commit
```
格式化与检查(示例):
```bash
black .
isort .
flake8 .
pylint .
mypy .
pytest
```
启用 `pre-commit`(只需一次):
```bash
pre-commit install
```