Sphinx域,用于在ReST中标记RESTful网络服务
项目描述
描述
Sphinx插件,用于添加HTTP域,允许文档化RESTful HTTP方法。
目前这是一个非常基础和实验性的代码。
HTTP方法
您可以文档化简单的方法,将路径中的任何参数用花括号括起来
.. http:method:: GET /api/foo/bar/{id}/{slug} :arg id: An id :arg slug: A slug Retrieve list of foobars matching given id.
查询字符串参数也受到支持,包括强制性和可选性
.. http:method:: GET /api/foo/bar/?id&slug :param id: An id :optparam slug: A slug Search for a list of foobars matching given id.
此外,您可以提供参数和参数的类型
.. http:method:: GET /api/foo/bar/{id}/?slug :arg integer id: An id :optparam string slug: A slug Search for a list of foobars matching given id.
也支持片段
.. http:method:: GET /#!/username :fragment username: A username Renders a user's profile page.
此外,您可以使用响应代码来文档化响应
.. http:method:: POST /api/foo/bar/ :param string slug: A slug :response 201: A foobar was created successfully. :response 400: Create a foobar.
要引用HTTP方法,请使用 :http:method:
.. http:method:: GET /api/ :label-name: get-root :title: API root The :http:method:`get-root` contains all of the API.
HTTP响应
文档化响应也很简单
.. http:response:: Foobar object A foobar object looks like this:: .. source-code:: js { 'slug': SLUG } :data string SLUG: A slug :format: JSON
要引用HTTP响应,请使用 :http:response:
.. http:response:: Foobar object A :http:response:`foobar-object` is returned when you foo the bar.
安装
运行 pip install sphinx-http-domain。
然后,将 sphinx_http_domain 添加到您的 conf.py
extensions = ['sphinx_http_domain']
开发
版本:预_alpha
欢迎为该项目做出贡献,请在此GitHub项目上fork!
贡献者
Simon Law (https://github.com/sfllaw)
项目详情
关闭
sphinx-http-domain-0.2.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 7e3f29bab7a00ccc40a8f58400a77522780aa262d6a5c140147721da8e25f2fb |
|
MD5 | 84ad0466da96d25b4a7dc4679adb9e62 |
|
BLAKE2b-256 | 2f0f8cba5fa05ae80a96cbe768fac6e628b1e65edfecff88d0b67240d92e6d1a |