Sphinx扩展,用于记录金字塔API。
pyramid_autodoc的Python项目详细描述
金字塔自动文档
Sphinx扩展,用于记录金字塔API。
安装
pip install pyramid_autodoc
开始
要使用pyramid_autodoc,只需将其添加到extensions sphinxconf.py文件的节:
# conf.pyextensions=[...,'pyramid_autodoc']
然后创建一个新的.rst文档,使用pyramid-autodoc 指示并提供金字塔的.ini文件的路径。下面是一个示例:
Welcome to my Pyramid app's API docs==================================== These are the best APIs in the world! ..autopyramid:: /path/to/development.ini
然后您可以运行sphinx-build命令,它将自动生成 来自金字塔路由和视图docstring的api文档。
我们还支持使用sphinxcontrib-httpdomain格式,只需使用 :format:设置:
Welcome to my Pyramid app's API docs==================================== These are the best APIs in the world! ..autopyramid:: /path/to/development.ini :format:httpdomain
忽略端点
如果您有一组不希望完全分组或跳过的端点 您可以使用以下几个选项:
- :match-path:-只列出一组特定的路径
- :skip-path:-黑名单一组特定的路径
- :match-module:-白名单一组模块
- :skip-module:-黑名单一组模块
Welcome to my Pyramid app's API docs==================================== These are the best APIs in the world! ..autopyramid:: /path/to/development.ini :skip-module: ^myapp.v1.* :match-path: ^/data
链接到源代码
如果要从终结点链接到相应的源代码 视图,并且您正在使用sphinx.ext.viewcode,您可以生成指向 它生成的源代码页。或者,如果你的消息来源在网上, 您可以生成外部链接。
- :link-code:-启用从终结点到源代码的链接。假设 sphinx.ext.viewcode正在使用,除非指定了link-code-pattern。
- :link-code-pattern:-用于生成指向源代码的链接的模式url。
模式中的标记替换为以下值。
- {file}替换为文件路径,例如pyramid_autodoc/utils.py。
- {lineno_start}替换为视图的起始行号,例如。 17。
- {lineno_end}替换为视图的结束行号,例如。 22。
Welcome to my Pyramid app's API docs==================================== Links to source code within the docs. ..autopyramid:: /path/to/development.ini :link-code: Links to source code on GitHub. ..autopyramid:: /path/to/development.ini :link-code::link-code-pattern:https://github.com/SurveyMonkey/pyramid_autodoc/blob/master/{file}#L{lineno_start}-L{lineno_end}
在最后一个例子中,生成的链接看起来像 https://github.com/SurveyMonkey/pyramid_autodoc/blob/master/pyramid_autodoc/utils.py#L17-L22。