mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Prettier console output from latex, texinfo, singlehtml and man page builders while inlining toctrees (#12681)
This commit is contained in:
parent
f0365cda38
commit
4a95555eae
@ -293,7 +293,7 @@ class LaTeXBuilder(Builder):
|
|||||||
toctree_only = entry[5]
|
toctree_only = entry[5]
|
||||||
destination = SphinxFileOutput(destination_path=path.join(self.outdir, targetname),
|
destination = SphinxFileOutput(destination_path=path.join(self.outdir, targetname),
|
||||||
encoding='utf-8', overwrite_if_changed=True)
|
encoding='utf-8', overwrite_if_changed=True)
|
||||||
with progress_message(__("processing %s") % targetname):
|
with progress_message(__("processing %s") % targetname, nonl=False):
|
||||||
doctree = self.env.get_doctree(docname)
|
doctree = self.env.get_doctree(docname)
|
||||||
toctree = next(doctree.findall(addnodes.toctree), None)
|
toctree = next(doctree.findall(addnodes.toctree), None)
|
||||||
if toctree and toctree.get('maxdepth') > 0:
|
if toctree and toctree.get('maxdepth') > 0:
|
||||||
@ -344,7 +344,7 @@ class LaTeXBuilder(Builder):
|
|||||||
self, indexfile: str, toctree_only: bool, appendices: list[str],
|
self, indexfile: str, toctree_only: bool, appendices: list[str],
|
||||||
) -> nodes.document:
|
) -> nodes.document:
|
||||||
self.docnames = {indexfile, *appendices}
|
self.docnames = {indexfile, *appendices}
|
||||||
logger.info(darkgreen(indexfile) + " ", nonl=True)
|
logger.info(darkgreen(indexfile))
|
||||||
tree = self.env.get_doctree(indexfile)
|
tree = self.env.get_doctree(indexfile)
|
||||||
tree['docname'] = indexfile
|
tree['docname'] = indexfile
|
||||||
if toctree_only:
|
if toctree_only:
|
||||||
|
@ -86,7 +86,7 @@ class ManualPageBuilder(Builder):
|
|||||||
else:
|
else:
|
||||||
targetname = f'{name}.{section}'
|
targetname = f'{name}.{section}'
|
||||||
|
|
||||||
logger.info(darkgreen(targetname) + ' { ', nonl=True)
|
logger.info(darkgreen(targetname) + ' { ')
|
||||||
destination = FileOutput(
|
destination = FileOutput(
|
||||||
destination_path=path.join(self.outdir, targetname),
|
destination_path=path.join(self.outdir, targetname),
|
||||||
encoding='utf-8')
|
encoding='utf-8')
|
||||||
|
@ -80,6 +80,7 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
|
|||||||
def assemble_doctree(self) -> nodes.document:
|
def assemble_doctree(self) -> nodes.document:
|
||||||
master = self.config.root_doc
|
master = self.config.root_doc
|
||||||
tree = self.env.get_doctree(master)
|
tree = self.env.get_doctree(master)
|
||||||
|
logger.info(darkgreen(master))
|
||||||
tree = inline_all_toctrees(self, set(), master, tree, darkgreen, [master])
|
tree = inline_all_toctrees(self, set(), master, tree, darkgreen, [master])
|
||||||
tree['docname'] = master
|
tree['docname'] = master
|
||||||
self.env.resolve_references(tree, master, self)
|
self.env.resolve_references(tree, master, self)
|
||||||
@ -157,7 +158,7 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder):
|
|||||||
with progress_message(__('preparing documents')):
|
with progress_message(__('preparing documents')):
|
||||||
self.prepare_writing(docnames) # type: ignore[arg-type]
|
self.prepare_writing(docnames) # type: ignore[arg-type]
|
||||||
|
|
||||||
with progress_message(__('assembling single document')):
|
with progress_message(__('assembling single document'), nonl=False):
|
||||||
doctree = self.assemble_doctree()
|
doctree = self.assemble_doctree()
|
||||||
self.env.toc_secnumbers = self.assemble_toc_secnumbers()
|
self.env.toc_secnumbers = self.assemble_toc_secnumbers()
|
||||||
self.env.toc_fignumbers = self.assemble_toc_fignumbers()
|
self.env.toc_fignumbers = self.assemble_toc_fignumbers()
|
||||||
|
@ -104,7 +104,7 @@ class TexinfoBuilder(Builder):
|
|||||||
destination = FileOutput(
|
destination = FileOutput(
|
||||||
destination_path=path.join(self.outdir, targetname),
|
destination_path=path.join(self.outdir, targetname),
|
||||||
encoding='utf-8')
|
encoding='utf-8')
|
||||||
with progress_message(__("processing %s") % targetname):
|
with progress_message(__("processing %s") % targetname, nonl=False):
|
||||||
appendices = self.config.texinfo_appendices or []
|
appendices = self.config.texinfo_appendices or []
|
||||||
doctree = self.assemble_doctree(docname, toctree_only, appendices=appendices)
|
doctree = self.assemble_doctree(docname, toctree_only, appendices=appendices)
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ class TexinfoBuilder(Builder):
|
|||||||
self, indexfile: str, toctree_only: bool, appendices: list[str],
|
self, indexfile: str, toctree_only: bool, appendices: list[str],
|
||||||
) -> nodes.document:
|
) -> nodes.document:
|
||||||
self.docnames = {indexfile, *appendices}
|
self.docnames = {indexfile, *appendices}
|
||||||
logger.info(darkgreen(indexfile) + " ", nonl=True)
|
logger.info(darkgreen(indexfile))
|
||||||
tree = self.env.get_doctree(indexfile)
|
tree = self.env.get_doctree(indexfile)
|
||||||
tree['docname'] = indexfile
|
tree['docname'] = indexfile
|
||||||
if toctree_only:
|
if toctree_only:
|
||||||
|
@ -414,6 +414,7 @@ def inline_all_toctrees(
|
|||||||
tree: nodes.document,
|
tree: nodes.document,
|
||||||
colorfunc: Callable[[str], str],
|
colorfunc: Callable[[str], str],
|
||||||
traversed: list[str],
|
traversed: list[str],
|
||||||
|
indent: str = '',
|
||||||
) -> nodes.document:
|
) -> nodes.document:
|
||||||
"""Inline all toctrees in the *tree*.
|
"""Inline all toctrees in the *tree*.
|
||||||
|
|
||||||
@ -423,14 +424,15 @@ def inline_all_toctrees(
|
|||||||
for toctreenode in list(tree.findall(addnodes.toctree)):
|
for toctreenode in list(tree.findall(addnodes.toctree)):
|
||||||
newnodes = []
|
newnodes = []
|
||||||
includefiles = map(str, toctreenode['includefiles'])
|
includefiles = map(str, toctreenode['includefiles'])
|
||||||
|
indent += ' '
|
||||||
for includefile in includefiles:
|
for includefile in includefiles:
|
||||||
if includefile not in traversed:
|
if includefile not in traversed:
|
||||||
try:
|
try:
|
||||||
traversed.append(includefile)
|
traversed.append(includefile)
|
||||||
logger.info(colorfunc(includefile) + " ", nonl=True)
|
logger.info(indent + colorfunc(includefile))
|
||||||
subtree = inline_all_toctrees(builder, docnameset, includefile,
|
subtree = inline_all_toctrees(builder, docnameset, includefile,
|
||||||
builder.env.get_doctree(includefile),
|
builder.env.get_doctree(includefile),
|
||||||
colorfunc, traversed)
|
colorfunc, traversed, indent)
|
||||||
docnameset.add(includefile)
|
docnameset.add(includefile)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.warning(__('toctree contains ref to nonexisting file %r'),
|
logger.warning(__('toctree contains ref to nonexisting file %r'),
|
||||||
|
Loading…
Reference in New Issue
Block a user