From e93f22e84e660e66f95509f0376bd08981785545 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Fri, 23 May 2008 14:01:53 +0000 Subject: [PATCH] Add html_use_index flag. --- CHANGES | 3 +++ doc/config.rst | 12 +++++++++--- sphinx/builder.py | 25 ++++++++++++++----------- sphinx/config.py | 1 + sphinx/quickstart.py | 3 +++ sphinx/templates/layout.html | 2 ++ 6 files changed, 32 insertions(+), 14 deletions(-) diff --git a/CHANGES b/CHANGES index ca42648d6..05b2c29c9 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,9 @@ New features added classes now that override the signature got via introspection from Python code. +* The new config value `html_use_index` can be used to switch index + generation in HTML documents off. + Bugs fixed ---------- diff --git a/doc/config.rst b/doc/config.rst index 83cf52599..80eb9c39b 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -197,7 +197,7 @@ that use Sphinx' HTMLWriter class. .. confval:: html_last_updated_fmt If this is not the empty string, a 'Last updated on:' timestamp is inserted - at every page bottom, using the given :func:`strftime` format. Default is + at every page bottom, using the given :func:`strftime` format. Default is ``'%b %d, %Y'``. .. confval:: html_use_smartypants @@ -223,7 +223,7 @@ that use Sphinx' HTMLWriter class. dictionary that maps document names to template names. Example:: - + html_additional_pages = { 'download': 'customdownload.html', } @@ -238,7 +238,7 @@ that use Sphinx' HTMLWriter class. you used this feature, migrate it by adding an ``'index'`` key to this setting, with your custom template as the value, and in your custom template, use :: - + {% extend "defindex.html" %} {% block tables %} ... old template content ... @@ -248,6 +248,12 @@ that use Sphinx' HTMLWriter class. If true, add a module index to the HTML documents. Default is ``True``. +.. confval:: html_use_index + + If true, add an index to the HTML documents. Default is ``True``. + + .. versionadded:: 0.5 + .. confval:: html_copy_source If true, the reST sources are included in the HTML build as diff --git a/sphinx/builder.py b/sphinx/builder.py index 211007d15..0fd838481 100644 --- a/sphinx/builder.py +++ b/sphinx/builder.py @@ -337,6 +337,7 @@ class StandaloneHTMLBuilder(Builder): copyright = self.config.copyright, style = self.config.html_style, use_modindex = self.config.html_use_modindex, + use_index = self.config.html_use_index, use_opensearch = self.config.html_use_opensearch, docstitle = docstitle, builder = self.name, @@ -410,18 +411,20 @@ class StandaloneHTMLBuilder(Builder): # the global general index - # the total count of lines for each index letter, used to distribute - # the entries into two columns - indexcounts = [] - for _, entries in self.env.index: - indexcounts.append(sum(1 + len(subitems) for _, (_, subitems) in entries)) + if self.config.html_use_index: + # the total count of lines for each index letter, used to distribute + # the entries into two columns + indexcounts = [] + for _, entries in self.env.index: + indexcounts.append(sum(1 + len(subitems) + for _, (_, subitems) in entries)) - genindexcontext = dict( - genindexentries = self.env.index, - genindexcounts = indexcounts, - ) - self.info(' genindex', nonl=1) - self.handle_page('genindex', genindexcontext, 'genindex.html') + genindexcontext = dict( + genindexentries = self.env.index, + genindexcounts = indexcounts, + ) + self.info(' genindex', nonl=1) + self.handle_page('genindex', genindexcontext, 'genindex.html') # the global module index diff --git a/sphinx/config.py b/sphinx/config.py index ad04d5517..90c1a931a 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -56,6 +56,7 @@ class Config(object): html_sidebars = ({}, False), html_additional_pages = ({}, False), html_use_modindex = (True, False), + html_use_index = (True, False), html_copy_source = (True, False), html_use_opensearch = ('', False), html_file_suffix = (None, False), diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index cf8856bb3..76d3f94cd 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -132,6 +132,9 @@ html_last_updated_fmt = '%%b %%d, %%Y' # If false, no module index is generated. #html_use_modindex = True +# If false, no index is generated. +#html_use_index = True + # If true, the reST sources are included in the HTML build as _sources/. #html_copy_source = True diff --git a/sphinx/templates/layout.html b/sphinx/templates/layout.html index a0806e93d..dfda6f69b 100644 --- a/sphinx/templates/layout.html +++ b/sphinx/templates/layout.html @@ -8,7 +8,9 @@