Skip to content

Commit 1d404d4

Browse files
committed
Add domain object table of contents configuration option
1 parent 3fbe4ac commit 1d404d4

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

doc/usage/configuration.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,11 @@ General configuration
678678
:term:`object` names (for object types where a "module" of some kind is
679679
defined), e.g. for :rst:dir:`py:function` directives. Default is ``True``.
680680

681+
.. confval:: toc_object_entries
682+
683+
Create table of contents entries for domain objects (e.g. functions, classes,
684+
attributes, etc.). Default is ``True``.
685+
681686
.. confval:: toc_object_entries_show_parents
682687

683688
A string that determines how domain objects (e.g. functions, classes,

sphinx/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class Config:
106106
'default_role': (None, 'env', [str]),
107107
'add_function_parentheses': (True, 'env', []),
108108
'add_module_names': (True, 'env', []),
109+
'toc_object_entries': (True, 'env', [bool]),
109110
'toc_object_entries_show_parents': ('domain', 'env',
110111
ENUM('domain', 'all', 'hide')),
111112
'trim_footnote_reference_space': (False, 'env', []),

sphinx/directives/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,12 @@ def run(self) -> List[Node]:
239239
finally:
240240
# Private attributes for ToC generation. Will be modified or removed
241241
# without notice.
242-
signode['_toc_parts'] = self._object_hierarchy_parts(signode)
243-
signode['_toc_name'] = self._toc_entry_name(signode)
242+
if self.env.app.config.toc_object_entries:
243+
signode['_toc_parts'] = self._object_hierarchy_parts(signode)
244+
signode['_toc_name'] = self._toc_entry_name(signode)
245+
else:
246+
signode['_toc_parts'] = ()
247+
signode['_toc_name'] = ''
244248
if name not in self.names:
245249
self.names.append(name)
246250
if not noindex:

0 commit comments

Comments
 (0)