跳转到主要内容

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']

开发

欢迎为该项目做出贡献,请在此GitHub项目上fork!

作者

David Zentgraf (https://github.com/deceze)

贡献者

项目详情


下载文件

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

源代码分发

sphinx-http-domain-0.2.tar.gz (9.6 kB 查看哈希值)

上传时间 源代码

由以下支持