Anonymous avatar Anonymous committed 251e68a

Make it possible to deactivate the module index.

Comments (0)

Files changed (6)

    Additional templates that should be rendered to HTML pages, must be a
    dictionary that maps document names to template names.
 
+.. confval:: html_use_modindex
+
+   If true, add a module index to the HTML documents.   Default is ``True``.
+
 .. confval:: html_copy_source
 
    If true, the reST sources are included in the HTML build as
 .. confval:: latex_preamble
 
    Additional LaTeX markup for the preamble.
+
+.. confval:: latex_use_modindex
+
+   If true, add a module index to LaTeX documents.   Default is ``True``.

sphinx/builder.py

             version = self.config.version,
             last_updated = self.last_updated,
             style = self.config.html_style,
+            use_modindex = self.config.html_use_modindex,
             builder = self.name,
             parents = [],
             titles = {},
 
         # the global module index
 
-        # the sorted list of all modules, for the global module index
-        modules = sorted(((mn, (self.get_relative_uri('modindex', fn) +
-                                '#module-' + mn, sy, pl, dep))
-                          for (mn, (fn, sy, pl, dep)) in self.env.modules.iteritems()),
-                         key=lambda x: x[0].lower())
-        # collect all platforms
-        platforms = set()
-        # sort out collapsable modules
-        modindexentries = []
-        pmn = ''
-        cg = 0 # collapse group
-        fl = '' # first letter
-        for mn, (fn, sy, pl, dep) in modules:
-            pl = pl and pl.split(', ') or []
-            platforms.update(pl)
-            if fl != mn[0].lower() and mn[0] != '_':
-                modindexentries.append(['', False, 0, False,
-                                        mn[0].upper(), '', [], False])
-            tn = mn.split('.')[0]
-            if tn != mn:
-                # submodule
-                if pmn == tn:
-                    # first submodule - make parent collapsable
-                    modindexentries[-1][1] = True
-                elif not pmn.startswith(tn):
-                    # submodule without parent in list, add dummy entry
+        if self.config.html_use_modindex:
+            # the sorted list of all modules, for the global module index
+            modules = sorted(((mn, (self.get_relative_uri('modindex', fn) +
+                                    '#module-' + mn, sy, pl, dep))
+                              for (mn, (fn, sy, pl, dep)) in self.env.modules.iteritems()),
+                             key=lambda x: x[0].lower())
+            # collect all platforms
+            platforms = set()
+            # sort out collapsable modules
+            modindexentries = []
+            pmn = ''
+            cg = 0 # collapse group
+            fl = '' # first letter
+            for mn, (fn, sy, pl, dep) in modules:
+                pl = pl and pl.split(', ') or []
+                platforms.update(pl)
+                if fl != mn[0].lower() and mn[0] != '_':
+                    modindexentries.append(['', False, 0, False,
+                                            mn[0].upper(), '', [], False])
+                tn = mn.split('.')[0]
+                if tn != mn:
+                    # submodule
+                    if pmn == tn:
+                        # first submodule - make parent collapsable
+                        modindexentries[-1][1] = True
+                    elif not pmn.startswith(tn):
+                        # submodule without parent in list, add dummy entry
+                        cg += 1
+                        modindexentries.append([tn, True, cg, False, '', '', [], False])
+                else:
                     cg += 1
-                    modindexentries.append([tn, True, cg, False, '', '', [], False])
-            else:
-                cg += 1
-            modindexentries.append([mn, False, cg, (tn != mn), fn, sy, pl, dep])
-            pmn = mn
-            fl = mn[0].lower()
-        platforms = sorted(platforms)
+                modindexentries.append([mn, False, cg, (tn != mn), fn, sy, pl, dep])
+                pmn = mn
+                fl = mn[0].lower()
+            platforms = sorted(platforms)
 
-        modindexcontext = dict(
-            modindexentries = modindexentries,
-            platforms = platforms,
-        )
-        self.handle_page('modindex', modindexcontext, 'modindex.html')
+            modindexcontext = dict(
+                modindexentries = modindexentries,
+                platforms = platforms,
+            )
+            self.handle_page('modindex', modindexcontext, 'modindex.html')
 
         # the search page
         self.handle_page('search', {}, 'search.html')
         html_index = ('', False),
         html_sidebars = ({}, False),
         html_additional_pages = ({}, False),
+        html_use_modindex = (True, False),
         html_copy_source = (True, False),
 
         # HTML help options
         latex_documents = ([], False),
         latex_preamble = ('', False),
         latex_appendices = ([], False),
+        latex_use_modindex = (True, False),
     )
 
     def __init__(self, dirname, filename):

sphinx/latexwriter.py

 \author{%(author)s}
 %(preamble)s
 \makeindex
-\makemodindex
 '''
 
 FOOTER = r'''
-\printmodindex
 \printindex
 \end{document}
 '''
         self.builder = builder
 
     def translate(self):
-        try:
-            visitor = LaTeXTranslator(self.document, self.builder)
-            self.document.walkabout(visitor)
-            self.output = visitor.astext()
-        except:
-            import pdb, sys, traceback
-            traceback.print_exc()
-            tb = sys.exc_info()[2]
-            pdb.post_mortem(tb)
+        visitor = LaTeXTranslator(self.document, self.builder)
+        self.document.walkabout(visitor)
+        self.output = visitor.astext()
 
 
 # Helper classes
                         'papersize': paper,
                         'pointsize': builder.config.latex_font_size,
                         'preamble': builder.config.latex_preamble,
+                        'modindex': builder.config.latex_use_modindex,
                         'author': document.settings.author,
                         'docname': document.settings.docname,
                         # if empty, the title is set to the first section title
 
     def astext(self):
         return (HEADER % self.options) + \
+               (self.options['modindex'] and '\\makemodindex\n' or '') + \
                self.highlighter.get_stylesheet() + '\n\n' + \
                u''.join(self.body) + \
+               (self.options['modindex'] and '\\printmodindex\n' or '') + \
                (FOOTER % self.options)
 
     def visit_document(self, node):

sphinx/quickstart.py

 # template names.
 #html_additional_pages = {}
 
+# If false, no module index is generated.
+#html_use_modindex = True
+
 # If true, the reST sources are included in the HTML build as _sources/<name>.
 #html_copy_source = True
 
 
 # Documents to append as an appendix to all manuals.
 #latex_appendices = []
+
+# If false, no module index is generated.
+#latex_use_modindex = True
 '''
 
 MASTER_FILE = '''\

sphinx/templates/layout.html

       <h3>Navigation</h3>
       <ul>
         <li class="right" style="margin-right: 10px"><a href="{{ pathto('genindex') }}" title="General Index" accesskey="I">index</a></li>
+        {%- if use_modindex %}
         <li class="right"><a href="{{ pathto('modindex') }}" title="Global Module Index" accesskey="M">modules</a> |</li>
+        {%- endif %}
         {%- if next %}
           <li class="right"><a href="{{ next.link|e }}" title="{{ next.title|striptags }}" accesskey="N">next</a> |</li>
         {%- endif %}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.