Skip to content

Commit

Permalink
Add domain object table of contents configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Sep 29, 2022
1 parent 571ec56 commit 95a4527
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions doc/usage/configuration.rst
Expand Up @@ -678,6 +678,11 @@ General configuration
:term:`object` names (for object types where a "module" of some kind is
defined), e.g. for :rst:dir:`py:function` directives. Default is ``True``.

.. confval:: toc_object_entries

Create table of contents entries for domain objects (e.g. functions, classes,
attributes, etc.). Default is ``True``.

.. confval:: toc_object_entries_show_parents

A string that determines how domain objects (e.g. functions, classes,
Expand Down
1 change: 1 addition & 0 deletions sphinx/config.py
Expand Up @@ -106,6 +106,7 @@ class Config:
'default_role': (None, 'env', [str]),
'add_function_parentheses': (True, 'env', []),
'add_module_names': (True, 'env', []),
'toc_object_entries': (True, 'env', [bool]),
'toc_object_entries_show_parents': ('domain', 'env',
ENUM('domain', 'all', 'hide')),
'trim_footnote_reference_space': (False, 'env', []),
Expand Down
8 changes: 6 additions & 2 deletions sphinx/directives/__init__.py
Expand Up @@ -239,8 +239,12 @@ def run(self) -> List[Node]:
finally:
# Private attributes for ToC generation. Will be modified or removed
# without notice.
signode['_toc_parts'] = self._object_hierarchy_parts(signode)
signode['_toc_name'] = self._toc_entry_name(signode)
if self.env.app.config.toc_object_entries:
signode['_toc_parts'] = self._object_hierarchy_parts(signode)
signode['_toc_name'] = self._toc_entry_name(signode)
else:
signode['_toc_parts'] = ()
signode['_toc_name'] = ''
if name not in self.names:
self.names.append(name)
if not noindex:
Expand Down

0 comments on commit 95a4527

Please sign in to comment.