mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Make it possible to deactivate the module index.
This commit is contained in:
parent
931cd9190a
commit
4d30e0bd40
@ -167,6 +167,10 @@ that use Sphinx' HTMLWriter class.
|
||||
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
|
||||
@ -217,3 +221,7 @@ These options influence LaTeX output.
|
||||
.. 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``.
|
||||
|
@ -315,6 +315,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
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 = {},
|
||||
@ -387,6 +388,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
|
||||
# the global module index
|
||||
|
||||
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))
|
||||
|
@ -53,6 +53,7 @@ class Config(object):
|
||||
html_index = ('', False),
|
||||
html_sidebars = ({}, False),
|
||||
html_additional_pages = ({}, False),
|
||||
html_use_modindex = (True, False),
|
||||
html_copy_source = (True, False),
|
||||
|
||||
# HTML help options
|
||||
@ -64,6 +65,7 @@ class Config(object):
|
||||
latex_documents = ([], False),
|
||||
latex_preamble = ('', False),
|
||||
latex_appendices = ([], False),
|
||||
latex_use_modindex = (True, False),
|
||||
)
|
||||
|
||||
def __init__(self, dirname, filename):
|
||||
|
@ -33,11 +33,9 @@ HEADER = r'''%% Generated by Sphinx.
|
||||
\author{%(author)s}
|
||||
%(preamble)s
|
||||
\makeindex
|
||||
\makemodindex
|
||||
'''
|
||||
|
||||
FOOTER = r'''
|
||||
\printmodindex
|
||||
\printindex
|
||||
\end{document}
|
||||
'''
|
||||
@ -57,15 +55,9 @@ class LaTeXWriter(writers.Writer):
|
||||
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)
|
||||
|
||||
|
||||
# Helper classes
|
||||
@ -100,6 +92,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
'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
|
||||
@ -127,8 +120,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
|
||||
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):
|
||||
|
@ -117,6 +117,9 @@ html_last_updated_fmt = '%%b %%d, %%Y'
|
||||
# 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
|
||||
|
||||
@ -142,6 +145,9 @@ htmlhelp_basename = '%(project)sdoc'
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_use_modindex = True
|
||||
'''
|
||||
|
||||
MASTER_FILE = '''\
|
||||
|
@ -9,7 +9,9 @@
|
||||
<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 %}
|
||||
|
Loading…
Reference in New Issue
Block a user