mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add a class option to the autosummary directive (#13144)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
----------
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
@@ -431,7 +432,9 @@ class Autosummary(SphinxDirective):
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user