mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add initial ability to output a name
This commit is contained in:
@@ -39,6 +39,7 @@ class TocTree(Directive):
|
||||
final_argument_whitespace = False
|
||||
option_spec = {
|
||||
'maxdepth': int,
|
||||
'name': str,
|
||||
'glob': directives.flag,
|
||||
'hidden': directives.flag,
|
||||
'includehidden': directives.flag,
|
||||
@@ -50,6 +51,7 @@ class TocTree(Directive):
|
||||
env = self.state.document.settings.env
|
||||
suffix = env.config.source_suffix
|
||||
glob = 'glob' in self.options
|
||||
name = self.options.get('name')
|
||||
|
||||
ret = []
|
||||
# (title, ref) pairs, where ref may be a document, or an external link,
|
||||
@@ -105,6 +107,7 @@ class TocTree(Directive):
|
||||
# includefiles only entries that are documents
|
||||
subnode['includefiles'] = includefiles
|
||||
subnode['maxdepth'] = self.options.get('maxdepth', -1)
|
||||
subnode['name'] = name
|
||||
subnode['glob'] = glob
|
||||
subnode['hidden'] = 'hidden' in self.options
|
||||
subnode['includehidden'] = 'includehidden' in self.options
|
||||
|
@@ -1353,7 +1353,15 @@ class BuildEnvironment:
|
||||
separate=False, subtree=False):
|
||||
"""Return TOC entries for a toctree node."""
|
||||
refs = [(e[0], e[1]) for e in toctreenode['entries']]
|
||||
name = toctreenode.attributes.get('name')
|
||||
entries = []
|
||||
if name:
|
||||
entries.extend(
|
||||
nodes.reference('', '', internal=False,
|
||||
refuri='', anchorname='',
|
||||
*[nodes.Text(name)])
|
||||
)
|
||||
|
||||
for (title, ref) in refs:
|
||||
try:
|
||||
refdoc = None
|
||||
|
Reference in New Issue
Block a user