使用带有'autodoc'的sphinx按类对显示进行排序? [英] Sorting display by class using sphinx with 'autodoc'?
问题描述
有没有一种方法可以使用Sphinx显示班级列表/选项卡,或者组织生成的html页面以按班级显示成员,班级之间的视觉分隔很好?
Is there a way to display a "Classes" list / tab using Sphinx, or to organize the html pages generated to show members by class, classes being visually well separated?
我使用Sphinx 1.1.3,尝试记录Python扩展(使用Cython创建的自定义扩展)。
我的问题是,如果我进入模块选项卡(这是非常不可读的),则整个扩展名显示在一个块中,另一方面,索引选项卡将所有内容合并在一起(这是正常的)。我想按班级显示(更接近Doxygen的显示方式)。
I use Sphinx 1.1.3, an try to document a Python extension (a custom one created with Cython). My problem is that the whole extension is displayed in one single block if I enter the modules tab (which is quite unreadable) and, by the other hand, the "Index" tab merges everything together (which is normal). I would like a per class display (something closer to what Doxygen would do).
是否执行类似的操作:
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
* :ref:`classindex` ???
存在吗?
非常感谢。
推荐答案
autosummary
扩展名,带有 autosummary_generate
配置变量设置为 True
,可用于1)生成紧凑的摘要列表,以及2)生成每个类一页的类文档。
The autosummary
extension, with the autosummary_generate
configuration variable set to True
, can be used to 1) generate compact summary listings and 2) generate class documentation with one page per class.
您必须明确指定要包括的每个类,但是一旦完成,便有了一个用于生成清晰文档的设置,这些类在视觉上很好地分开了。
You have to explicitly specify each class to be included, but once this is done you have a setup for generating clear documentation where the classes are visually well separated.
以下标记将为每个类(Class1,Class2,Class3)输出一个存根 .rst页面。每个页面均基于模板,并包含提取完整文档的 .. autoclass ::
指令。在最终的HTML输出中,每个类页面都从主自动摘要表中的相应条目进行链接。
The following markup will output one "stub" .rst page for each class (Class1, Class2, Class3). Each page is based on a template and includes an .. autoclass::
directive that extracts the full documentation. In the final HTML output, each class page is linked from the corresponding entry in the main autosummary table.
:mod:`mymodule` --- Some module
===============================
This module contains several classes.
.. currentmodule:: mymodule
Class overview
--------------
.. autosummary::
:toctree: stubs
:template: class.rst
Class1
Class2
Class3
此处的详细信息:> https://www.sphinx-doc.org/en/master/usage/extensions/autosummary.html
这篇关于使用带有'autodoc'的sphinx按类对显示进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!