我使用Sphinx+autodoc+autosummary为我的项目(mrpy)生成文档。
我正在做一个两层的总结,在index.rst中我有(最少)
mrpy
====
.. autosummary::
:toctree: _autosummary
:template: modules.rst
mrpy.stats
<other modules...>如您所见,我为模块级的自动摘要使用了自定义模板。我这样做是为了让模块级的总结,我也得到了模块内的对象摘要,其中每个链接到自己的页面。作为参考,我的modules.rst文件是
{{ fullname }}
{{ underline }}
.. automodule:: {{ fullname }}
{% block functions %}
{% if functions %}
.. rubric:: Functions
.. autosummary::
:toctree: {{ objname }}
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% block classes %}
{% if classes %}
.. rubric:: Classes
.. autosummary::
:toctree: {{ objname }}
:template: class.rst
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% block exceptions %}
{% if exceptions %}
.. rubric:: Exceptions
.. autosummary::
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}mrpy.stats只包含三个类,它们在索引页上生成的表中的链接中被很好地概括。在遵循指向其中一个类的链接时,我使用另一个自定义模板class.rst
{{ fullname }}
{{ underline }}
.. currentmodule:: {{ module }}
.. autoclass:: {{ objname }}
{% block methods %}
{% if methods %}
.. rubric:: Methods
.. autosummary::
:toctree: {{ objname }}
{% for item in methods %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
{% block attributes %}
{% if attributes %}
.. rubric:: Attributes
.. autosummary::
:toctree: {{ objname }}
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}但是,该类的页面如预期的那样包含类docstring的标题,但包含类的方法和属性的两个表式摘要。
有人知道怎么摆脱其中一个多余的桌子吗?
发布于 2016-01-05 04:16:19
答案似乎是numpydoc使用了自动摘要。将numpydoc_show_class_members=False添加到conf.py解决了这个问题。在这里找到的解决方案:https://github.com/phn/pytpm/issues/3#issuecomment-12133978
https://stackoverflow.com/questions/34216659
复制相似问题