Readthedocs:有没有办法在一个文件中分别自动修改相同的模型函数?

时间:2016-11-29 14:09:50

标签: python python-sphinx restructuredtext read-the-docs

现在,我的文档/来源有一个index.rst,其 doctree 会导入另一个名为api.rst的文件。我这个api.rst文件我想autodoc一个python模块。此模块是一个.py,其中包含许多未附加到任何类的函数,但它们按功能分组。我可以写这样的api文件:

fbbotw api
==========

.. automodule:: fbbotw
   :members:

但是,如果不考虑这些组,它将自动调整所有功能。现在,我正在尝试使用.. autofunction::指令这样做:

fbbotw Functions reference
==========================

Graph API Functions
-------------------

.. autofunction:: fbbotw.get_user_information


Send Api Functions
------------------

Sender Actions
~~~~~~~~~~~~~~

.. autofunction:: fbbotw.typing

Content Types
~~~~~~~~~~~~~

.. autofunction:: fbbotw.post_text_message
.. autofunction:: fbbotw.post_audio_attachment
.. autofunction:: fbbotw.post_file_attachment
.. autofunction:: fbbotw.post_image_attachment
.. autofunction:: fbbotw.post_video_attachment

Quick Replies
~~~~~~~~~~~~~

.. autofunction:: fbbotw.post_text_w_quickreplies


Templates
~~~~~~~~~

.. autofunction:: fbbotw.post_button_template
.. autofunction:: fbbotw.post_generic_template
.. autofunction:: fbbotw.post_list_template
.. autofunction:: fbbotw.post_receipt_template

Buttons
~~~~~~~

.. autofunction:: fbbotw.post_call_button


Thread Settings Functions
-------------------------

.. autofunction:: fbbotw.post_settings
.. autofunction:: fbbotw.post_greeting_text
.. autofunction:: fbbotw.post_start_button
.. autofunction:: fbbotw.post_persistent_menu
.. autofunction:: fbbotw.post_domain_whitelisting
.. autofunction:: fbbotw.post_account_linking_url

它在本地工作,但在线readthedocs只创建api.rst的标题,但.. autofunction::没有做任何事情。还有其他方法可以做到这一点,还是我错过了任何配置?

我尝试过的其他事情:

对于api.rst中的每个组创建另一个文件并将其导入toctree,并在这些组文件中使用.. automodule: fbbotw :members: function1, function2...指定该文件中我想要autodoc的成员。

我真的怀疑它在readthedocs管理员身上可能是一个糟糕的配置,我不能让它在网上工作,因为它在本地工作正常。

2 个答案:

答案 0 :(得分:0)

Sphinx有一个autodocs api用于自动为您的包生成第一个文件。您可以在autodocs运行后逐步编辑并添加更多信息。运行autodocs时要小心,因为它可能会覆盖旧文件。

答案 1 :(得分:0)

@MikhailKorobov在评论中回答:

  

因此问题与autofunction vs automodule无关,它是   autodocs不工作,对吧?他们有一个FAQ部分   问题:   http://read-the-docs.readthedocs.io/en/latest/faq.html#my-project-isn-t-building-with-autodoc

我的模块上有ImportError因此autodoc无法设置它。检查readthedocs构建日志我可以看到我的测试中没有涵盖此ImportError,并且构建文档的环境也不同。现在工作:http://fbbotw.readthedocs.io/en/latest/