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
|
Additional templates that should be rendered to HTML pages, must be a
|
||||||
dictionary that maps document names to template names.
|
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
|
.. confval:: html_copy_source
|
||||||
|
|
||||||
If true, the reST sources are included in the HTML build as
|
If true, the reST sources are included in the HTML build as
|
||||||
@ -217,3 +221,7 @@ These options influence LaTeX output.
|
|||||||
.. confval:: latex_preamble
|
.. confval:: latex_preamble
|
||||||
|
|
||||||
Additional LaTeX markup for the 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,
|
version = self.config.version,
|
||||||
last_updated = self.last_updated,
|
last_updated = self.last_updated,
|
||||||
style = self.config.html_style,
|
style = self.config.html_style,
|
||||||
|
use_modindex = self.config.html_use_modindex,
|
||||||
builder = self.name,
|
builder = self.name,
|
||||||
parents = [],
|
parents = [],
|
||||||
titles = {},
|
titles = {},
|
||||||
@ -387,46 +388,47 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
|
|
||||||
# the global module index
|
# the global module index
|
||||||
|
|
||||||
# the sorted list of all modules, for the global module index
|
if self.config.html_use_modindex:
|
||||||
modules = sorted(((mn, (self.get_relative_uri('modindex', fn) +
|
# the sorted list of all modules, for the global module index
|
||||||
'#module-' + mn, sy, pl, dep))
|
modules = sorted(((mn, (self.get_relative_uri('modindex', fn) +
|
||||||
for (mn, (fn, sy, pl, dep)) in self.env.modules.iteritems()),
|
'#module-' + mn, sy, pl, dep))
|
||||||
key=lambda x: x[0].lower())
|
for (mn, (fn, sy, pl, dep)) in self.env.modules.iteritems()),
|
||||||
# collect all platforms
|
key=lambda x: x[0].lower())
|
||||||
platforms = set()
|
# collect all platforms
|
||||||
# sort out collapsable modules
|
platforms = set()
|
||||||
modindexentries = []
|
# sort out collapsable modules
|
||||||
pmn = ''
|
modindexentries = []
|
||||||
cg = 0 # collapse group
|
pmn = ''
|
||||||
fl = '' # first letter
|
cg = 0 # collapse group
|
||||||
for mn, (fn, sy, pl, dep) in modules:
|
fl = '' # first letter
|
||||||
pl = pl and pl.split(', ') or []
|
for mn, (fn, sy, pl, dep) in modules:
|
||||||
platforms.update(pl)
|
pl = pl and pl.split(', ') or []
|
||||||
if fl != mn[0].lower() and mn[0] != '_':
|
platforms.update(pl)
|
||||||
modindexentries.append(['', False, 0, False,
|
if fl != mn[0].lower() and mn[0] != '_':
|
||||||
mn[0].upper(), '', [], False])
|
modindexentries.append(['', False, 0, False,
|
||||||
tn = mn.split('.')[0]
|
mn[0].upper(), '', [], False])
|
||||||
if tn != mn:
|
tn = mn.split('.')[0]
|
||||||
# submodule
|
if tn != mn:
|
||||||
if pmn == tn:
|
# submodule
|
||||||
# first submodule - make parent collapsable
|
if pmn == tn:
|
||||||
modindexentries[-1][1] = True
|
# first submodule - make parent collapsable
|
||||||
elif not pmn.startswith(tn):
|
modindexentries[-1][1] = True
|
||||||
# submodule without parent in list, add dummy entry
|
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
|
cg += 1
|
||||||
modindexentries.append([tn, True, cg, False, '', '', [], False])
|
modindexentries.append([mn, False, cg, (tn != mn), fn, sy, pl, dep])
|
||||||
else:
|
pmn = mn
|
||||||
cg += 1
|
fl = mn[0].lower()
|
||||||
modindexentries.append([mn, False, cg, (tn != mn), fn, sy, pl, dep])
|
platforms = sorted(platforms)
|
||||||
pmn = mn
|
|
||||||
fl = mn[0].lower()
|
|
||||||
platforms = sorted(platforms)
|
|
||||||
|
|
||||||
modindexcontext = dict(
|
modindexcontext = dict(
|
||||||
modindexentries = modindexentries,
|
modindexentries = modindexentries,
|
||||||
platforms = platforms,
|
platforms = platforms,
|
||||||
)
|
)
|
||||||
self.handle_page('modindex', modindexcontext, 'modindex.html')
|
self.handle_page('modindex', modindexcontext, 'modindex.html')
|
||||||
|
|
||||||
# the search page
|
# the search page
|
||||||
self.handle_page('search', {}, 'search.html')
|
self.handle_page('search', {}, 'search.html')
|
||||||
|
@ -53,6 +53,7 @@ class Config(object):
|
|||||||
html_index = ('', False),
|
html_index = ('', False),
|
||||||
html_sidebars = ({}, False),
|
html_sidebars = ({}, False),
|
||||||
html_additional_pages = ({}, False),
|
html_additional_pages = ({}, False),
|
||||||
|
html_use_modindex = (True, False),
|
||||||
html_copy_source = (True, False),
|
html_copy_source = (True, False),
|
||||||
|
|
||||||
# HTML help options
|
# HTML help options
|
||||||
@ -64,6 +65,7 @@ class Config(object):
|
|||||||
latex_documents = ([], False),
|
latex_documents = ([], False),
|
||||||
latex_preamble = ('', False),
|
latex_preamble = ('', False),
|
||||||
latex_appendices = ([], False),
|
latex_appendices = ([], False),
|
||||||
|
latex_use_modindex = (True, False),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, dirname, filename):
|
def __init__(self, dirname, filename):
|
||||||
|
@ -33,11 +33,9 @@ HEADER = r'''%% Generated by Sphinx.
|
|||||||
\author{%(author)s}
|
\author{%(author)s}
|
||||||
%(preamble)s
|
%(preamble)s
|
||||||
\makeindex
|
\makeindex
|
||||||
\makemodindex
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
FOOTER = r'''
|
FOOTER = r'''
|
||||||
\printmodindex
|
|
||||||
\printindex
|
\printindex
|
||||||
\end{document}
|
\end{document}
|
||||||
'''
|
'''
|
||||||
@ -57,15 +55,9 @@ class LaTeXWriter(writers.Writer):
|
|||||||
self.builder = builder
|
self.builder = builder
|
||||||
|
|
||||||
def translate(self):
|
def translate(self):
|
||||||
try:
|
visitor = LaTeXTranslator(self.document, self.builder)
|
||||||
visitor = LaTeXTranslator(self.document, self.builder)
|
self.document.walkabout(visitor)
|
||||||
self.document.walkabout(visitor)
|
self.output = visitor.astext()
|
||||||
self.output = visitor.astext()
|
|
||||||
except:
|
|
||||||
import pdb, sys, traceback
|
|
||||||
traceback.print_exc()
|
|
||||||
tb = sys.exc_info()[2]
|
|
||||||
pdb.post_mortem(tb)
|
|
||||||
|
|
||||||
|
|
||||||
# Helper classes
|
# Helper classes
|
||||||
@ -100,6 +92,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
'papersize': paper,
|
'papersize': paper,
|
||||||
'pointsize': builder.config.latex_font_size,
|
'pointsize': builder.config.latex_font_size,
|
||||||
'preamble': builder.config.latex_preamble,
|
'preamble': builder.config.latex_preamble,
|
||||||
|
'modindex': builder.config.latex_use_modindex,
|
||||||
'author': document.settings.author,
|
'author': document.settings.author,
|
||||||
'docname': document.settings.docname,
|
'docname': document.settings.docname,
|
||||||
# if empty, the title is set to the first section title
|
# if empty, the title is set to the first section title
|
||||||
@ -127,8 +120,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
|
|
||||||
def astext(self):
|
def astext(self):
|
||||||
return (HEADER % self.options) + \
|
return (HEADER % self.options) + \
|
||||||
|
(self.options['modindex'] and '\\makemodindex\n' or '') + \
|
||||||
self.highlighter.get_stylesheet() + '\n\n' + \
|
self.highlighter.get_stylesheet() + '\n\n' + \
|
||||||
u''.join(self.body) + \
|
u''.join(self.body) + \
|
||||||
|
(self.options['modindex'] and '\\printmodindex\n' or '') + \
|
||||||
(FOOTER % self.options)
|
(FOOTER % self.options)
|
||||||
|
|
||||||
def visit_document(self, node):
|
def visit_document(self, node):
|
||||||
|
@ -117,6 +117,9 @@ html_last_updated_fmt = '%%b %%d, %%Y'
|
|||||||
# template names.
|
# template names.
|
||||||
#html_additional_pages = {}
|
#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>.
|
# If true, the reST sources are included in the HTML build as _sources/<name>.
|
||||||
#html_copy_source = True
|
#html_copy_source = True
|
||||||
|
|
||||||
@ -142,6 +145,9 @@ htmlhelp_basename = '%(project)sdoc'
|
|||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
# Documents to append as an appendix to all manuals.
|
||||||
#latex_appendices = []
|
#latex_appendices = []
|
||||||
|
|
||||||
|
# If false, no module index is generated.
|
||||||
|
#latex_use_modindex = True
|
||||||
'''
|
'''
|
||||||
|
|
||||||
MASTER_FILE = '''\
|
MASTER_FILE = '''\
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
<h3>Navigation</h3>
|
<h3>Navigation</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li class="right" style="margin-right: 10px"><a href="{{ pathto('genindex') }}" title="General Index" accesskey="I">index</a></li>
|
<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>
|
<li class="right"><a href="{{ pathto('modindex') }}" title="Global Module Index" accesskey="M">modules</a> |</li>
|
||||||
|
{%- endif %}
|
||||||
{%- if next %}
|
{%- if next %}
|
||||||
<li class="right"><a href="{{ next.link|e }}" title="{{ next.title|striptags }}" accesskey="N">next</a> |</li>
|
<li class="right"><a href="{{ next.link|e }}" title="{{ next.title|striptags }}" accesskey="N">next</a> |</li>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user