Fix man build failure in newer sphinx versions
This commit is contained in:
parent
9a4e3488c2
commit
55ebd1a4c5
1 changed files with 9 additions and 5 deletions
|
@ -7,6 +7,7 @@ from docutils.io import FileOutput
|
||||||
from os import path
|
from os import path
|
||||||
from sphinx.util.nodes import inline_all_toctrees
|
from sphinx.util.nodes import inline_all_toctrees
|
||||||
from sphinx import addnodes
|
from sphinx import addnodes
|
||||||
|
from sphinx.util import logging
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Extension based on sphinx builtin manpage.
|
Extension based on sphinx builtin manpage.
|
||||||
|
@ -15,6 +16,9 @@ from sphinx import addnodes
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ManualPageTranslator(sphinx.writers.manpage.ManualPageTranslator):
|
class ManualPageTranslator(sphinx.writers.manpage.ManualPageTranslator):
|
||||||
|
|
||||||
def header(self):
|
def header(self):
|
||||||
|
@ -28,7 +32,7 @@ class ManualPageWriter(sphinx.writers.manpage.ManualPageWriter):
|
||||||
def __init__(self, builder):
|
def __init__(self, builder):
|
||||||
super().__init__(builder)
|
super().__init__(builder)
|
||||||
self.translator_class = (
|
self.translator_class = (
|
||||||
self.builder.translator_class or ManualPageTranslator)
|
self.builder.get_translator_class() or ManualPageTranslator)
|
||||||
|
|
||||||
|
|
||||||
class ManualPageBuilder(sphinx.builders.manpage.ManualPageBuilder):
|
class ManualPageBuilder(sphinx.builders.manpage.ManualPageBuilder):
|
||||||
|
@ -43,7 +47,7 @@ class ManualPageBuilder(sphinx.builders.manpage.ManualPageBuilder):
|
||||||
components=(docwriter,),
|
components=(docwriter,),
|
||||||
read_config_files=True).get_default_values()
|
read_config_files=True).get_default_values()
|
||||||
|
|
||||||
self.info(bold('writing... '), nonl=True)
|
logger.info(bold('writing... '), nonl=True)
|
||||||
|
|
||||||
for info in self.config.man_pages:
|
for info in self.config.man_pages:
|
||||||
docname, name, description, authors, section = info
|
docname, name, description, authors, section = info
|
||||||
|
@ -54,7 +58,7 @@ class ManualPageBuilder(sphinx.builders.manpage.ManualPageBuilder):
|
||||||
authors = []
|
authors = []
|
||||||
|
|
||||||
targetname = '%s.%s' % (name, section)
|
targetname = '%s.%s' % (name, section)
|
||||||
self.info(darkgreen(targetname) + ' { ', nonl=True)
|
logger.info(darkgreen(targetname) + ' { ', nonl=True)
|
||||||
destination = FileOutput(
|
destination = FileOutput(
|
||||||
destination_path=path.join(self.outdir, targetname),
|
destination_path=path.join(self.outdir, targetname),
|
||||||
encoding='utf-8')
|
encoding='utf-8')
|
||||||
|
@ -63,7 +67,7 @@ class ManualPageBuilder(sphinx.builders.manpage.ManualPageBuilder):
|
||||||
docnames = set()
|
docnames = set()
|
||||||
largetree = inline_all_toctrees(self, docnames, docname, tree,
|
largetree = inline_all_toctrees(self, docnames, docname, tree,
|
||||||
darkgreen, [docname])
|
darkgreen, [docname])
|
||||||
self.info('} ', nonl=True)
|
logger.info('} ', nonl=True)
|
||||||
self.env.resolve_references(largetree, docname, self)
|
self.env.resolve_references(largetree, docname, self)
|
||||||
# remove pending_xref nodes
|
# remove pending_xref nodes
|
||||||
for pendingnode in largetree.traverse(addnodes.pending_xref):
|
for pendingnode in largetree.traverse(addnodes.pending_xref):
|
||||||
|
@ -76,7 +80,7 @@ class ManualPageBuilder(sphinx.builders.manpage.ManualPageBuilder):
|
||||||
largetree.settings.section = section
|
largetree.settings.section = section
|
||||||
|
|
||||||
docwriter.write(largetree, destination)
|
docwriter.write(largetree, destination)
|
||||||
self.info()
|
logger.info("")
|
||||||
|
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
|
|
Loading…
Reference in a new issue