Readthedocs:有没有办法在一个文件中单独自动记录相同的模型功能?
Readthedocs: Is there a way to autodoc same model functions separately in the one file?
现在我的 docs/source 有一个 index.rst
,它在其 doctree 中导入另一个名为 api.rst
的文件。在这个 api.rst
文件中,我想 autodoc
一个 python 模块。该模块是一个 .py 文件,其中包含许多未附加到任何 class 的函数,但它们按功能分组。我可以这样写 api 文件:
fbbotw api
==========
.. automodule:: fbbotw
:members:
然而,它会 autodoc
所有函数而不考虑这些组。现在,我正在尝试使用 .. 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 管理员上的一个错误配置,我无法让它在线工作,因为它在本地一切正常。
Sphinx 有一个 autodocs api 可以自动为您的包生成第一个文件。您可以在 autodocs 具有 运行 后编辑每个 rst 并添加更多信息。 运行ning autodocs 时要小心,因为它可能会覆盖旧文件。
@MikhailKorobov 在评论中的回答:
so the problem is not related to autofunction vs automodule, it is
autodocs which is not working, right? They have a FAQ section for this
problem:
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/
现在我的 docs/source 有一个 index.rst
,它在其 doctree 中导入另一个名为 api.rst
的文件。在这个 api.rst
文件中,我想 autodoc
一个 python 模块。该模块是一个 .py 文件,其中包含许多未附加到任何 class 的函数,但它们按功能分组。我可以这样写 api 文件:
fbbotw api
==========
.. automodule:: fbbotw
:members:
然而,它会 autodoc
所有函数而不考虑这些组。现在,我正在尝试使用 .. 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 管理员上的一个错误配置,我无法让它在线工作,因为它在本地一切正常。
Sphinx 有一个 autodocs api 可以自动为您的包生成第一个文件。您可以在 autodocs 具有 运行 后编辑每个 rst 并添加更多信息。 运行ning autodocs 时要小心,因为它可能会覆盖旧文件。
@MikhailKorobov 在评论中的回答:
so the problem is not related to autofunction vs automodule, it is autodocs which is not working, right? They have a FAQ section for this problem: 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/