From 76c953052156f4fe0afac5982fb21cadcab107a7 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Fri, 9 Jan 2015 08:56:51 -0800 Subject: [PATCH] Add initial ability to output a name --- sphinx/directives/other.py | 3 +++ sphinx/environment.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py index 948de4fee..cdefede12 100644 --- a/sphinx/directives/other.py +++ b/sphinx/directives/other.py @@ -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 diff --git a/sphinx/environment.py b/sphinx/environment.py index 5820097dc..bf3e1c561 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -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