mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Allow any master document structure when writing the HTML help contents file.
This commit is contained in:
parent
b6f8f5d37c
commit
ea5f9d7de7
14
CHANGES
14
CHANGES
@ -1,11 +1,17 @@
|
|||||||
Release 0.3 (TBA)
|
Changes in trunk
|
||||||
=================
|
================
|
||||||
|
|
||||||
New features added
|
New features added
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
* If the `pygments_style` contains a dot it's treated as import path and
|
* If the `pygments_style` config value contains a dot it's treated as the
|
||||||
used as style class.
|
import path of a custom Pygments style class.
|
||||||
|
|
||||||
|
Bugs fixed
|
||||||
|
----------
|
||||||
|
|
||||||
|
* sphinx.htmlwriter: Correctly write the TOC file for any structure of the
|
||||||
|
master document.
|
||||||
|
|
||||||
|
|
||||||
Release 0.2 (Apr 27, 2008)
|
Release 0.2 (Apr 27, 2008)
|
||||||
|
@ -700,7 +700,7 @@ class BuildEnvironment:
|
|||||||
stream=RedirStream(self._warnfunc))
|
stream=RedirStream(self._warnfunc))
|
||||||
return doctree
|
return doctree
|
||||||
|
|
||||||
def get_and_resolve_doctree(self, docname, builder, doctree=None):
|
def get_and_resolve_doctree(self, docname, builder, doctree=None, prune_toctrees=True):
|
||||||
"""Read the doctree from the pickle, resolve cross-references and
|
"""Read the doctree from the pickle, resolve cross-references and
|
||||||
toctrees and return it."""
|
toctrees and return it."""
|
||||||
if doctree is None:
|
if doctree is None:
|
||||||
@ -753,8 +753,9 @@ class BuildEnvironment:
|
|||||||
tocentries = _entries_from_toctree(toctreenode, separate=True)
|
tocentries = _entries_from_toctree(toctreenode, separate=True)
|
||||||
if tocentries:
|
if tocentries:
|
||||||
newnode = addnodes.compact_paragraph('', '', *tocentries)
|
newnode = addnodes.compact_paragraph('', '', *tocentries)
|
||||||
|
newnode['toctree'] = True
|
||||||
# prune the tree to maxdepth and replace titles
|
# prune the tree to maxdepth and replace titles
|
||||||
if maxdepth > 0:
|
if maxdepth > 0 and prune_toctrees:
|
||||||
_walk_depth(newnode, 1, maxdepth, titleoverrides)
|
_walk_depth(newnode, 1, maxdepth, titleoverrides)
|
||||||
# replace titles, if needed
|
# replace titles, if needed
|
||||||
if titleoverrides:
|
if titleoverrides:
|
||||||
|
@ -150,7 +150,8 @@ def build_hhx(builder, outdir, outname):
|
|||||||
if builder.config.html_use_modindex:
|
if builder.config.html_use_modindex:
|
||||||
f.write('<LI> ' + object_sitemap % ('Global Module Index', 'modindex.html'))
|
f.write('<LI> ' + object_sitemap % ('Global Module Index', 'modindex.html'))
|
||||||
# the TOC
|
# the TOC
|
||||||
toc = builder.env.get_and_resolve_doctree(builder.config.master_doc, builder)
|
tocdoc = builder.env.get_and_resolve_doctree(builder.config.master_doc, builder,
|
||||||
|
prune_toctrees=False)
|
||||||
def write_toc(node, ullevel=0):
|
def write_toc(node, ullevel=0):
|
||||||
if isinstance(node, nodes.list_item):
|
if isinstance(node, nodes.list_item):
|
||||||
f.write('<LI> ')
|
f.write('<LI> ')
|
||||||
@ -169,11 +170,10 @@ def build_hhx(builder, outdir, outname):
|
|||||||
elif isinstance(node, addnodes.compact_paragraph):
|
elif isinstance(node, addnodes.compact_paragraph):
|
||||||
for subnode in node:
|
for subnode in node:
|
||||||
write_toc(subnode, ullevel)
|
write_toc(subnode, ullevel)
|
||||||
elif isinstance(node, nodes.section):
|
istoctree = lambda node: isinstance(node, addnodes.compact_paragraph) and \
|
||||||
write_toc(node[1], ullevel)
|
node.has_key('toctree')
|
||||||
elif isinstance(node, nodes.document):
|
for node in tocdoc.traverse(istoctree):
|
||||||
write_toc(node[0], ullevel)
|
write_toc(node)
|
||||||
write_toc(toc)
|
|
||||||
f.write(contents_footer)
|
f.write(contents_footer)
|
||||||
finally:
|
finally:
|
||||||
f.close()
|
f.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user