autodoc_pydantic 项目教程
1. 项目的目录结构及介绍
autodoc_pydantic/
├── docs/
│ └── sphinxcontrib/
│ └── autodoc_pydantic/
├── tests/
├── .all-contributorsrc
├── .gitignore
├── .readthedocs.yaml
├── .release-please-manifest.json
├── CHANGELOG.md
├── CODEOWNERS
├── LICENSE
├── README.md
├── pyproject.toml
├── release-please-config.json
├── renovate.json
├── ruff.toml
├── tox.ini
目录结构介绍
- docs/: 包含 Sphinx 文档的配置和内容。
- sphinxcontrib/autodoc_pydantic/: 包含与 autodoc_pydantic 相关的 Sphinx 插件代码。
- tests/: 包含项目的测试代码。
- .all-contributorsrc: 配置文件,用于管理项目的贡献者。
- .gitignore: Git 忽略文件列表。
- .readthedocs.yaml: Read the Docs 配置文件。
- .release-please-manifest.json: 发布管理配置文件。
- CHANGELOG.md: 项目变更日志。
- CODEOWNERS: 代码所有者配置文件。
- LICENSE: 项目许可证文件。
- README.md: 项目介绍和使用说明。
- pyproject.toml: Python 项目配置文件。
- release-please-config.json: 发布管理配置文件。
- renovate.json: Renovate 配置文件。
- ruff.toml: Ruff 配置文件。
- tox.ini: Tox 配置文件。
2. 项目的启动文件介绍
项目中没有明确的“启动文件”,因为 autodoc_pydantic
是一个 Sphinx 插件,通常在 Sphinx 文档生成过程中被调用。要使用该插件,你需要在 Sphinx 项目的 conf.py
文件中进行配置。
Sphinx 配置示例
# conf.py
extensions = [
'sphinxcontrib.autodoc_pydantic',
]
3. 项目的配置文件介绍
pyproject.toml
pyproject.toml
是 Python 项目的配置文件,包含了项目的依赖、构建系统和工具配置等信息。
[tool.poetry]
name = "autodoc_pydantic"
version = "0.1.0"
description = "Seamlessly integrate pydantic models in your Sphinx documentation"
authors = ["Your Name <[email protected]>"]
[tool.poetry.dependencies]
python = "^3.7"
sphinx = "^4.0.0"
pydantic = "^1.5.0"
[tool.poetry.dev-dependencies]
pytest = "^6.2.5"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
.readthedocs.yaml
readthedocs.yaml
是 Read the Docs 的配置文件,用于配置文档的构建和部署。
version: 2
build:
os: ubuntu-20.04
tools:
python: "3.8"
python:
install:
- method: pip
path: .
ruff.toml
ruff.toml
是 Ruff 代码检查工具的配置文件,用于配置代码风格和检查规则。
[tool.ruff]
line-length = 88
select = ["E", "F", "W", "I"]
ignore = ["E501"]
tox.ini
tox.ini
是 Tox 配置文件,用于配置项目的测试环境和测试命令。
[tox]
envlist = py37,py38,py39
[testenv]
deps =
pytest
commands =
pytest tests/
通过以上配置文件,你可以管理和配置 autodoc_pydantic
项目的开发、测试和文档生成环境。