Sphinx扩展,用于自动生成API树。
项目描述
sphinx-apitree
apitree
是一个小型库,可以以最小的摩擦生成可用的文档!
apitree
负责一切,因此您可以只关注代码。
使用方法
在 docs/conf.py
中,替换所有内容为
import apitree
apitree.make_project(
# e.g. `import visu3d as v3d` -> {'v3d': 'visu3d'}
project_name={'alias': 'my_module'},
globals=globals(),
)
然后生成文档
sphinx-build -b html docs/ docs/_build
要在您的 toctree 中添加 api/my_module/index
,例如
..toctree:
:caption: API
api/my_module/index
功能
- 全部包含:单次函数调用包括主题、API生成等 ...
- 自动生成API树
- 不需要
__all__
(智能检测哪些符号已记录) - 添加可展开的toc树,包含所有符号
- 不需要
- 添加到
GitHub
的链接。 - 默认支持Markdown(
.md
)/ Jupyter(.ipynb
) - 自动交叉引用(只需在Markdown内联代码中注释
my_symbol
,链接会自动添加) - 与
autodoc
和apitree
相反,它还记录- 类型注解(
Union[]
,...) - 属性
- 类型注解(
- ...
在项目中安装
-
在
pyproject.toml
中[project.optional-dependencies] # Installed through `pip install .[docs]` docs = [ # Install `apitree` with all extensions (sphinx, theme,...) "sphinx-apitree[ext]", ]
-
在
.readthedocs.yaml
中sphinx: configuration: docs/conf.py python: install: - method: pip path: . extra_requirements: - docs
选项
默认情况下,apitree
尝试自动推断一切。但是有时用户想覆盖默认选项。
-
包与模块:默认情况下,所有
__init__.py
定义公共API(记录导入),而模块(module.py
)定义实现(不记录导入)。您可以通过在模块定义中添加来显式标记模块为包,以便记录其导入,如下所示__apitree__ = dict( is_package=True, )
使用apitree的项目示例
- https://github.com/google-research/visu3d (https://visu3d.readthedocs.io/)
- https://github.com/google-research/dataclass_array (https://dataclass-array.readthedocs.io/)
- https://github.com/google-research/etils (https://etils.readthedocs.io/)
- https://github.com/google-research/kauldron (https://kauldron.readthedocs.io/)
生成于
echo start \
&& cd ../visu3d && sphinx-build -b html docs/ docs/_build \
&& cd ../dataclass_array && sphinx-build -b html docs/ docs/_build \
&& cd ../etils && sphinx-build -b html docs/ docs/_build \
&& cd ../kauldron && sphinx-build -b html docs/ docs/_build \
&& echo finished
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源分布
sphinx_apitree-1.5.3.tar.gz (19.7 kB 查看散列)
构建分布
sphinx_apitree-1.5.3-py3-none-any.whl (24.8 kB 查看散列)
关闭
sphinx_apitree-1.5.3.tar.gz 的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | b411cfd8091e0b193dda3197c78f846583d0eb1e41787c6b36bcf919bc544175 |
|
MD5 | 03620d0c5d0a8e36d5167685e9a92257 |
|
BLAKE2b-256 | 0a697b91bd607b86a763297cbb8a64631b7cadea161d217058701cdf07585d4c |
关闭
sphinx_apitree-1.5.3-py3-none-any.whl 的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 8809a0a66ccb701582ca8b39125057d022b538d16b5017f02c4469e5e72f48a9 |
|
MD5 | ebc222047df971e96e8547dfdced8d6e |
|
BLAKE2b-256 | 1a45d2f2745b8514ba02173ee1e1351c0625c5e262cf1b14f46d20a0542ed962 |