跳转到主要内容

Sphinx扩展,用于记录您的Pyramid API。

项目描述

pyramid_autodoc

Sphinx扩展,用于记录您的Pyramid API。

安装

pip install pyramid_autodoc

入门

要使用 pyramid_autodoc,只需将其添加到您的Sphinx conf.py 文件的 extensions 部分即可

# conf.py
extensions = [..., 'pyramid_autodoc']

然后创建一个新的 .rst 文档,该文档使用 pyramid-autodoc 指令,并为您提供Pyramid的 .ini 文件的路径。以下是一个示例

Welcome to my Pyramid app's API docs
====================================

These are the best APIs in the world!

.. autopyramid:: /path/to/development.ini

然后,您只需运行您的 sphinx-build 命令,它将自动从您的Pyramid路由和视图docstrings生成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: - 启用端点与源代码之间的链接。除非指定 link-code-pattern,否则假定正在使用 sphinx.ext.viewcode

  • :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

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分发

pyramid_autodoc-1.0.0.tar.gz (9.1 kB 查看哈希值)

上传时间 源代码

由以下机构支持