From e3a27b76f2eb0a086fb8c1994294c34c70d71375 Mon Sep 17 00:00:00 2001 From: Jonathan Waltman Date: Tue, 19 Feb 2013 03:24:57 -0600 Subject: [PATCH] Closes #1110: Add new config value texinfo_no_detailmenu and do not generate detailed menus for non-"Top" nodes. --- CHANGES | 6 ++++++ doc/config.rst | 7 +++++++ sphinx/config.py | 1 + sphinx/quickstart.py | 3 +++ sphinx/writers/texinfo.py | 14 +++++++------- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index e8ebf9271..c5a1004d5 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,12 @@ Release 1.2 (in development) ============================ +* #1110: Added a new configuration value :confval:`texinfo_no_detailmenu` for + controlling whether the Texinfo writer generates a ``@detailmenu`` in the + "Top" node's menu. + +* The Texinfo writer now only generates detailed menus for the "Top" node. + * New locales: #1097: Added Basque locale. * Fix text builder did not respect wide/fullwidth characters: diff --git a/doc/config.rst b/doc/config.rst index 34d862e9a..961fd799c 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -1288,6 +1288,13 @@ These options influence Texinfo output. .. versionadded:: 1.1 +.. confval:: texinfo_no_detailmenu + + If true, do not generate a ``@detailmenu`` in the "Top" node's menu + containing entries for each sub-node in the document. Default is ``False``. + + .. versionadded:: 1.2 + .. confval:: texinfo_elements A dictionary that contains Texinfo snippets that override those Sphinx diff --git a/sphinx/config.py b/sphinx/config.py index 36a5b862a..2e548986d 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -192,6 +192,7 @@ class Config(object): texinfo_elements = ({}, None), texinfo_domain_indices = (True, None), texinfo_show_urls = ('footnote', None), + texinfo_no_detailmenu = (False, None), # linkcheck options linkcheck_ignore = ([], None), diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index 118d260ff..2184ba619 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -283,6 +283,9 @@ texinfo_documents = [ # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False ''' EPUB_CONFIG = u''' diff --git a/sphinx/writers/texinfo.py b/sphinx/writers/texinfo.py index a8306c113..21844c15c 100644 --- a/sphinx/writers/texinfo.py +++ b/sphinx/writers/texinfo.py @@ -391,7 +391,9 @@ class TexinfoTranslator(nodes.NodeVisitor): return self.body.append('\n@menu\n') self.add_menu_entries(entries) - if not self.node_menus[entries[0]]: + if (node_name != 'Top' or + not self.node_menus[entries[0]] or + self.builder.config.texinfo_no_detailmenu): self.body.append('\n@end menu\n') return @@ -404,14 +406,12 @@ class TexinfoTranslator(nodes.NodeVisitor): for subentry in entries: _add_detailed_menu(subentry) - if node_name == 'Top': - self.body.append('\n@detailmenu\n' - ' --- The Detailed Node Listing ---\n') + self.body.append('\n@detailmenu\n' + ' --- The Detailed Node Listing ---\n') for entry in entries: _add_detailed_menu(entry) - if node_name == 'Top': - self.body.append('\n@end detailmenu') - self.body.append('\n@end menu\n\n') + self.body.append('\n@end detailmenu\n' + '@end menu\n') def tex_image_length(self, width_str): match = re.match('(\d*\.?\d*)\s*(\S*)', width_str)