为什么sphinxcontib-httpdomain指令http:post是未知的?

问题描述 投票:1回答:1

我在使用sphinxcontrib-httpdomain时遇到麻烦。如果我定义http get或post或任何其他域,则sphinx-build会告诉我有关错误

未知指令类型“ http:get”

我的资源中http:post域的定义:

.. http:get:: /users/(int:user_id)/posts/(tag)

   The posts tagged with `tag` that the user (`user_id`) wrote.

   **Example request**:

   .. sourcecode:: http

      GET /users/123/posts/web HTTP/1.1
      Host: example.com
      Accept: application/json, text/javascript

   **Example response**:

   .. sourcecode:: http

      HTTP/1.1 200 OK
      Vary: Accept
      Content-Type: text/javascript

      [
        {
          "post_id": 12345,
          "author_id": 123,
          "tags": ["server", "web"],
          "subject": "I tried Nginx"
        },
        {
          "post_id": 12346,
          "author_id": 123,
          "tags": ["html5", "standards", "web"],
          "subject": "We go to HTML 5"
        }
      ]

   :query sort: one of ``hit``, ``created-at``
   :query offset: offset number. default is 0
   :query limit: limit number. default is 30
   :reqheader Accept: the response content type depends on
                      :mailheader:`Accept` header
   :reqheader Authorization: optional OAuth token to authenticate
   :resheader Content-Type: this depends on :mailheader:`Accept`
                            header of request
   :statuscode 200: no error
   :statuscode 404: there's no user

此块前后有两个空行。我尝试使用3,4个空格并偏移块的内容

conf.py扩展模块的内容:

extensions = ['sphinx.ext.autodoc',
            'sphinx.ext.extlinks',
            'sphinx.ext.intersphinx',
            'sphinx.ext.todo',
            'sphinx.ext.coverage',
            'sphinx.ext.ifconfig',
            'sphinx.ext.doctest',
            'sphinx.ext.graphviz',
            'sphinxcontrib.httpdomain'
            ]

[我也尝试过,但没有帮助:-要通过pip重新安装所有sphinx *软件包

  • 要通过apt-get重新安装所有sphinx *软件包

  • 要在conf.py中指定扩展路径

  • 要通过pip重新安装所有autodoc,docutils软件包

  • 要在另一台主机上构建(相同错误)

  • 使用-vvv模式查看构建日志

  • 阅读[官方插件文档] [3]并完成所有步骤

一些有用的信息:

所有软件包都安装到/usr/local/lib/python2.7/dist-packages

点显示狮身人面像输出:

Name: Sphinx
Version: 1.6.7
Summary: Python documentation generator
Home-page: http://sphinx-doc.org/
Author: Georg Brandl
Author-email: [email protected]
License: BSD
Location: /usr/local/lib/python2.7/dist-packages
Requires: sphinxcontrib-websupport, babel, imagesize, setuptools, typing, Pygments, requests, six, docutils, alabaster, Jinja2, snowballstemmer

pip show sphinxcontrib-httpdomain输出:

Name: sphinxcontrib-httpdomain
Version: 1.6.0
Summary: Sphinx domain for documenting HTTP APIs
Home-page: https://github.com/sphinx-contrib/httpdomain
Author: Hong Minhee
Author-email: [email protected]
License: BSD
Location: /usr/local/lib/python2.7/dist-packages
Requires: six, Sphinx

uname输出:

Linux 4.13.0-32-generic #35-Ubuntu SMP Thu Jan 25 09:13:46 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
python-sphinx
1个回答
0
投票

解决了这个问题一段时间后,我终于找到了解决方案。 Debian buster和Ubuntu bionic(及更高版本)中包含的版本已添加了一个补丁程序,该补丁程序解决了一个问题,但增加了此问题。

此修补程序来自this commit,但缺少在this other commit中添加了几天的修补程序。

看来,即使您尝试使用pip进行安装,您仍在使用系统版本。您可以通过在/usr/lib/python2/dist-packages/sphinxcontrib/httpdomain.py中编辑代码来对其进行简单修补。

我正在将补丁发送给软件包维护者,希望它很快会在不稳定的情况下得到修复。

© www.soinside.com 2019 - 2024. All rights reserved.