Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Features added
* #11824: linkcode: Allow extensions to add support for a domain by defining
the keys that should be present.
Patch by Nicolas Peugnet.
* #13144: Add a ``class`` option to the :rst:dir:`autosummary` directive.
Patch by Tim Hoffmann.

Bugs fixed
----------
Expand Down
10 changes: 10 additions & 0 deletions doc/usage/extensions/autosummary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ The :mod:`sphinx.ext.autosummary` extension does this in two parts:

.. rubric:: Options

.. rst:directive:option:: class: class names
:type: a list of class names, separated by spaces

Assign `class attributes`_ to the table.
This is a :dudir:`common option <common-options>`.

.. _class attributes: https://docutils.sourceforge.io/docs/ref/doctree.html#classes

.. versionadded:: 8.2

.. rst:directive:option:: toctree: optional directory name

If you want the :rst:dir:`autosummary` table to also serve as a
Expand Down
5 changes: 4 additions & 1 deletion sphinx/ext/autosummary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ class Autosummary(SphinxDirective):
has_content = True
option_spec: ClassVar[OptionSpec] = {
'caption': directives.unchanged_required,
'class': directives.class_option,
'toctree': directives.unchanged,
'nosignatures': directives.flag,
'recursive': directives.flag,
Expand Down Expand Up @@ -431,7 +432,9 @@ def get_table(self, items: list[tuple[str, str, str, str]]) -> list[Node]:
table_spec['spec'] = r'\X{1}{2}\X{1}{2}'

table = autosummary_table('')
real_table = nodes.table('', classes=['autosummary longtable'])
real_table = nodes.table(
'', classes=['autosummary', 'longtable', *self.options.get('class', ())]
)
table.append(real_table)
group = nodes.tgroup('', cols=2)
real_table.append(group)
Expand Down
Loading