mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5796 from jdufresne/super
Use Python 3 super() argument-less syntax
This commit is contained in:
commit
2597c4174e
@ -128,7 +128,7 @@ class desc_returns(desc_type):
|
|||||||
"""Node for a "returns" annotation (a la -> in Python)."""
|
"""Node for a "returns" annotation (a la -> in Python)."""
|
||||||
def astext(self):
|
def astext(self):
|
||||||
# type: () -> str
|
# type: () -> str
|
||||||
return ' -> ' + super(desc_returns, self).astext()
|
return ' -> ' + super().astext()
|
||||||
|
|
||||||
|
|
||||||
class desc_name(nodes.Part, nodes.Inline, nodes.FixedTextElement):
|
class desc_name(nodes.Part, nodes.Inline, nodes.FixedTextElement):
|
||||||
@ -150,7 +150,7 @@ class desc_optional(nodes.Part, nodes.Inline, nodes.FixedTextElement):
|
|||||||
|
|
||||||
def astext(self):
|
def astext(self):
|
||||||
# type: () -> str
|
# type: () -> str
|
||||||
return '[' + super(desc_optional, self).astext() + ']'
|
return '[' + super().astext() + ']'
|
||||||
|
|
||||||
|
|
||||||
class desc_annotation(nodes.Part, nodes.Inline, nodes.FixedTextElement):
|
class desc_annotation(nodes.Part, nodes.Inline, nodes.FixedTextElement):
|
||||||
@ -210,7 +210,7 @@ class math(nodes.math):
|
|||||||
RemovedInSphinx30Warning, stacklevel=2)
|
RemovedInSphinx30Warning, stacklevel=2)
|
||||||
return self.astext()
|
return self.astext()
|
||||||
else:
|
else:
|
||||||
return super(math, self).__getitem__(key)
|
return super().__getitem__(key)
|
||||||
|
|
||||||
|
|
||||||
class math_block(nodes.math_block):
|
class math_block(nodes.math_block):
|
||||||
@ -229,7 +229,7 @@ class math_block(nodes.math_block):
|
|||||||
RemovedInSphinx30Warning, stacklevel=2)
|
RemovedInSphinx30Warning, stacklevel=2)
|
||||||
return self.astext()
|
return self.astext()
|
||||||
else:
|
else:
|
||||||
return super(math_block, self).__getitem__(key)
|
return super().__getitem__(key)
|
||||||
|
|
||||||
|
|
||||||
class displaymath(math_block):
|
class displaymath(math_block):
|
||||||
@ -354,7 +354,7 @@ class abbreviation(nodes.abbreviation):
|
|||||||
warnings.warn("abbrevition node for Sphinx was replaced by docutils'.",
|
warnings.warn("abbrevition node for Sphinx was replaced by docutils'.",
|
||||||
RemovedInSphinx40Warning, stacklevel=2)
|
RemovedInSphinx40Warning, stacklevel=2)
|
||||||
|
|
||||||
super(abbreviation, self).__init__(rawsource, text, *children, **attributes)
|
super().__init__(rawsource, text, *children, **attributes)
|
||||||
|
|
||||||
|
|
||||||
class manpage(nodes.Inline, nodes.FixedTextElement):
|
class manpage(nodes.Inline, nodes.FixedTextElement):
|
||||||
|
@ -151,7 +151,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
|||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
super(EpubBuilder, self).init()
|
super().init()
|
||||||
# the output files for epub must be .html only
|
# the output files for epub must be .html only
|
||||||
self.out_suffix = '.xhtml'
|
self.out_suffix = '.xhtml'
|
||||||
self.link_suffix = '.xhtml'
|
self.link_suffix = '.xhtml'
|
||||||
@ -373,7 +373,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
|||||||
"""
|
"""
|
||||||
self.fix_ids(doctree)
|
self.fix_ids(doctree)
|
||||||
self.add_visible_links(doctree, self.config.epub_show_urls)
|
self.add_visible_links(doctree, self.config.epub_show_urls)
|
||||||
super(EpubBuilder, self).write_doc(docname, doctree)
|
super().write_doc(docname, doctree)
|
||||||
|
|
||||||
def fix_genindex(self, tree):
|
def fix_genindex(self, tree):
|
||||||
# type: (List[Tuple[str, List[Tuple[str, Any]]]]) -> None
|
# type: (List[Tuple[str, List[Tuple[str, Any]]]]) -> None
|
||||||
@ -448,11 +448,11 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
|||||||
if self.config.epub_fix_images or self.config.epub_max_image_width:
|
if self.config.epub_fix_images or self.config.epub_max_image_width:
|
||||||
if not Image:
|
if not Image:
|
||||||
logger.warning(__('PIL not found - copying image files'))
|
logger.warning(__('PIL not found - copying image files'))
|
||||||
super(EpubBuilder, self).copy_image_files()
|
super().copy_image_files()
|
||||||
else:
|
else:
|
||||||
self.copy_image_files_pil()
|
self.copy_image_files_pil()
|
||||||
else:
|
else:
|
||||||
super(EpubBuilder, self).copy_image_files()
|
super().copy_image_files()
|
||||||
|
|
||||||
def copy_download_files(self):
|
def copy_download_files(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
@ -471,8 +471,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
|||||||
return
|
return
|
||||||
self.fix_genindex(addctx['genindexentries'])
|
self.fix_genindex(addctx['genindexentries'])
|
||||||
addctx['doctype'] = self.doctype
|
addctx['doctype'] = self.doctype
|
||||||
super(EpubBuilder, self).handle_page(pagename, addctx, templatename,
|
super().handle_page(pagename, addctx, templatename, outfilename, event_arg)
|
||||||
outfilename, event_arg)
|
|
||||||
|
|
||||||
def build_mimetype(self, outdir, outname):
|
def build_mimetype(self, outdir, outname):
|
||||||
# type: (str, str) -> None
|
# type: (str, str) -> None
|
||||||
|
@ -86,7 +86,7 @@ class AppleHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
super(AppleHelpBuilder, self).init()
|
super().init()
|
||||||
# the output files for HTML help must be .html only
|
# the output files for HTML help must be .html only
|
||||||
self.out_suffix = '.html'
|
self.out_suffix = '.html'
|
||||||
self.link_suffix = '.html'
|
self.link_suffix = '.html'
|
||||||
@ -105,7 +105,7 @@ class AppleHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
|
|
||||||
def handle_finish(self):
|
def handle_finish(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
super(AppleHelpBuilder, self).handle_finish()
|
super().handle_finish()
|
||||||
|
|
||||||
self.finish_tasks.add_task(self.copy_localized_files)
|
self.finish_tasks.add_task(self.copy_localized_files)
|
||||||
self.finish_tasks.add_task(self.build_helpbook)
|
self.finish_tasks.add_task(self.build_helpbook)
|
||||||
|
@ -62,7 +62,7 @@ class DevhelpBuilder(StandaloneHTMLBuilder):
|
|||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
super(DevhelpBuilder, self).init()
|
super().init()
|
||||||
self.out_suffix = '.html'
|
self.out_suffix = '.html'
|
||||||
self.link_suffix = '.html'
|
self.link_suffix = '.html'
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ class Epub3Builder(_epub_base.EpubBuilder):
|
|||||||
"""
|
"""
|
||||||
writing_mode = self.config.epub_writing_mode
|
writing_mode = self.config.epub_writing_mode
|
||||||
|
|
||||||
metadata = super(Epub3Builder, self).content_metadata()
|
metadata = super().content_metadata()
|
||||||
metadata['description'] = self.esc(self.config.epub_description)
|
metadata['description'] = self.esc(self.config.epub_description)
|
||||||
metadata['contributor'] = self.esc(self.config.epub_contributor)
|
metadata['contributor'] = self.esc(self.config.epub_contributor)
|
||||||
metadata['page_progression_direction'] = PAGE_PROGRESSION_DIRECTIONS.get(writing_mode)
|
metadata['page_progression_direction'] = PAGE_PROGRESSION_DIRECTIONS.get(writing_mode)
|
||||||
@ -141,7 +141,7 @@ class Epub3Builder(_epub_base.EpubBuilder):
|
|||||||
|
|
||||||
def prepare_writing(self, docnames):
|
def prepare_writing(self, docnames):
|
||||||
# type: (Set[str]) -> None
|
# type: (Set[str]) -> None
|
||||||
super(Epub3Builder, self).prepare_writing(docnames)
|
super().prepare_writing(docnames)
|
||||||
|
|
||||||
writing_mode = self.config.epub_writing_mode
|
writing_mode = self.config.epub_writing_mode
|
||||||
self.globalcontext['theme_writing_mode'] = THEME_WRITING_MODES.get(writing_mode)
|
self.globalcontext['theme_writing_mode'] = THEME_WRITING_MODES.get(writing_mode)
|
||||||
|
@ -119,7 +119,7 @@ class I18nBuilder(Builder):
|
|||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
super(I18nBuilder, self).init()
|
super().init()
|
||||||
self.env.set_versioning_method(self.versioning_method,
|
self.env.set_versioning_method(self.versioning_method,
|
||||||
self.env.config.gettext_uuid)
|
self.env.config.gettext_uuid)
|
||||||
self.tags = I18nTags()
|
self.tags = I18nTags()
|
||||||
@ -176,7 +176,7 @@ class LocalTimeZone(tzinfo):
|
|||||||
|
|
||||||
def __init__(self, *args, **kw):
|
def __init__(self, *args, **kw):
|
||||||
# type: (Any, Any) -> None
|
# type: (Any, Any) -> None
|
||||||
super(LocalTimeZone, self).__init__(*args, **kw) # type: ignore
|
super().__init__(*args, **kw) # type: ignore
|
||||||
self.tzdelta = tzdelta
|
self.tzdelta = tzdelta
|
||||||
|
|
||||||
def utcoffset(self, dt):
|
def utcoffset(self, dt):
|
||||||
@ -219,7 +219,7 @@ class MessageCatalogBuilder(I18nBuilder):
|
|||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
super(MessageCatalogBuilder, self).init()
|
super().init()
|
||||||
self.create_template_bridge()
|
self.create_template_bridge()
|
||||||
self.templates.init(self)
|
self.templates.init(self)
|
||||||
|
|
||||||
@ -258,11 +258,11 @@ class MessageCatalogBuilder(I18nBuilder):
|
|||||||
def build(self, docnames, summary=None, method='update'):
|
def build(self, docnames, summary=None, method='update'):
|
||||||
# type: (Iterable[str], str, str) -> None
|
# type: (Iterable[str], str, str) -> None
|
||||||
self._extract_from_template()
|
self._extract_from_template()
|
||||||
super(MessageCatalogBuilder, self).build(docnames, summary, method)
|
super().build(docnames, summary, method)
|
||||||
|
|
||||||
def finish(self):
|
def finish(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
super(MessageCatalogBuilder, self).finish()
|
super().finish()
|
||||||
data = {
|
data = {
|
||||||
'version': self.config.version,
|
'version': self.config.version,
|
||||||
'copyright': self.config.copyright,
|
'copyright': self.config.copyright,
|
||||||
|
@ -122,7 +122,7 @@ class JSContainer(list):
|
|||||||
warnings.warn('builder.script_files is deprecated. '
|
warnings.warn('builder.script_files is deprecated. '
|
||||||
'Please use app.add_js_file() instead.',
|
'Please use app.add_js_file() instead.',
|
||||||
RemovedInSphinx30Warning, stacklevel=2)
|
RemovedInSphinx30Warning, stacklevel=2)
|
||||||
super(JSContainer, self).insert(index, obj)
|
super().insert(index, obj)
|
||||||
|
|
||||||
def extend(self, other): # type: ignore
|
def extend(self, other): # type: ignore
|
||||||
# type: (List[str]) -> None
|
# type: (List[str]) -> None
|
||||||
@ -256,7 +256,7 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
# type: (Sphinx) -> None
|
# type: (Sphinx) -> None
|
||||||
super(StandaloneHTMLBuilder, self).__init__(app)
|
super().__init__(app)
|
||||||
|
|
||||||
# CSS files
|
# CSS files
|
||||||
self.css_files = [] # type: List[Dict[str, str]]
|
self.css_files = [] # type: List[Dict[str, str]]
|
||||||
@ -1211,7 +1211,7 @@ class DirectoryHTMLBuilder(StandaloneHTMLBuilder):
|
|||||||
|
|
||||||
def prepare_writing(self, docnames):
|
def prepare_writing(self, docnames):
|
||||||
# type: (Set[str]) -> None
|
# type: (Set[str]) -> None
|
||||||
super(DirectoryHTMLBuilder, self).prepare_writing(docnames)
|
super().prepare_writing(docnames)
|
||||||
self.globalcontext['no_search_suffix'] = True
|
self.globalcontext['no_search_suffix'] = True
|
||||||
|
|
||||||
|
|
||||||
@ -1474,7 +1474,7 @@ class SerializingHTMLBuilder(StandaloneHTMLBuilder):
|
|||||||
self.dump_context(self.globalcontext, outfilename)
|
self.dump_context(self.globalcontext, outfilename)
|
||||||
|
|
||||||
# super here to dump the search index
|
# super here to dump the search index
|
||||||
super(SerializingHTMLBuilder, self).handle_finish()
|
super().handle_finish()
|
||||||
|
|
||||||
# copy the environment file from the doctree dir to the output dir
|
# copy the environment file from the doctree dir to the output dir
|
||||||
# as needed by the web app
|
# as needed by the web app
|
||||||
|
@ -200,7 +200,7 @@ class HTMLHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
# the output files for HTML help is .html by default
|
# the output files for HTML help is .html by default
|
||||||
self.out_suffix = '.html'
|
self.out_suffix = '.html'
|
||||||
self.link_suffix = '.html'
|
self.link_suffix = '.html'
|
||||||
super(HTMLHelpBuilder, self).init()
|
super().init()
|
||||||
# determine the correct locale setting
|
# determine the correct locale setting
|
||||||
locale = chm_locales.get(self.config.language)
|
locale = chm_locales.get(self.config.language)
|
||||||
if locale is not None:
|
if locale is not None:
|
||||||
@ -227,7 +227,7 @@ class HTMLHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
if node.get('internal') is None and 'refuri' in node:
|
if node.get('internal') is None and 'refuri' in node:
|
||||||
node['target'] = '_blank'
|
node['target'] = '_blank'
|
||||||
|
|
||||||
super(HTMLHelpBuilder, self).write_doc(docname, doctree)
|
super().write_doc(docname, doctree)
|
||||||
|
|
||||||
def build_hhx(self, outdir, outname):
|
def build_hhx(self, outdir, outname):
|
||||||
# type: (str, str) -> None
|
# type: (str, str) -> None
|
||||||
|
@ -155,7 +155,7 @@ class FootnoteCollector(nodes.NodeVisitor):
|
|||||||
self.auto_footnotes = [] # type: List[nodes.footnote]
|
self.auto_footnotes = [] # type: List[nodes.footnote]
|
||||||
self.used_footnote_numbers = set() # type: Set[str]
|
self.used_footnote_numbers = set() # type: Set[str]
|
||||||
self.footnote_refs = [] # type: List[nodes.footnote_reference]
|
self.footnote_refs = [] # type: List[nodes.footnote_reference]
|
||||||
super(FootnoteCollector, self).__init__(document)
|
super().__init__(document)
|
||||||
|
|
||||||
def unknown_visit(self, node):
|
def unknown_visit(self, node):
|
||||||
# type: (nodes.Node) -> None
|
# type: (nodes.Node) -> None
|
||||||
@ -365,7 +365,7 @@ class LaTeXFootnoteVisitor(nodes.NodeVisitor):
|
|||||||
self.pendings = [] # type: List[nodes.footnote]
|
self.pendings = [] # type: List[nodes.footnote]
|
||||||
self.table_footnotes = [] # type: List[nodes.footnote]
|
self.table_footnotes = [] # type: List[nodes.footnote]
|
||||||
self.restricted = None # type: nodes.Element
|
self.restricted = None # type: nodes.Element
|
||||||
super(LaTeXFootnoteVisitor, self).__init__(document)
|
super().__init__(document)
|
||||||
|
|
||||||
def unknown_visit(self, node):
|
def unknown_visit(self, node):
|
||||||
# type: (nodes.Node) -> None
|
# type: (nodes.Node) -> None
|
||||||
|
@ -44,7 +44,7 @@ class AnchorCheckParser(HTMLParser):
|
|||||||
|
|
||||||
def __init__(self, search_anchor):
|
def __init__(self, search_anchor):
|
||||||
# type: (str) -> None
|
# type: (str) -> None
|
||||||
super(AnchorCheckParser, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.search_anchor = search_anchor
|
self.search_anchor = search_anchor
|
||||||
self.found = False
|
self.found = False
|
||||||
|
@ -80,7 +80,7 @@ class QtHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
super(QtHelpBuilder, self).init()
|
super().init()
|
||||||
# the output files for HTML help must be .html only
|
# the output files for HTML help must be .html only
|
||||||
self.out_suffix = '.html'
|
self.out_suffix = '.html'
|
||||||
self.link_suffix = '.html'
|
self.link_suffix = '.html'
|
||||||
|
@ -216,7 +216,7 @@ class QuickstartRenderer(SphinxRenderer):
|
|||||||
def __init__(self, templatedir):
|
def __init__(self, templatedir):
|
||||||
# type: (str) -> None
|
# type: (str) -> None
|
||||||
self.templatedir = templatedir or ''
|
self.templatedir = templatedir or ''
|
||||||
super(QuickstartRenderer, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
def render(self, template_name, context):
|
def render(self, template_name, context):
|
||||||
# type: (str, Dict) -> str
|
# type: (str, Dict) -> str
|
||||||
@ -224,7 +224,7 @@ class QuickstartRenderer(SphinxRenderer):
|
|||||||
if self.templatedir and path.exists(user_template):
|
if self.templatedir and path.exists(user_template):
|
||||||
return self.render_from_file(user_template, context)
|
return self.render_from_file(user_template, context)
|
||||||
else:
|
else:
|
||||||
return super(QuickstartRenderer, self).render(template_name, context)
|
return super().render(template_name, context)
|
||||||
|
|
||||||
|
|
||||||
def ask_user(d):
|
def ask_user(d):
|
||||||
|
@ -34,29 +34,29 @@ class DeprecatedDict(dict):
|
|||||||
# type: (Dict, str, Type[Warning]) -> None
|
# type: (Dict, str, Type[Warning]) -> None
|
||||||
self.message = message
|
self.message = message
|
||||||
self.warning = warning
|
self.warning = warning
|
||||||
super(DeprecatedDict, self).__init__(data)
|
super().__init__(data)
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
# type: (str, Any) -> None
|
# type: (str, Any) -> None
|
||||||
warnings.warn(self.message, self.warning, stacklevel=2)
|
warnings.warn(self.message, self.warning, stacklevel=2)
|
||||||
super(DeprecatedDict, self).__setitem__(key, value)
|
super().__setitem__(key, value)
|
||||||
|
|
||||||
def setdefault(self, key, default=None):
|
def setdefault(self, key, default=None):
|
||||||
# type: (str, Any) -> None
|
# type: (str, Any) -> None
|
||||||
warnings.warn(self.message, self.warning, stacklevel=2)
|
warnings.warn(self.message, self.warning, stacklevel=2)
|
||||||
return super(DeprecatedDict, self).setdefault(key, default)
|
return super().setdefault(key, default)
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
# type: (str) -> None
|
# type: (str) -> None
|
||||||
warnings.warn(self.message, self.warning, stacklevel=2)
|
warnings.warn(self.message, self.warning, stacklevel=2)
|
||||||
return super(DeprecatedDict, self).__getitem__(key)
|
return super().__getitem__(key)
|
||||||
|
|
||||||
def get(self, key, default=None):
|
def get(self, key, default=None):
|
||||||
# type: (str, Any) -> None
|
# type: (str, Any) -> None
|
||||||
warnings.warn(self.message, self.warning, stacklevel=2)
|
warnings.warn(self.message, self.warning, stacklevel=2)
|
||||||
return super(DeprecatedDict, self).get(key, default)
|
return super().get(key, default)
|
||||||
|
|
||||||
def update(self, other=None): # type: ignore
|
def update(self, other=None): # type: ignore
|
||||||
# type: (Dict) -> None
|
# type: (Dict) -> None
|
||||||
warnings.warn(self.message, self.warning, stacklevel=2)
|
warnings.warn(self.message, self.warning, stacklevel=2)
|
||||||
super(DeprecatedDict, self).update(other)
|
super().update(other)
|
||||||
|
@ -62,7 +62,7 @@ class HighlightLang(Highlight):
|
|||||||
warnings.warn('highlightlang directive is deprecated. '
|
warnings.warn('highlightlang directive is deprecated. '
|
||||||
'Please use highlight directive instead.',
|
'Please use highlight directive instead.',
|
||||||
RemovedInSphinx40Warning, stacklevel=2)
|
RemovedInSphinx40Warning, stacklevel=2)
|
||||||
return super(HighlightLang, self).run()
|
return super().run()
|
||||||
|
|
||||||
|
|
||||||
def dedent_lines(lines, dedent, location=None):
|
def dedent_lines(lines, dedent, location=None):
|
||||||
|
@ -387,11 +387,11 @@ class Include(BaseInclude, SphinxDirective):
|
|||||||
if self.arguments[0].startswith('<') and \
|
if self.arguments[0].startswith('<') and \
|
||||||
self.arguments[0].endswith('>'):
|
self.arguments[0].endswith('>'):
|
||||||
# docutils "standard" includes, do not do path processing
|
# docutils "standard" includes, do not do path processing
|
||||||
return super(Include, self).run()
|
return super().run()
|
||||||
rel_filename, filename = self.env.relfn2path(self.arguments[0])
|
rel_filename, filename = self.env.relfn2path(self.arguments[0])
|
||||||
self.arguments[0] = filename
|
self.arguments[0] = filename
|
||||||
self.env.note_included(filename)
|
self.env.note_included(filename)
|
||||||
return super(Include, self).run()
|
return super().run()
|
||||||
|
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
|
@ -32,7 +32,7 @@ class Figure(images.Figure):
|
|||||||
def run(self):
|
def run(self):
|
||||||
# type: () -> List[nodes.Node]
|
# type: () -> List[nodes.Node]
|
||||||
name = self.options.pop('name', None)
|
name = self.options.pop('name', None)
|
||||||
result = super(Figure, self).run()
|
result = super().run()
|
||||||
if len(result) == 2 or isinstance(result[0], nodes.system_message):
|
if len(result) == 2 or isinstance(result[0], nodes.system_message):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ class Figure(images.Figure):
|
|||||||
class Meta(html.Meta, SphinxDirective):
|
class Meta(html.Meta, SphinxDirective):
|
||||||
def run(self):
|
def run(self):
|
||||||
# type: () -> List[nodes.Node]
|
# type: () -> List[nodes.Node]
|
||||||
result = super(Meta, self).run()
|
result = super().run()
|
||||||
for node in result:
|
for node in result:
|
||||||
if (isinstance(node, nodes.pending) and
|
if (isinstance(node, nodes.pending) and
|
||||||
isinstance(node.details['nodes'][0], html.MetaBody.meta)):
|
isinstance(node.details['nodes'][0], html.MetaBody.meta)):
|
||||||
@ -76,7 +76,7 @@ class RSTTable(tables.RSTTable):
|
|||||||
|
|
||||||
def make_title(self):
|
def make_title(self):
|
||||||
# type: () -> Tuple[nodes.title, List[nodes.system_message]]
|
# type: () -> Tuple[nodes.title, List[nodes.system_message]]
|
||||||
title, message = super(RSTTable, self).make_title()
|
title, message = super().make_title()
|
||||||
if title:
|
if title:
|
||||||
set_source_info(self, title)
|
set_source_info(self, title)
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ class CSVTable(tables.CSVTable):
|
|||||||
|
|
||||||
def make_title(self):
|
def make_title(self):
|
||||||
# type: () -> Tuple[nodes.title, List[nodes.system_message]]
|
# type: () -> Tuple[nodes.title, List[nodes.system_message]]
|
||||||
title, message = super(CSVTable, self).make_title()
|
title, message = super().make_title()
|
||||||
if title:
|
if title:
|
||||||
set_source_info(self, title)
|
set_source_info(self, title)
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ class ListTable(tables.ListTable):
|
|||||||
|
|
||||||
def make_title(self):
|
def make_title(self):
|
||||||
# type: () -> Tuple[nodes.title, List[nodes.system_message]]
|
# type: () -> Tuple[nodes.title, List[nodes.system_message]]
|
||||||
title, message = super(ListTable, self).make_title()
|
title, message = super().make_title()
|
||||||
if title:
|
if title:
|
||||||
set_source_info(self, title)
|
set_source_info(self, title)
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ class Domain:
|
|||||||
def run(self):
|
def run(self):
|
||||||
# type: () -> List[nodes.Node]
|
# type: () -> List[nodes.Node]
|
||||||
self.name = fullname
|
self.name = fullname
|
||||||
return super(DirectiveAdapter, self).run()
|
return super().run()
|
||||||
self._directive_cache[name] = DirectiveAdapter
|
self._directive_cache[name] = DirectiveAdapter
|
||||||
return DirectiveAdapter
|
return DirectiveAdapter
|
||||||
|
|
||||||
|
@ -3736,7 +3736,7 @@ class Symbol:
|
|||||||
if key == "children":
|
if key == "children":
|
||||||
assert False
|
assert False
|
||||||
else:
|
else:
|
||||||
return super(Symbol, self).__setattr__(key, value)
|
return super().__setattr__(key, value)
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
parent, # type: Symbol
|
parent, # type: Symbol
|
||||||
@ -6432,7 +6432,7 @@ class CPPObject(ObjectDescription):
|
|||||||
symbol = parentSymbol.add_name(name)
|
symbol = parentSymbol.add_name(name)
|
||||||
env.temp_data['cpp:last_symbol'] = symbol
|
env.temp_data['cpp:last_symbol'] = symbol
|
||||||
return []
|
return []
|
||||||
return super(CPPObject, self).run()
|
return super().run()
|
||||||
|
|
||||||
def handle_signature(self, sig, signode):
|
def handle_signature(self, sig, signode):
|
||||||
# type: (str, addnodes.desc_signature) -> Any
|
# type: (str, addnodes.desc_signature) -> Any
|
||||||
|
@ -125,7 +125,7 @@ class PyXrefMixin:
|
|||||||
env=None, # type: BuildEnvironment
|
env=None, # type: BuildEnvironment
|
||||||
):
|
):
|
||||||
# type: (...) -> nodes.Node
|
# type: (...) -> nodes.Node
|
||||||
result = super(PyXrefMixin, self).make_xref(rolename, domain, target, # type: ignore
|
result = super().make_xref(rolename, domain, target, # type: ignore
|
||||||
innernode, contnode, env)
|
innernode, contnode, env)
|
||||||
result['refspecific'] = True
|
result['refspecific'] = True
|
||||||
if target.startswith(('.', '~')):
|
if target.startswith(('.', '~')):
|
||||||
@ -176,8 +176,7 @@ class PyField(PyXrefMixin, Field):
|
|||||||
# None is not a type, so use obj role instead.
|
# None is not a type, so use obj role instead.
|
||||||
rolename = 'obj'
|
rolename = 'obj'
|
||||||
|
|
||||||
return super(PyField, self).make_xref(rolename, domain, target,
|
return super().make_xref(rolename, domain, target, innernode, contnode, env)
|
||||||
innernode, contnode, env)
|
|
||||||
|
|
||||||
|
|
||||||
class PyGroupedField(PyXrefMixin, GroupedField):
|
class PyGroupedField(PyXrefMixin, GroupedField):
|
||||||
@ -192,8 +191,7 @@ class PyTypedField(PyXrefMixin, TypedField):
|
|||||||
# None is not a type, so use obj role instead.
|
# None is not a type, so use obj role instead.
|
||||||
rolename = 'obj'
|
rolename = 'obj'
|
||||||
|
|
||||||
return super(PyTypedField, self).make_xref(rolename, domain, target,
|
return super().make_xref(rolename, domain, target, innernode, contnode, env)
|
||||||
innernode, contnode, env)
|
|
||||||
|
|
||||||
|
|
||||||
class PyObject(ObjectDescription):
|
class PyObject(ObjectDescription):
|
||||||
@ -543,7 +541,7 @@ class PyDecoratorMixin:
|
|||||||
"""
|
"""
|
||||||
def handle_signature(self, sig, signode):
|
def handle_signature(self, sig, signode):
|
||||||
# type: (str, addnodes.desc_signature) -> Tuple[str, str]
|
# type: (str, addnodes.desc_signature) -> Tuple[str, str]
|
||||||
ret = super(PyDecoratorMixin, self).handle_signature(sig, signode) # type: ignore
|
ret = super().handle_signature(sig, signode) # type: ignore
|
||||||
signode.insert(0, addnodes.desc_addname('@', '@'))
|
signode.insert(0, addnodes.desc_addname('@', '@'))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -560,7 +558,7 @@ class PyDecoratorFunction(PyDecoratorMixin, PyModulelevel):
|
|||||||
# type: () -> List[nodes.Node]
|
# type: () -> List[nodes.Node]
|
||||||
# a decorator function is a function after all
|
# a decorator function is a function after all
|
||||||
self.name = 'py:function'
|
self.name = 'py:function'
|
||||||
return super(PyDecoratorFunction, self).run()
|
return super().run()
|
||||||
|
|
||||||
|
|
||||||
class PyDecoratorMethod(PyDecoratorMixin, PyClassmember):
|
class PyDecoratorMethod(PyDecoratorMixin, PyClassmember):
|
||||||
@ -570,7 +568,7 @@ class PyDecoratorMethod(PyDecoratorMixin, PyClassmember):
|
|||||||
def run(self):
|
def run(self):
|
||||||
# type: () -> List[nodes.Node]
|
# type: () -> List[nodes.Node]
|
||||||
self.name = 'py:method'
|
self.name = 'py:method'
|
||||||
return super(PyDecoratorMethod, self).run()
|
return super().run()
|
||||||
|
|
||||||
|
|
||||||
class PyModule(SphinxDirective):
|
class PyModule(SphinxDirective):
|
||||||
|
@ -529,7 +529,7 @@ class StandardDomain(Domain):
|
|||||||
|
|
||||||
def __init__(self, env):
|
def __init__(self, env):
|
||||||
# type: (BuildEnvironment) -> None
|
# type: (BuildEnvironment) -> None
|
||||||
super(StandardDomain, self).__init__(env)
|
super().__init__(env)
|
||||||
|
|
||||||
# set up enumerable nodes
|
# set up enumerable nodes
|
||||||
self.enumerable_nodes = copy(self.enumerable_nodes) # create a copy for this instance
|
self.enumerable_nodes = copy(self.enumerable_nodes) # create a copy for this instance
|
||||||
|
@ -54,7 +54,7 @@ class ExtensionError(SphinxError):
|
|||||||
|
|
||||||
def __init__(self, message, orig_exc=None):
|
def __init__(self, message, orig_exc=None):
|
||||||
# type: (str, Exception) -> None
|
# type: (str, Exception) -> None
|
||||||
super(ExtensionError, self).__init__(message)
|
super().__init__(message)
|
||||||
self.message = message
|
self.message = message
|
||||||
self.orig_exc = orig_exc
|
self.orig_exc = orig_exc
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ class ExtensionError(SphinxError):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
# type: () -> str
|
# type: () -> str
|
||||||
parent_str = super(ExtensionError, self).__str__()
|
parent_str = super().__str__()
|
||||||
if self.orig_exc:
|
if self.orig_exc:
|
||||||
return '%s (exception: %s)' % (parent_str, self.orig_exc)
|
return '%s (exception: %s)' % (parent_str, self.orig_exc)
|
||||||
return parent_str
|
return parent_str
|
||||||
|
@ -782,7 +782,7 @@ class ModuleDocumenter(Documenter):
|
|||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
# type: (Any) -> None
|
# type: (Any) -> None
|
||||||
super(ModuleDocumenter, self).__init__(*args)
|
super().__init__(*args)
|
||||||
merge_special_members_option(self.options)
|
merge_special_members_option(self.options)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -800,7 +800,7 @@ class ModuleDocumenter(Documenter):
|
|||||||
|
|
||||||
def parse_name(self):
|
def parse_name(self):
|
||||||
# type: () -> bool
|
# type: () -> bool
|
||||||
ret = super(ModuleDocumenter, self).parse_name()
|
ret = super().parse_name()
|
||||||
if self.args or self.retann:
|
if self.args or self.retann:
|
||||||
logger.warning(__('signature arguments or return annotation '
|
logger.warning(__('signature arguments or return annotation '
|
||||||
'given for automodule %s') % self.fullname,
|
'given for automodule %s') % self.fullname,
|
||||||
@ -962,7 +962,7 @@ class DocstringSignatureMixin:
|
|||||||
lines = getattr(self, '_new_docstrings', None)
|
lines = getattr(self, '_new_docstrings', None)
|
||||||
if lines is not None:
|
if lines is not None:
|
||||||
return lines
|
return lines
|
||||||
return super(DocstringSignatureMixin, self).get_doc(None, ignore) # type: ignore
|
return super().get_doc(None, ignore) # type: ignore
|
||||||
|
|
||||||
def format_signature(self):
|
def format_signature(self):
|
||||||
# type: () -> str
|
# type: () -> str
|
||||||
@ -972,7 +972,7 @@ class DocstringSignatureMixin:
|
|||||||
result = self._find_signature()
|
result = self._find_signature()
|
||||||
if result is not None:
|
if result is not None:
|
||||||
self.args, self.retann = result
|
self.args, self.retann = result
|
||||||
return super(DocstringSignatureMixin, self).format_signature() # type: ignore
|
return super().format_signature() # type: ignore
|
||||||
|
|
||||||
|
|
||||||
class DocstringStripSignatureMixin(DocstringSignatureMixin):
|
class DocstringStripSignatureMixin(DocstringSignatureMixin):
|
||||||
@ -991,7 +991,7 @@ class DocstringStripSignatureMixin(DocstringSignatureMixin):
|
|||||||
# DocstringSignatureMixin.format_signature.
|
# DocstringSignatureMixin.format_signature.
|
||||||
# Documenter.format_signature use self.args value to format.
|
# Documenter.format_signature use self.args value to format.
|
||||||
_args, self.retann = result
|
_args, self.retann = result
|
||||||
return super(DocstringStripSignatureMixin, self).format_signature()
|
return super().format_signature()
|
||||||
|
|
||||||
|
|
||||||
class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: ignore
|
class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: ignore
|
||||||
@ -1059,7 +1059,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
|
|||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
# type: (Any) -> None
|
# type: (Any) -> None
|
||||||
super(ClassDocumenter, self).__init__(*args)
|
super().__init__(*args)
|
||||||
merge_special_members_option(self.options)
|
merge_special_members_option(self.options)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -1069,7 +1069,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
|
|||||||
|
|
||||||
def import_object(self):
|
def import_object(self):
|
||||||
# type: () -> Any
|
# type: () -> Any
|
||||||
ret = super(ClassDocumenter, self).import_object()
|
ret = super().import_object()
|
||||||
# if the class is documented under another name, document it
|
# if the class is documented under another name, document it
|
||||||
# as data/attribute
|
# as data/attribute
|
||||||
if ret:
|
if ret:
|
||||||
@ -1101,13 +1101,13 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
|
|||||||
if self.doc_as_attr:
|
if self.doc_as_attr:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
return super(ClassDocumenter, self).format_signature()
|
return super().format_signature()
|
||||||
|
|
||||||
def add_directive_header(self, sig):
|
def add_directive_header(self, sig):
|
||||||
# type: (str) -> None
|
# type: (str) -> None
|
||||||
if self.doc_as_attr:
|
if self.doc_as_attr:
|
||||||
self.directivetype = 'attribute'
|
self.directivetype = 'attribute'
|
||||||
super(ClassDocumenter, self).add_directive_header(sig)
|
super().add_directive_header(sig)
|
||||||
|
|
||||||
# add inheritance info, if wanted
|
# add inheritance info, if wanted
|
||||||
if not self.doc_as_attr and self.options.show_inheritance:
|
if not self.doc_as_attr and self.options.show_inheritance:
|
||||||
@ -1176,15 +1176,15 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
|
|||||||
if module and module != parentmodule:
|
if module and module != parentmodule:
|
||||||
classname = str(module) + u'.' + str(classname)
|
classname = str(module) + u'.' + str(classname)
|
||||||
content = StringList([_('alias of :class:`%s`') % classname], source='')
|
content = StringList([_('alias of :class:`%s`') % classname], source='')
|
||||||
super(ClassDocumenter, self).add_content(content, no_docstring=True)
|
super().add_content(content, no_docstring=True)
|
||||||
else:
|
else:
|
||||||
super(ClassDocumenter, self).add_content(more_content)
|
super().add_content(more_content)
|
||||||
|
|
||||||
def document_members(self, all_members=False):
|
def document_members(self, all_members=False):
|
||||||
# type: (bool) -> None
|
# type: (bool) -> None
|
||||||
if self.doc_as_attr:
|
if self.doc_as_attr:
|
||||||
return
|
return
|
||||||
super(ClassDocumenter, self).document_members(all_members)
|
super().document_members(all_members)
|
||||||
|
|
||||||
def generate(self, more_content=None, real_modname=None,
|
def generate(self, more_content=None, real_modname=None,
|
||||||
check_module=False, all_members=False):
|
check_module=False, all_members=False):
|
||||||
@ -1194,7 +1194,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
|
|||||||
# If a class gets imported into the module real_modname
|
# If a class gets imported into the module real_modname
|
||||||
# the analyzer won't find the source of the class, if
|
# the analyzer won't find the source of the class, if
|
||||||
# it looks in real_modname.
|
# it looks in real_modname.
|
||||||
return super(ClassDocumenter, self).generate(more_content=more_content,
|
return super().generate(more_content=more_content,
|
||||||
check_module=check_module,
|
check_module=check_module,
|
||||||
all_members=all_members)
|
all_members=all_members)
|
||||||
|
|
||||||
@ -1232,7 +1232,7 @@ class DataDocumenter(ModuleLevelDocumenter):
|
|||||||
|
|
||||||
def add_directive_header(self, sig):
|
def add_directive_header(self, sig):
|
||||||
# type: (str) -> None
|
# type: (str) -> None
|
||||||
super(DataDocumenter, self).add_directive_header(sig)
|
super().add_directive_header(sig)
|
||||||
sourcename = self.get_sourcename()
|
sourcename = self.get_sourcename()
|
||||||
if not self.options.annotation:
|
if not self.options.annotation:
|
||||||
try:
|
try:
|
||||||
@ -1273,7 +1273,7 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type:
|
|||||||
|
|
||||||
def import_object(self):
|
def import_object(self):
|
||||||
# type: () -> Any
|
# type: () -> Any
|
||||||
ret = super(MethodDocumenter, self).import_object()
|
ret = super().import_object()
|
||||||
if not ret:
|
if not ret:
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -1351,7 +1351,7 @@ class AttributeDocumenter(DocstringStripSignatureMixin, ClassLevelDocumenter):
|
|||||||
|
|
||||||
def import_object(self):
|
def import_object(self):
|
||||||
# type: () -> Any
|
# type: () -> Any
|
||||||
ret = super(AttributeDocumenter, self).import_object()
|
ret = super().import_object()
|
||||||
if isenumattribute(self.object):
|
if isenumattribute(self.object):
|
||||||
self.object = self.object.value
|
self.object = self.object.value
|
||||||
if isdescriptor(self.object) and \
|
if isdescriptor(self.object) and \
|
||||||
@ -1369,7 +1369,7 @@ class AttributeDocumenter(DocstringStripSignatureMixin, ClassLevelDocumenter):
|
|||||||
|
|
||||||
def add_directive_header(self, sig):
|
def add_directive_header(self, sig):
|
||||||
# type: (str) -> None
|
# type: (str) -> None
|
||||||
super(AttributeDocumenter, self).add_directive_header(sig)
|
super().add_directive_header(sig)
|
||||||
sourcename = self.get_sourcename()
|
sourcename = self.get_sourcename()
|
||||||
if not self.options.annotation:
|
if not self.options.annotation:
|
||||||
if not self._datadescriptor:
|
if not self._datadescriptor:
|
||||||
@ -1391,7 +1391,7 @@ class AttributeDocumenter(DocstringStripSignatureMixin, ClassLevelDocumenter):
|
|||||||
# if it's not a data descriptor, its docstring is very probably the
|
# if it's not a data descriptor, its docstring is very probably the
|
||||||
# wrong thing to display
|
# wrong thing to display
|
||||||
no_docstring = True
|
no_docstring = True
|
||||||
super(AttributeDocumenter, self).add_content(more_content, no_docstring)
|
super().add_content(more_content, no_docstring)
|
||||||
|
|
||||||
|
|
||||||
class InstanceAttributeDocumenter(AttributeDocumenter):
|
class InstanceAttributeDocumenter(AttributeDocumenter):
|
||||||
@ -1423,7 +1423,7 @@ class InstanceAttributeDocumenter(AttributeDocumenter):
|
|||||||
def add_content(self, more_content, no_docstring=False):
|
def add_content(self, more_content, no_docstring=False):
|
||||||
# type: (Any, bool) -> None
|
# type: (Any, bool) -> None
|
||||||
"""Never try to get a docstring from the object."""
|
"""Never try to get a docstring from the object."""
|
||||||
super(InstanceAttributeDocumenter, self).add_content(more_content, no_docstring=True)
|
super().add_content(more_content, no_docstring=True)
|
||||||
|
|
||||||
|
|
||||||
def get_documenters(app):
|
def get_documenters(app):
|
||||||
|
@ -83,7 +83,7 @@ class _MockModule(ModuleType):
|
|||||||
|
|
||||||
def __init__(self, name, loader=None):
|
def __init__(self, name, loader=None):
|
||||||
# type: (str, _MockImporter) -> None
|
# type: (str, _MockImporter) -> None
|
||||||
super(_MockModule, self).__init__(name)
|
super().__init__(name)
|
||||||
self.__all__ = [] # type: List[str]
|
self.__all__ = [] # type: List[str]
|
||||||
self.__path__ = [] # type: List[str]
|
self.__path__ = [] # type: List[str]
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ class MockLoader(Loader):
|
|||||||
"""A loader for mocking."""
|
"""A loader for mocking."""
|
||||||
def __init__(self, finder):
|
def __init__(self, finder):
|
||||||
# type: (MockFinder) -> None
|
# type: (MockFinder) -> None
|
||||||
super(MockLoader, self).__init__()
|
super().__init__()
|
||||||
self.finder = finder
|
self.finder = finder
|
||||||
|
|
||||||
def create_module(self, spec):
|
def create_module(self, spec):
|
||||||
@ -163,7 +163,7 @@ class MockFinder(MetaPathFinder):
|
|||||||
|
|
||||||
def __init__(self, modnames):
|
def __init__(self, modnames):
|
||||||
# type: (List[str]) -> None
|
# type: (List[str]) -> None
|
||||||
super(MockFinder, self).__init__()
|
super().__init__()
|
||||||
self.modnames = modnames
|
self.modnames = modnames
|
||||||
self.loader = MockLoader(self)
|
self.loader = MockLoader(self)
|
||||||
self.mocked_modules = [] # type: List[str]
|
self.mocked_modules = [] # type: List[str]
|
||||||
|
@ -177,7 +177,7 @@ _app = None # type: Sphinx
|
|||||||
class FakeDirective(DocumenterBridge):
|
class FakeDirective(DocumenterBridge):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
super(FakeDirective, self).__init__({}, None, Options(), 0) # type: ignore
|
super().__init__({}, None, Options(), 0) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
def get_documenter(app, obj, parent):
|
def get_documenter(app, obj, parent):
|
||||||
|
@ -259,7 +259,7 @@ class SphinxDocTestRunner(doctest.DocTestRunner):
|
|||||||
old_stdout = sys.stdout
|
old_stdout = sys.stdout
|
||||||
sys.stdout = string_io
|
sys.stdout = string_io
|
||||||
try:
|
try:
|
||||||
res = super(SphinxDocTestRunner, self).summarize(verbose)
|
res = super().summarize(verbose)
|
||||||
finally:
|
finally:
|
||||||
sys.stdout = old_stdout
|
sys.stdout = old_stdout
|
||||||
out(string_io.getvalue())
|
out(string_io.getvalue())
|
||||||
|
@ -50,7 +50,7 @@ class MathExtError(SphinxError):
|
|||||||
msg += '\n[stderr]\n' + stderr.decode(sys_encoding, 'replace')
|
msg += '\n[stderr]\n' + stderr.decode(sys_encoding, 'replace')
|
||||||
if stdout:
|
if stdout:
|
||||||
msg += '\n[stdout]\n' + stdout.decode(sys_encoding, 'replace')
|
msg += '\n[stdout]\n' + stdout.decode(sys_encoding, 'replace')
|
||||||
super(MathExtError, self).__init__(msg)
|
super().__init__(msg)
|
||||||
|
|
||||||
|
|
||||||
class InvokeError(SphinxError):
|
class InvokeError(SphinxError):
|
||||||
|
@ -33,7 +33,7 @@ class MathDirective(MathDirectiveBase):
|
|||||||
warnings.warn('sphinx.ext.mathbase.MathDirective is moved to '
|
warnings.warn('sphinx.ext.mathbase.MathDirective is moved to '
|
||||||
'sphinx.directives.patches package.',
|
'sphinx.directives.patches package.',
|
||||||
RemovedInSphinx30Warning, stacklevel=2)
|
RemovedInSphinx30Warning, stacklevel=2)
|
||||||
return super(MathDirective, self).run()
|
return super().run()
|
||||||
|
|
||||||
|
|
||||||
def math_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
|
def math_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
|
||||||
|
@ -913,8 +913,7 @@ class NumpyDocstring(GoogleDocstring):
|
|||||||
obj=None, options=None):
|
obj=None, options=None):
|
||||||
# type: (Union[str, List[str]], SphinxConfig, Sphinx, str, str, Any, Any) -> None
|
# type: (Union[str, List[str]], SphinxConfig, Sphinx, str, str, Any, Any) -> None
|
||||||
self._directive_sections = ['.. index::']
|
self._directive_sections = ['.. index::']
|
||||||
super(NumpyDocstring, self).__init__(docstring, config, app, what,
|
super().__init__(docstring, config, app, what, name, obj, options)
|
||||||
name, obj, options)
|
|
||||||
|
|
||||||
def _consume_field(self, parse_type=True, prefer_type=False):
|
def _consume_field(self, parse_type=True, prefer_type=False):
|
||||||
# type: (bool, bool) -> Tuple[str, str, List[str]]
|
# type: (bool, bool) -> Tuple[str, str, List[str]]
|
||||||
|
@ -232,7 +232,7 @@ class modify_iter(peek_iter):
|
|||||||
if not callable(self.modifier):
|
if not callable(self.modifier):
|
||||||
raise TypeError('modify_iter(o, modifier): '
|
raise TypeError('modify_iter(o, modifier): '
|
||||||
'modifier must be callable')
|
'modifier must be callable')
|
||||||
super(modify_iter, self).__init__(*args)
|
super().__init__(*args)
|
||||||
|
|
||||||
def _fillcache(self, n):
|
def _fillcache(self, n):
|
||||||
# type: (int) -> None
|
# type: (int) -> None
|
||||||
|
@ -64,7 +64,7 @@ class Todo(BaseAdmonition, SphinxDirective):
|
|||||||
if not self.options.get('class'):
|
if not self.options.get('class'):
|
||||||
self.options['class'] = ['admonition-todo']
|
self.options['class'] = ['admonition-todo']
|
||||||
|
|
||||||
(todo,) = super(Todo, self).run() # type: Tuple[nodes.Node]
|
(todo,) = super().run() # type: Tuple[nodes.Node]
|
||||||
if isinstance(todo, nodes.system_message):
|
if isinstance(todo, nodes.system_message):
|
||||||
return [todo]
|
return [todo]
|
||||||
elif isinstance(todo, todo_node):
|
elif isinstance(todo, todo_node):
|
||||||
|
14
sphinx/io.py
14
sphinx/io.py
@ -65,18 +65,18 @@ class SphinxBaseReader(standalone.Reader):
|
|||||||
def __init__(self, app, *args, **kwargs):
|
def __init__(self, app, *args, **kwargs):
|
||||||
# type: (Sphinx, Any, Any) -> None
|
# type: (Sphinx, Any, Any) -> None
|
||||||
self.env = app.env
|
self.env = app.env
|
||||||
super(SphinxBaseReader, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def get_transforms(self):
|
def get_transforms(self):
|
||||||
# type: () -> List[Type[Transform]]
|
# type: () -> List[Type[Transform]]
|
||||||
return super(SphinxBaseReader, self).get_transforms() + self.transforms
|
return super().get_transforms() + self.transforms
|
||||||
|
|
||||||
def new_document(self):
|
def new_document(self):
|
||||||
# type: () -> nodes.document
|
# type: () -> nodes.document
|
||||||
"""Creates a new document object which having a special reporter object good
|
"""Creates a new document object which having a special reporter object good
|
||||||
for logging.
|
for logging.
|
||||||
"""
|
"""
|
||||||
document = super(SphinxBaseReader, self).new_document()
|
document = super().new_document()
|
||||||
|
|
||||||
# substitute transformer
|
# substitute transformer
|
||||||
document.transformer = SphinxTransformer(document)
|
document.transformer = SphinxTransformer(document)
|
||||||
@ -104,7 +104,7 @@ class SphinxStandaloneReader(SphinxBaseReader):
|
|||||||
def __init__(self, app, *args, **kwargs):
|
def __init__(self, app, *args, **kwargs):
|
||||||
# type: (Sphinx, Any, Any) -> None
|
# type: (Sphinx, Any, Any) -> None
|
||||||
self.transforms = self.transforms + app.registry.get_transforms()
|
self.transforms = self.transforms + app.registry.get_transforms()
|
||||||
super(SphinxStandaloneReader, self).__init__(app, *args, **kwargs)
|
super().__init__(app, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class SphinxI18nReader(SphinxBaseReader):
|
class SphinxI18nReader(SphinxBaseReader):
|
||||||
@ -166,7 +166,7 @@ class SphinxBaseFileInput(FileInput):
|
|||||||
self.env = env
|
self.env = env
|
||||||
|
|
||||||
kwds['error_handler'] = 'sphinx' # py3: handle error on open.
|
kwds['error_handler'] = 'sphinx' # py3: handle error on open.
|
||||||
super(SphinxBaseFileInput, self).__init__(*args, **kwds)
|
super().__init__(*args, **kwds)
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
# type: () -> str
|
# type: () -> str
|
||||||
@ -174,7 +174,7 @@ class SphinxBaseFileInput(FileInput):
|
|||||||
|
|
||||||
After reading, it emits Sphinx event ``source-read``.
|
After reading, it emits Sphinx event ``source-read``.
|
||||||
"""
|
"""
|
||||||
data = super(SphinxBaseFileInput, self).read()
|
data = super().read()
|
||||||
|
|
||||||
# emit source-read event
|
# emit source-read event
|
||||||
arg = [data]
|
arg = [data]
|
||||||
@ -237,7 +237,7 @@ class SphinxRSTFileInput(SphinxBaseFileInput):
|
|||||||
warnings.warn('SphinxRSTFileInput is deprecated.',
|
warnings.warn('SphinxRSTFileInput is deprecated.',
|
||||||
RemovedInSphinx30Warning, stacklevel=2)
|
RemovedInSphinx30Warning, stacklevel=2)
|
||||||
|
|
||||||
inputstring = super(SphinxRSTFileInput, self).read()
|
inputstring = super().read()
|
||||||
lines = string2lines(inputstring, convert_whitespace=True)
|
lines = string2lines(inputstring, convert_whitespace=True)
|
||||||
content = StringList()
|
content = StringList()
|
||||||
for lineno, line in enumerate(lines):
|
for lineno, line in enumerate(lines):
|
||||||
|
@ -29,7 +29,7 @@ class Make(make_mode.Make):
|
|||||||
warnings.warn('sphinx.make_mode.Make is deprecated. '
|
warnings.warn('sphinx.make_mode.Make is deprecated. '
|
||||||
'Please use sphinx.cmd.make_mode.Make instead.',
|
'Please use sphinx.cmd.make_mode.Make instead.',
|
||||||
RemovedInSphinx30Warning, stacklevel=2)
|
RemovedInSphinx30Warning, stacklevel=2)
|
||||||
super(Make, self).__init__(*args)
|
super().__init__(*args)
|
||||||
|
|
||||||
|
|
||||||
def run_make_mode(args):
|
def run_make_mode(args):
|
||||||
|
@ -68,7 +68,7 @@ class RSTParser(docutils.parsers.rst.Parser, Parser):
|
|||||||
|
|
||||||
refs: sphinx.io.SphinxStandaloneReader
|
refs: sphinx.io.SphinxStandaloneReader
|
||||||
"""
|
"""
|
||||||
transforms = super(RSTParser, self).get_transforms()
|
transforms = super().get_transforms()
|
||||||
transforms.remove(SmartQuotes)
|
transforms.remove(SmartQuotes)
|
||||||
return transforms
|
return transforms
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ class AfterCommentParser(TokenProcessor):
|
|||||||
|
|
||||||
def __init__(self, lines):
|
def __init__(self, lines):
|
||||||
# type: (List[str]) -> None
|
# type: (List[str]) -> None
|
||||||
super(AfterCommentParser, self).__init__(lines)
|
super().__init__(lines)
|
||||||
self.comment = None # type: str
|
self.comment = None # type: str
|
||||||
|
|
||||||
def fetch_rvalue(self):
|
def fetch_rvalue(self):
|
||||||
@ -249,7 +249,7 @@ class VariableCommentPicker(ast.NodeVisitor):
|
|||||||
self.comments = {} # type: Dict[Tuple[str, str], str]
|
self.comments = {} # type: Dict[Tuple[str, str], str]
|
||||||
self.previous = None # type: ast.AST
|
self.previous = None # type: ast.AST
|
||||||
self.deforders = {} # type: Dict[str, int]
|
self.deforders = {} # type: Dict[str, int]
|
||||||
super(VariableCommentPicker, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
def add_entry(self, name):
|
def add_entry(self, name):
|
||||||
# type: (str) -> None
|
# type: (str) -> None
|
||||||
@ -293,7 +293,7 @@ class VariableCommentPicker(ast.NodeVisitor):
|
|||||||
def visit(self, node):
|
def visit(self, node):
|
||||||
# type: (ast.AST) -> None
|
# type: (ast.AST) -> None
|
||||||
"""Updates self.previous to ."""
|
"""Updates self.previous to ."""
|
||||||
super(VariableCommentPicker, self).visit(node)
|
super().visit(node)
|
||||||
self.previous = node
|
self.previous = node
|
||||||
|
|
||||||
def visit_Assign(self, node):
|
def visit_Assign(self, node):
|
||||||
@ -388,7 +388,7 @@ class VariableCommentPicker(ast.NodeVisitor):
|
|||||||
class DefinitionFinder(TokenProcessor):
|
class DefinitionFinder(TokenProcessor):
|
||||||
def __init__(self, lines):
|
def __init__(self, lines):
|
||||||
# type: (List[str]) -> None
|
# type: (List[str]) -> None
|
||||||
super(DefinitionFinder, self).__init__(lines)
|
super().__init__(lines)
|
||||||
self.decorator = None # type: Token
|
self.decorator = None # type: Token
|
||||||
self.context = [] # type: List[str]
|
self.context = [] # type: List[str]
|
||||||
self.indents = [] # type: List
|
self.indents = [] # type: List
|
||||||
|
@ -171,8 +171,7 @@ class XRefRole:
|
|||||||
class AnyXRefRole(XRefRole):
|
class AnyXRefRole(XRefRole):
|
||||||
def process_link(self, env, refnode, has_explicit_title, title, target):
|
def process_link(self, env, refnode, has_explicit_title, title, target):
|
||||||
# type: (BuildEnvironment, nodes.Element, bool, str, str) -> Tuple[str, str]
|
# type: (BuildEnvironment, nodes.Element, bool, str, str) -> Tuple[str, str]
|
||||||
result = super(AnyXRefRole, self).process_link(env, refnode, has_explicit_title,
|
result = super().process_link(env, refnode, has_explicit_title, title, target)
|
||||||
title, target)
|
|
||||||
# add all possible context info (i.e. std:program, py:module etc.)
|
# add all possible context info (i.e. std:program, py:module etc.)
|
||||||
refnode.attributes.update(env.ref_context)
|
refnode.attributes.update(env.ref_context)
|
||||||
return result
|
return result
|
||||||
|
@ -198,7 +198,7 @@ class WordCollector(nodes.NodeVisitor):
|
|||||||
|
|
||||||
def __init__(self, document, lang):
|
def __init__(self, document, lang):
|
||||||
# type: (nodes.document, SearchLanguage) -> None
|
# type: (nodes.document, SearchLanguage) -> None
|
||||||
super(WordCollector, self).__init__(document)
|
super().__init__(document)
|
||||||
self.found_words = [] # type: List[str]
|
self.found_words = [] # type: List[str]
|
||||||
self.found_title_words = [] # type: List[str]
|
self.found_title_words = [] # type: List[str]
|
||||||
self.lang = lang
|
self.lang = lang
|
||||||
|
@ -64,7 +64,7 @@ class BaseSplitter:
|
|||||||
class MecabSplitter(BaseSplitter):
|
class MecabSplitter(BaseSplitter):
|
||||||
def __init__(self, options):
|
def __init__(self, options):
|
||||||
# type: (Dict) -> None
|
# type: (Dict) -> None
|
||||||
super(MecabSplitter, self).__init__(options)
|
super().__init__(options)
|
||||||
self.ctypes_libmecab = None # type: Any
|
self.ctypes_libmecab = None # type: Any
|
||||||
self.ctypes_mecab = None # type: Any
|
self.ctypes_mecab = None # type: Any
|
||||||
if not native_module:
|
if not native_module:
|
||||||
@ -138,7 +138,7 @@ MeCabBinder = MecabSplitter # keep backward compatibility until Sphinx-1.6
|
|||||||
class JanomeSplitter(BaseSplitter):
|
class JanomeSplitter(BaseSplitter):
|
||||||
def __init__(self, options):
|
def __init__(self, options):
|
||||||
# type: (Dict) -> None
|
# type: (Dict) -> None
|
||||||
super(JanomeSplitter, self).__init__(options)
|
super().__init__(options)
|
||||||
self.user_dict = options.get('user_dic')
|
self.user_dict = options.get('user_dic')
|
||||||
self.user_dict_enc = options.get('user_dic_enc', 'utf8')
|
self.user_dict_enc = options.get('user_dic_enc', 'utf8')
|
||||||
self.init_tokenizer()
|
self.init_tokenizer()
|
||||||
|
@ -139,7 +139,7 @@ class SphinxTestApp(application.Sphinx):
|
|||||||
if v.startswith('visit_'))
|
if v.startswith('visit_'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
super(SphinxTestApp, self).__init__(srcdir, confdir, outdir, doctreedir,
|
super().__init__(srcdir, confdir, outdir, doctreedir,
|
||||||
buildername, confoverrides, status, warning,
|
buildername, confoverrides, status, warning,
|
||||||
freshenv, warningiserror, tags)
|
freshenv, warningiserror, tags)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -88,7 +88,7 @@ class SphinxTransformer(Transformer):
|
|||||||
if not hasattr(self.document.settings, 'env') and self.env:
|
if not hasattr(self.document.settings, 'env') and self.env:
|
||||||
self.document.settings.env = self.env
|
self.document.settings.env = self.env
|
||||||
|
|
||||||
super(SphinxTransformer, self).apply_transforms()
|
super().apply_transforms()
|
||||||
else:
|
else:
|
||||||
# wrap the target node by document node during transforming
|
# wrap the target node by document node during transforming
|
||||||
try:
|
try:
|
||||||
@ -97,7 +97,7 @@ class SphinxTransformer(Transformer):
|
|||||||
document.settings.env = self.env
|
document.settings.env = self.env
|
||||||
document += self.document
|
document += self.document
|
||||||
self.document = document
|
self.document = document
|
||||||
super(SphinxTransformer, self).apply_transforms()
|
super().apply_transforms()
|
||||||
finally:
|
finally:
|
||||||
self.document = self.document[0]
|
self.document = self.document[0]
|
||||||
|
|
||||||
@ -355,7 +355,7 @@ class SphinxSmartQuotes(SmartQuotes, SphinxTransform):
|
|||||||
# override default settings with :confval:`smartquotes_action`
|
# override default settings with :confval:`smartquotes_action`
|
||||||
self.smartquotes_action = self.config.smartquotes_action
|
self.smartquotes_action = self.config.smartquotes_action
|
||||||
|
|
||||||
super(SphinxSmartQuotes, self).apply()
|
super().apply()
|
||||||
|
|
||||||
def is_available(self):
|
def is_available(self):
|
||||||
# type: () -> bool
|
# type: () -> bool
|
||||||
|
@ -55,7 +55,7 @@ class HighlightLanguageVisitor(nodes.NodeVisitor):
|
|||||||
# type: (nodes.document, str) -> None
|
# type: (nodes.document, str) -> None
|
||||||
self.default_setting = HighlightSetting(default_language, sys.maxsize)
|
self.default_setting = HighlightSetting(default_language, sys.maxsize)
|
||||||
self.settings = [] # type: List[HighlightSetting]
|
self.settings = [] # type: List[HighlightSetting]
|
||||||
super(HighlightLanguageVisitor, self).__init__(document)
|
super().__init__(document)
|
||||||
|
|
||||||
def unknown_visit(self, node):
|
def unknown_visit(self, node):
|
||||||
# type: (nodes.Node) -> None
|
# type: (nodes.Node) -> None
|
||||||
|
@ -203,7 +203,7 @@ class ImageConverter(BaseImageConverter):
|
|||||||
self.available = None # type: bool
|
self.available = None # type: bool
|
||||||
# the converter is available or not.
|
# the converter is available or not.
|
||||||
# Will be checked at first conversion
|
# Will be checked at first conversion
|
||||||
super(ImageConverter, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def match(self, node):
|
def match(self, node):
|
||||||
# type: (nodes.image) -> bool
|
# type: (nodes.image) -> bool
|
||||||
|
@ -496,7 +496,7 @@ def force_decode(string, encoding):
|
|||||||
|
|
||||||
class attrdict(dict):
|
class attrdict(dict):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(attrdict, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
warnings.warn('The attrdict class is deprecated.',
|
warnings.warn('The attrdict class is deprecated.',
|
||||||
RemovedInSphinx40Warning, stacklevel=2)
|
RemovedInSphinx40Warning, stacklevel=2)
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ class GroupedField(Field):
|
|||||||
def __init__(self, name, names=(), label=None, rolename=None,
|
def __init__(self, name, names=(), label=None, rolename=None,
|
||||||
can_collapse=False):
|
can_collapse=False):
|
||||||
# type: (str, Tuple[str, ...], str, str, bool) -> None
|
# type: (str, Tuple[str, ...], str, str, bool) -> None
|
||||||
super(GroupedField, self).__init__(name, names, label, True, rolename)
|
super().__init__(name, names, label, True, rolename)
|
||||||
self.can_collapse = can_collapse
|
self.can_collapse = can_collapse
|
||||||
|
|
||||||
def make_field(self,
|
def make_field(self,
|
||||||
@ -194,7 +194,7 @@ class TypedField(GroupedField):
|
|||||||
def __init__(self, name, names=(), typenames=(), label=None,
|
def __init__(self, name, names=(), typenames=(), label=None,
|
||||||
rolename=None, typerolename=None, can_collapse=False):
|
rolename=None, typerolename=None, can_collapse=False):
|
||||||
# type: (str, Tuple[str, ...], Tuple[str, ...], str, str, str, bool) -> None
|
# type: (str, Tuple[str, ...], Tuple[str, ...], str, str, str, bool) -> None
|
||||||
super(TypedField, self).__init__(name, names, label, rolename, can_collapse)
|
super().__init__(name, names, label, rolename, can_collapse)
|
||||||
self.typenames = typenames
|
self.typenames = typenames
|
||||||
self.typerolename = typerolename
|
self.typerolename = typerolename
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ class LoggingReporter(Reporter):
|
|||||||
error_handler='backslashreplace'):
|
error_handler='backslashreplace'):
|
||||||
# type: (str, int, int, bool, str) -> None
|
# type: (str, int, int, bool, str) -> None
|
||||||
stream = cast(IO, WarningStream())
|
stream = cast(IO, WarningStream())
|
||||||
super(LoggingReporter, self).__init__(source, report_level, halt_level,
|
super().__init__(source, report_level, halt_level,
|
||||||
stream, debug, error_handler=error_handler)
|
stream, debug, error_handler=error_handler)
|
||||||
|
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ class NullReporter(Reporter):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
super(NullReporter, self).__init__('', 999, 4)
|
super().__init__('', 999, 4)
|
||||||
|
|
||||||
|
|
||||||
def is_html5_writer_available():
|
def is_html5_writer_available():
|
||||||
@ -349,7 +349,7 @@ class SphinxFileOutput(FileOutput):
|
|||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
# type: (Any) -> None
|
# type: (Any) -> None
|
||||||
self.overwrite_if_changed = kwargs.pop('overwrite_if_changed', False)
|
self.overwrite_if_changed = kwargs.pop('overwrite_if_changed', False)
|
||||||
super(SphinxFileOutput, self).__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
def write(self, data):
|
def write(self, data):
|
||||||
# type: (str) -> str
|
# type: (str) -> str
|
||||||
@ -360,7 +360,7 @@ class SphinxFileOutput(FileOutput):
|
|||||||
if f.read() == data:
|
if f.read() == data:
|
||||||
return data
|
return data
|
||||||
|
|
||||||
return super(SphinxFileOutput, self).write(data)
|
return super().write(data)
|
||||||
|
|
||||||
|
|
||||||
class SphinxDirective(Directive):
|
class SphinxDirective(Directive):
|
||||||
@ -396,7 +396,7 @@ class SphinxTranslator(nodes.NodeVisitor):
|
|||||||
|
|
||||||
def __init__(self, builder, document):
|
def __init__(self, builder, document):
|
||||||
# type: (Builder, nodes.document) -> None
|
# type: (Builder, nodes.document) -> None
|
||||||
super(SphinxTranslator, self).__init__(document)
|
super().__init__(document)
|
||||||
self.builder = builder
|
self.builder = builder
|
||||||
self.config = builder.config
|
self.config = builder.config
|
||||||
self.settings = document.settings
|
self.settings = document.settings
|
||||||
|
@ -25,7 +25,7 @@ class SphinxJSONEncoder(json.JSONEncoder):
|
|||||||
# type: (Any) -> str
|
# type: (Any) -> str
|
||||||
if isinstance(obj, UserString):
|
if isinstance(obj, UserString):
|
||||||
return text_type(obj)
|
return text_type(obj)
|
||||||
return super(SphinxJSONEncoder, self).default(obj)
|
return super().default(obj)
|
||||||
|
|
||||||
|
|
||||||
def dump(obj, fp, *args, **kwds):
|
def dump(obj, fp, *args, **kwds):
|
||||||
|
@ -100,7 +100,7 @@ class SphinxLogRecord(logging.LogRecord):
|
|||||||
|
|
||||||
def getMessage(self):
|
def getMessage(self):
|
||||||
# type: () -> str
|
# type: () -> str
|
||||||
message = super(SphinxLogRecord, self).getMessage()
|
message = super().getMessage()
|
||||||
location = getattr(self, 'location', None)
|
location = getattr(self, 'location', None)
|
||||||
if location:
|
if location:
|
||||||
message = '%s: %s%s' % (location, self.prefix, message)
|
message = '%s: %s%s' % (location, self.prefix, message)
|
||||||
@ -126,10 +126,10 @@ class SphinxLoggerAdapter(logging.LoggerAdapter):
|
|||||||
def log(self, level, msg, *args, **kwargs): # type: ignore
|
def log(self, level, msg, *args, **kwargs): # type: ignore
|
||||||
# type: (Union[int, str], str, Any, Any) -> None
|
# type: (Union[int, str], str, Any, Any) -> None
|
||||||
if isinstance(level, int):
|
if isinstance(level, int):
|
||||||
super(SphinxLoggerAdapter, self).log(level, msg, *args, **kwargs)
|
super().log(level, msg, *args, **kwargs)
|
||||||
else:
|
else:
|
||||||
levelno = LEVEL_NAMES[level]
|
levelno = LEVEL_NAMES[level]
|
||||||
super(SphinxLoggerAdapter, self).log(levelno, msg, *args, **kwargs)
|
super().log(levelno, msg, *args, **kwargs)
|
||||||
|
|
||||||
def verbose(self, msg, *args, **kwargs):
|
def verbose(self, msg, *args, **kwargs):
|
||||||
# type: (str, Any, Any) -> None
|
# type: (str, Any, Any) -> None
|
||||||
@ -171,7 +171,7 @@ class NewLineStreamHandler(logging.StreamHandler):
|
|||||||
if getattr(record, 'nonl', False):
|
if getattr(record, 'nonl', False):
|
||||||
# skip appending terminator when nonl=True
|
# skip appending terminator when nonl=True
|
||||||
self.terminator = ''
|
self.terminator = ''
|
||||||
super(NewLineStreamHandler, self).emit(record)
|
super().emit(record)
|
||||||
finally:
|
finally:
|
||||||
self.terminator = '\n'
|
self.terminator = '\n'
|
||||||
self.release()
|
self.release()
|
||||||
@ -182,7 +182,7 @@ class MemoryHandler(logging.handlers.BufferingHandler):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
super(MemoryHandler, self).__init__(-1)
|
super().__init__(-1)
|
||||||
|
|
||||||
def shouldFlush(self, record):
|
def shouldFlush(self, record):
|
||||||
# type: (logging.LogRecord) -> bool
|
# type: (logging.LogRecord) -> bool
|
||||||
@ -385,7 +385,7 @@ class WarningSuppressor(logging.Filter):
|
|||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
# type: (Sphinx) -> None
|
# type: (Sphinx) -> None
|
||||||
self.app = app
|
self.app = app
|
||||||
super(WarningSuppressor, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
def filter(self, record):
|
def filter(self, record):
|
||||||
# type: (logging.LogRecord) -> bool
|
# type: (logging.LogRecord) -> bool
|
||||||
@ -411,7 +411,7 @@ class WarningIsErrorFilter(logging.Filter):
|
|||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
# type: (Sphinx) -> None
|
# type: (Sphinx) -> None
|
||||||
self.app = app
|
self.app = app
|
||||||
super(WarningIsErrorFilter, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
def filter(self, record):
|
def filter(self, record):
|
||||||
# type: (logging.LogRecord) -> bool
|
# type: (logging.LogRecord) -> bool
|
||||||
@ -448,7 +448,7 @@ class MessagePrefixFilter(logging.Filter):
|
|||||||
def __init__(self, prefix):
|
def __init__(self, prefix):
|
||||||
# type: (str) -> None
|
# type: (str) -> None
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
super(MessagePrefixFilter, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
def filter(self, record):
|
def filter(self, record):
|
||||||
# type: (logging.LogRecord) -> bool
|
# type: (logging.LogRecord) -> bool
|
||||||
@ -468,7 +468,7 @@ class SphinxLogRecordTranslator(logging.Filter):
|
|||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
# type: (Sphinx) -> None
|
# type: (Sphinx) -> None
|
||||||
self.app = app
|
self.app = app
|
||||||
super(SphinxLogRecordTranslator, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
def filter(self, record): # type: ignore
|
def filter(self, record): # type: ignore
|
||||||
# type: (SphinxWarningLogRecord) -> bool
|
# type: (SphinxWarningLogRecord) -> bool
|
||||||
@ -519,7 +519,7 @@ def get_node_location(node):
|
|||||||
class ColorizeFormatter(logging.Formatter):
|
class ColorizeFormatter(logging.Formatter):
|
||||||
def format(self, record):
|
def format(self, record):
|
||||||
# type: (logging.LogRecord) -> str
|
# type: (logging.LogRecord) -> str
|
||||||
message = super(ColorizeFormatter, self).format(record)
|
message = super().format(record)
|
||||||
color = getattr(record, 'color', None)
|
color = getattr(record, 'color', None)
|
||||||
if color is None:
|
if color is None:
|
||||||
color = COLOR_MAP.get(record.levelno)
|
color = COLOR_MAP.get(record.levelno)
|
||||||
|
@ -40,7 +40,7 @@ class StandardStemmer(PorterStemmer, BaseStemmer): # type: ignore
|
|||||||
"""
|
"""
|
||||||
def stem(self, word): # type: ignore
|
def stem(self, word): # type: ignore
|
||||||
# type: (str) -> str
|
# type: (str) -> str
|
||||||
return super(StandardStemmer, self).stem(word, 0, len(word) - 1)
|
return super().stem(word, 0, len(word) - 1)
|
||||||
|
|
||||||
|
|
||||||
def get_stemmer():
|
def get_stemmer():
|
||||||
|
@ -44,7 +44,7 @@ class FileRenderer(BaseRenderer):
|
|||||||
def __init__(self, search_path):
|
def __init__(self, search_path):
|
||||||
# type: (str) -> None
|
# type: (str) -> None
|
||||||
loader = SphinxFileSystemLoader(search_path)
|
loader = SphinxFileSystemLoader(search_path)
|
||||||
super(FileRenderer, self).__init__(loader)
|
super().__init__(loader)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def render_from_file(cls, filename, context):
|
def render_from_file(cls, filename, context):
|
||||||
@ -59,7 +59,7 @@ class SphinxRenderer(FileRenderer):
|
|||||||
# type: (str) -> None
|
# type: (str) -> None
|
||||||
if template_path is None:
|
if template_path is None:
|
||||||
template_path = os.path.join(package_dir, 'templates')
|
template_path = os.path.join(package_dir, 'templates')
|
||||||
super(SphinxRenderer, self).__init__(template_path)
|
super().__init__(template_path)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def render_from_file(cls, filename, context):
|
def render_from_file(cls, filename, context):
|
||||||
@ -71,7 +71,7 @@ class LaTeXRenderer(SphinxRenderer):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
template_path = os.path.join(package_dir, 'templates', 'latex')
|
template_path = os.path.join(package_dir, 'templates', 'latex')
|
||||||
super(LaTeXRenderer, self).__init__(template_path)
|
super().__init__(template_path)
|
||||||
|
|
||||||
# use texescape as escape filter
|
# use texescape as escape filter
|
||||||
self.env.filters['e'] = texescape.escape
|
self.env.filters['e'] = texescape.escape
|
||||||
|
@ -48,7 +48,7 @@ class HTMLWriter(Writer):
|
|||||||
|
|
||||||
def __init__(self, builder):
|
def __init__(self, builder):
|
||||||
# type: (StandaloneHTMLBuilder) -> None
|
# type: (StandaloneHTMLBuilder) -> None
|
||||||
super(HTMLWriter, self).__init__()
|
super().__init__()
|
||||||
self.builder = builder
|
self.builder = builder
|
||||||
|
|
||||||
def translate(self):
|
def translate(self):
|
||||||
@ -76,7 +76,7 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
|
|
||||||
def __init__(self, builder, document):
|
def __init__(self, builder, document):
|
||||||
# type: (StandaloneHTMLBuilder, nodes.document) -> None
|
# type: (StandaloneHTMLBuilder, nodes.document) -> None
|
||||||
super(HTMLTranslator, self).__init__(builder, document)
|
super().__init__(builder, document)
|
||||||
self.highlighter = self.builder.highlighter
|
self.highlighter = self.builder.highlighter
|
||||||
self.docnames = [self.builder.current_docname] # for singlehtml builder
|
self.docnames = [self.builder.current_docname] # for singlehtml builder
|
||||||
self.manpages_url = self.config.manpages_url
|
self.manpages_url = self.config.manpages_url
|
||||||
@ -377,18 +377,18 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
# avoid emitting empty <ul></ul>
|
# avoid emitting empty <ul></ul>
|
||||||
raise nodes.SkipNode
|
raise nodes.SkipNode
|
||||||
self.generate_targets_for_listing(node)
|
self.generate_targets_for_listing(node)
|
||||||
super(HTMLTranslator, self).visit_bullet_list(node)
|
super().visit_bullet_list(node)
|
||||||
|
|
||||||
# overwritten
|
# overwritten
|
||||||
def visit_enumerated_list(self, node):
|
def visit_enumerated_list(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
self.generate_targets_for_listing(node)
|
self.generate_targets_for_listing(node)
|
||||||
super(HTMLTranslator, self).visit_enumerated_list(node)
|
super().visit_enumerated_list(node)
|
||||||
|
|
||||||
# overwritten
|
# overwritten
|
||||||
def visit_title(self, node):
|
def visit_title(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
super(HTMLTranslator, self).visit_title(node)
|
super().visit_title(node)
|
||||||
self.add_secnumber(node)
|
self.add_secnumber(node)
|
||||||
self.add_fignumber(node.parent)
|
self.add_fignumber(node.parent)
|
||||||
if isinstance(node.parent, nodes.table):
|
if isinstance(node.parent, nodes.table):
|
||||||
@ -414,14 +414,14 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
elif isinstance(node.parent, nodes.table):
|
elif isinstance(node.parent, nodes.table):
|
||||||
self.body.append('</span>')
|
self.body.append('</span>')
|
||||||
|
|
||||||
super(HTMLTranslator, self).depart_title(node)
|
super().depart_title(node)
|
||||||
|
|
||||||
# overwritten
|
# overwritten
|
||||||
def visit_literal_block(self, node):
|
def visit_literal_block(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
if node.rawsource != node.astext():
|
if node.rawsource != node.astext():
|
||||||
# most probably a parsed-literal block -- don't highlight
|
# most probably a parsed-literal block -- don't highlight
|
||||||
return super(HTMLTranslator, self).visit_literal_block(node)
|
return super().visit_literal_block(node)
|
||||||
|
|
||||||
lang = node.get('language', 'default')
|
lang = node.get('language', 'default')
|
||||||
linenos = node.get('linenos', False)
|
linenos = node.get('linenos', False)
|
||||||
@ -447,7 +447,7 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'):
|
if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'):
|
||||||
self.body.append('<div class="code-block-caption">')
|
self.body.append('<div class="code-block-caption">')
|
||||||
else:
|
else:
|
||||||
super(HTMLTranslator, self).visit_caption(node)
|
super().visit_caption(node)
|
||||||
self.add_fignumber(node.parent)
|
self.add_fignumber(node.parent)
|
||||||
self.body.append(self.starttag(node, 'span', '', CLASS='caption-text'))
|
self.body.append(self.starttag(node, 'span', '', CLASS='caption-text'))
|
||||||
|
|
||||||
@ -468,7 +468,7 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'):
|
if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'):
|
||||||
self.body.append('</div>\n')
|
self.body.append('</div>\n')
|
||||||
else:
|
else:
|
||||||
super(HTMLTranslator, self).depart_caption(node)
|
super().depart_caption(node)
|
||||||
|
|
||||||
def visit_doctest_block(self, node):
|
def visit_doctest_block(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
@ -554,7 +554,7 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
if isinstance(node.parent, addnodes.versionmodified):
|
if isinstance(node.parent, addnodes.versionmodified):
|
||||||
# Never compact versionmodified nodes.
|
# Never compact versionmodified nodes.
|
||||||
return False
|
return False
|
||||||
return super(HTMLTranslator, self).should_be_compact_paragraph(node)
|
return super().should_be_compact_paragraph(node)
|
||||||
|
|
||||||
def visit_compact_paragraph(self, node):
|
def visit_compact_paragraph(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
@ -628,7 +628,7 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
node['width'] = str(size[0])
|
node['width'] = str(size[0])
|
||||||
if 'height' not in node:
|
if 'height' not in node:
|
||||||
node['height'] = str(size[1])
|
node['height'] = str(size[1])
|
||||||
super(HTMLTranslator, self).visit_image(node)
|
super().visit_image(node)
|
||||||
|
|
||||||
# overwritten
|
# overwritten
|
||||||
def depart_image(self, node):
|
def depart_image(self, node):
|
||||||
@ -636,7 +636,7 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
if node['uri'].lower().endswith(('svg', 'svgz')):
|
if node['uri'].lower().endswith(('svg', 'svgz')):
|
||||||
self.body.append(self.context.pop())
|
self.body.append(self.context.pop())
|
||||||
else:
|
else:
|
||||||
super(HTMLTranslator, self).depart_image(node)
|
super().depart_image(node)
|
||||||
|
|
||||||
def visit_toctree(self, node):
|
def visit_toctree(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
@ -686,7 +686,7 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
|
|
||||||
def visit_option_group(self, node):
|
def visit_option_group(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
super(HTMLTranslator, self).visit_option_group(node)
|
super().visit_option_group(node)
|
||||||
self.context[-2] = self.context[-2].replace(' ', ' ')
|
self.context[-2] = self.context[-2].replace(' ', ' ')
|
||||||
|
|
||||||
# overwritten
|
# overwritten
|
||||||
@ -829,7 +829,7 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
def visit_table(self, node):
|
def visit_table(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
self._table_row_index = 0
|
self._table_row_index = 0
|
||||||
return super(HTMLTranslator, self).visit_table(node)
|
return super().visit_table(node)
|
||||||
|
|
||||||
def visit_row(self, node):
|
def visit_row(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
@ -843,14 +843,14 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
|
|
||||||
def visit_entry(self, node):
|
def visit_entry(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
super(HTMLTranslator, self).visit_entry(node)
|
super().visit_entry(node)
|
||||||
if self.body[-1] == ' ':
|
if self.body[-1] == ' ':
|
||||||
self.body[-1] = ' '
|
self.body[-1] = ' '
|
||||||
|
|
||||||
def visit_field_list(self, node):
|
def visit_field_list(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
self._fieldlist_row_index = 0
|
self._fieldlist_row_index = 0
|
||||||
return super(HTMLTranslator, self).visit_field_list(node)
|
return super().visit_field_list(node)
|
||||||
|
|
||||||
def visit_field(self, node):
|
def visit_field(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
@ -864,7 +864,7 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
def visit_field_name(self, node):
|
def visit_field_name(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
context_count = len(self.context)
|
context_count = len(self.context)
|
||||||
super(HTMLTranslator, self).visit_field_name(node)
|
super().visit_field_name(node)
|
||||||
if context_count != len(self.context):
|
if context_count != len(self.context):
|
||||||
self.context[-1] = self.context[-1].replace(' ', ' ')
|
self.context[-1] = self.context[-1].replace(' ', ' ')
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
|||||||
|
|
||||||
def __init__(self, builder, document):
|
def __init__(self, builder, document):
|
||||||
# type: (StandaloneHTMLBuilder, nodes.document) -> None
|
# type: (StandaloneHTMLBuilder, nodes.document) -> None
|
||||||
super(HTML5Translator, self).__init__(builder, document)
|
super().__init__(builder, document)
|
||||||
self.highlighter = self.builder.highlighter
|
self.highlighter = self.builder.highlighter
|
||||||
self.docnames = [self.builder.current_docname] # for singlehtml builder
|
self.docnames = [self.builder.current_docname] # for singlehtml builder
|
||||||
self.manpages_url = self.config.manpages_url
|
self.manpages_url = self.config.manpages_url
|
||||||
@ -329,12 +329,12 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
|||||||
if len(node) == 1 and isinstance(node[0], addnodes.toctree):
|
if len(node) == 1 and isinstance(node[0], addnodes.toctree):
|
||||||
# avoid emitting empty <ul></ul>
|
# avoid emitting empty <ul></ul>
|
||||||
raise nodes.SkipNode
|
raise nodes.SkipNode
|
||||||
super(HTML5Translator, self).visit_bullet_list(node)
|
super().visit_bullet_list(node)
|
||||||
|
|
||||||
# overwritten
|
# overwritten
|
||||||
def visit_title(self, node):
|
def visit_title(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
super(HTML5Translator, self).visit_title(node)
|
super().visit_title(node)
|
||||||
self.add_secnumber(node)
|
self.add_secnumber(node)
|
||||||
self.add_fignumber(node.parent)
|
self.add_fignumber(node.parent)
|
||||||
if isinstance(node.parent, nodes.table):
|
if isinstance(node.parent, nodes.table):
|
||||||
@ -360,14 +360,14 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
|||||||
elif isinstance(node.parent, nodes.table):
|
elif isinstance(node.parent, nodes.table):
|
||||||
self.body.append('</span>')
|
self.body.append('</span>')
|
||||||
|
|
||||||
super(HTML5Translator, self).depart_title(node)
|
super().depart_title(node)
|
||||||
|
|
||||||
# overwritten
|
# overwritten
|
||||||
def visit_literal_block(self, node):
|
def visit_literal_block(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
if node.rawsource != node.astext():
|
if node.rawsource != node.astext():
|
||||||
# most probably a parsed-literal block -- don't highlight
|
# most probably a parsed-literal block -- don't highlight
|
||||||
return super(HTML5Translator, self).visit_literal_block(node)
|
return super().visit_literal_block(node)
|
||||||
|
|
||||||
lang = node.get('language', 'default')
|
lang = node.get('language', 'default')
|
||||||
linenos = node.get('linenos', False)
|
linenos = node.get('linenos', False)
|
||||||
@ -393,7 +393,7 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
|||||||
if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'):
|
if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'):
|
||||||
self.body.append('<div class="code-block-caption">')
|
self.body.append('<div class="code-block-caption">')
|
||||||
else:
|
else:
|
||||||
super(HTML5Translator, self).visit_caption(node)
|
super().visit_caption(node)
|
||||||
self.add_fignumber(node.parent)
|
self.add_fignumber(node.parent)
|
||||||
self.body.append(self.starttag(node, 'span', '', CLASS='caption-text'))
|
self.body.append(self.starttag(node, 'span', '', CLASS='caption-text'))
|
||||||
|
|
||||||
@ -414,7 +414,7 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
|||||||
if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'):
|
if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'):
|
||||||
self.body.append('</div>\n')
|
self.body.append('</div>\n')
|
||||||
else:
|
else:
|
||||||
super(HTML5Translator, self).depart_caption(node)
|
super().depart_caption(node)
|
||||||
|
|
||||||
def visit_doctest_block(self, node):
|
def visit_doctest_block(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
@ -562,7 +562,7 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
|||||||
node['width'] = str(size[0])
|
node['width'] = str(size[0])
|
||||||
if 'height' not in node:
|
if 'height' not in node:
|
||||||
node['height'] = str(size[1])
|
node['height'] = str(size[1])
|
||||||
super(HTML5Translator, self).visit_image(node)
|
super().visit_image(node)
|
||||||
|
|
||||||
# overwritten
|
# overwritten
|
||||||
def depart_image(self, node):
|
def depart_image(self, node):
|
||||||
@ -570,7 +570,7 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
|||||||
if node['uri'].lower().endswith(('svg', 'svgz')):
|
if node['uri'].lower().endswith(('svg', 'svgz')):
|
||||||
self.body.append(self.context.pop())
|
self.body.append(self.context.pop())
|
||||||
else:
|
else:
|
||||||
super(HTML5Translator, self).depart_image(node)
|
super().depart_image(node)
|
||||||
|
|
||||||
def visit_toctree(self, node):
|
def visit_toctree(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
@ -795,7 +795,7 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
|||||||
def visit_field_list(self, node):
|
def visit_field_list(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
self._fieldlist_row_index = 0
|
self._fieldlist_row_index = 0
|
||||||
return super(HTML5Translator, self).visit_field_list(node)
|
return super().visit_field_list(node)
|
||||||
|
|
||||||
def visit_field(self, node):
|
def visit_field(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
|
@ -250,7 +250,7 @@ class LaTeXWriter(writers.Writer):
|
|||||||
|
|
||||||
def __init__(self, builder):
|
def __init__(self, builder):
|
||||||
# type: (LaTeXBuilder) -> None
|
# type: (LaTeXBuilder) -> None
|
||||||
super(LaTeXWriter, self).__init__()
|
super().__init__()
|
||||||
self.builder = builder
|
self.builder = builder
|
||||||
|
|
||||||
def translate(self):
|
def translate(self):
|
||||||
@ -270,7 +270,7 @@ class ExtBabel(Babel):
|
|||||||
self.language_code = language_code
|
self.language_code = language_code
|
||||||
self.use_polyglossia = use_polyglossia
|
self.use_polyglossia = use_polyglossia
|
||||||
self.supported = True
|
self.supported = True
|
||||||
super(ExtBabel, self).__init__(language_code or '')
|
super().__init__(language_code or '')
|
||||||
|
|
||||||
def get_shorthandoff(self):
|
def get_shorthandoff(self):
|
||||||
# type: () -> str
|
# type: () -> str
|
||||||
@ -288,7 +288,7 @@ class ExtBabel(Babel):
|
|||||||
|
|
||||||
def language_name(self, language_code):
|
def language_name(self, language_code):
|
||||||
# type: (str) -> str
|
# type: (str) -> str
|
||||||
language = super(ExtBabel, self).language_name(language_code)
|
language = super().language_name(language_code)
|
||||||
if language == 'ngerman' and self.use_polyglossia:
|
if language == 'ngerman' and self.use_polyglossia:
|
||||||
# polyglossia calls new orthography (Neue Rechtschreibung) as
|
# polyglossia calls new orthography (Neue Rechtschreibung) as
|
||||||
# german (with new spelling option).
|
# german (with new spelling option).
|
||||||
@ -305,7 +305,7 @@ class ExtBabel(Babel):
|
|||||||
if self.use_polyglossia is False:
|
if self.use_polyglossia is False:
|
||||||
return None
|
return None
|
||||||
elif self.language == 'german':
|
elif self.language == 'german':
|
||||||
language = super(ExtBabel, self).language_name(self.language_code)
|
language = super().language_name(self.language_code)
|
||||||
if language == 'ngerman':
|
if language == 'ngerman':
|
||||||
return 'spelling=new'
|
return 'spelling=new'
|
||||||
else:
|
else:
|
||||||
@ -509,7 +509,7 @@ class LaTeXTranslator(SphinxTranslator):
|
|||||||
|
|
||||||
def __init__(self, document, builder):
|
def __init__(self, document, builder):
|
||||||
# type: (nodes.document, LaTeXBuilder) -> None
|
# type: (nodes.document, LaTeXBuilder) -> None
|
||||||
super(LaTeXTranslator, self).__init__(builder, document)
|
super().__init__(builder, document)
|
||||||
self.body = [] # type: List[str]
|
self.body = [] # type: List[str]
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
|
@ -35,7 +35,7 @@ logger = logging.getLogger(__name__)
|
|||||||
class ManualPageWriter(Writer):
|
class ManualPageWriter(Writer):
|
||||||
def __init__(self, builder):
|
def __init__(self, builder):
|
||||||
# type: (Builder) -> None
|
# type: (Builder) -> None
|
||||||
super(ManualPageWriter, self).__init__()
|
super().__init__()
|
||||||
self.builder = builder
|
self.builder = builder
|
||||||
|
|
||||||
def translate(self):
|
def translate(self):
|
||||||
@ -87,7 +87,7 @@ class ManualPageTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
|
|
||||||
def __init__(self, builder, document):
|
def __init__(self, builder, document):
|
||||||
# type: (Builder, nodes.document) -> None
|
# type: (Builder, nodes.document) -> None
|
||||||
super(ManualPageTranslator, self).__init__(builder, document)
|
super().__init__(builder, document)
|
||||||
|
|
||||||
self.in_productionlist = 0
|
self.in_productionlist = 0
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ class ManualPageTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
if node.traverse(nodes.strong):
|
if node.traverse(nodes.strong):
|
||||||
self.body.append('\n')
|
self.body.append('\n')
|
||||||
else:
|
else:
|
||||||
super(ManualPageTranslator, self).visit_term(node)
|
super().visit_term(node)
|
||||||
|
|
||||||
# overwritten -- we don't want source comments to show up
|
# overwritten -- we don't want source comments to show up
|
||||||
def visit_comment(self, node): # type: ignore
|
def visit_comment(self, node): # type: ignore
|
||||||
@ -260,7 +260,7 @@ class ManualPageTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
def visit_footnote(self, node):
|
def visit_footnote(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
self.ensure_eol()
|
self.ensure_eol()
|
||||||
super(ManualPageTranslator, self).visit_footnote(node)
|
super().visit_footnote(node)
|
||||||
|
|
||||||
# overwritten -- handle footnotes rubric
|
# overwritten -- handle footnotes rubric
|
||||||
def visit_rubric(self, node):
|
def visit_rubric(self, node):
|
||||||
@ -473,14 +473,14 @@ class ManualPageTranslator(SphinxTranslator, BaseTranslator):
|
|||||||
self.body.append('.SH %s\n' %
|
self.body.append('.SH %s\n' %
|
||||||
self.deunicode(node.astext().upper()))
|
self.deunicode(node.astext().upper()))
|
||||||
raise nodes.SkipNode
|
raise nodes.SkipNode
|
||||||
return super(ManualPageTranslator, self).visit_title(node)
|
return super().visit_title(node)
|
||||||
|
|
||||||
def depart_title(self, node):
|
def depart_title(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
if isinstance(node.parent, addnodes.seealso):
|
if isinstance(node.parent, addnodes.seealso):
|
||||||
self.body.append('"\n')
|
self.body.append('"\n')
|
||||||
return
|
return
|
||||||
return super(ManualPageTranslator, self).depart_title(node)
|
return super().depart_title(node)
|
||||||
|
|
||||||
def visit_raw(self, node):
|
def visit_raw(self, node):
|
||||||
# type: (nodes.Element) -> None
|
# type: (nodes.Element) -> None
|
||||||
|
@ -134,7 +134,7 @@ class TexinfoWriter(writers.Writer):
|
|||||||
|
|
||||||
def __init__(self, builder):
|
def __init__(self, builder):
|
||||||
# type: (TexinfoBuilder) -> None
|
# type: (TexinfoBuilder) -> None
|
||||||
super(TexinfoWriter, self).__init__()
|
super().__init__()
|
||||||
self.builder = builder
|
self.builder = builder
|
||||||
|
|
||||||
def translate(self):
|
def translate(self):
|
||||||
@ -169,7 +169,7 @@ class TexinfoTranslator(SphinxTranslator):
|
|||||||
|
|
||||||
def __init__(self, document, builder):
|
def __init__(self, document, builder):
|
||||||
# type: (nodes.document, TexinfoBuilder) -> None
|
# type: (nodes.document, TexinfoBuilder) -> None
|
||||||
super(TexinfoTranslator, self).__init__(builder, document)
|
super().__init__(builder, document)
|
||||||
self.init_settings()
|
self.init_settings()
|
||||||
|
|
||||||
self.written_ids = set() # type: Set[str]
|
self.written_ids = set() # type: Set[str]
|
||||||
|
@ -382,7 +382,7 @@ class TextWriter(writers.Writer):
|
|||||||
|
|
||||||
def __init__(self, builder):
|
def __init__(self, builder):
|
||||||
# type: (TextBuilder) -> None
|
# type: (TextBuilder) -> None
|
||||||
super(TextWriter, self).__init__()
|
super().__init__()
|
||||||
self.builder = builder
|
self.builder = builder
|
||||||
|
|
||||||
def translate(self):
|
def translate(self):
|
||||||
@ -397,7 +397,7 @@ class TextTranslator(SphinxTranslator):
|
|||||||
|
|
||||||
def __init__(self, document, builder):
|
def __init__(self, document, builder):
|
||||||
# type: (nodes.document, TextBuilder) -> None
|
# type: (nodes.document, TextBuilder) -> None
|
||||||
super(TextTranslator, self).__init__(builder, document)
|
super().__init__(builder, document)
|
||||||
|
|
||||||
newlines = self.config.text_newlines
|
newlines = self.config.text_newlines
|
||||||
if newlines == 'windows':
|
if newlines == 'windows':
|
||||||
|
@ -21,7 +21,7 @@ class XMLWriter(BaseXMLWriter):
|
|||||||
|
|
||||||
def __init__(self, builder):
|
def __init__(self, builder):
|
||||||
# type: (Builder) -> None
|
# type: (Builder) -> None
|
||||||
super(XMLWriter, self).__init__()
|
super().__init__()
|
||||||
self.builder = builder
|
self.builder = builder
|
||||||
self.translator_class = self.builder.get_translator_class()
|
self.translator_class = self.builder.get_translator_class()
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ class XMLWriter(BaseXMLWriter):
|
|||||||
self.builder.env.config.xml_pretty
|
self.builder.env.config.xml_pretty
|
||||||
self.document.settings.xml_declaration = True
|
self.document.settings.xml_declaration = True
|
||||||
self.document.settings.doctype_declaration = True
|
self.document.settings.doctype_declaration = True
|
||||||
return super(XMLWriter, self).translate()
|
return super().translate()
|
||||||
|
|
||||||
|
|
||||||
class PseudoXMLWriter(BaseXMLWriter):
|
class PseudoXMLWriter(BaseXMLWriter):
|
||||||
@ -48,7 +48,7 @@ class PseudoXMLWriter(BaseXMLWriter):
|
|||||||
|
|
||||||
def __init__(self, builder):
|
def __init__(self, builder):
|
||||||
# type: (Builder) -> None
|
# type: (Builder) -> None
|
||||||
super(PseudoXMLWriter, self).__init__()
|
super().__init__()
|
||||||
self.builder = builder
|
self.builder = builder
|
||||||
|
|
||||||
def translate(self):
|
def translate(self):
|
||||||
|
@ -17,7 +17,7 @@ from sphinx.util.fileutil import copy_asset, copy_asset_file
|
|||||||
|
|
||||||
class DummyTemplateLoader(BuiltinTemplateLoader):
|
class DummyTemplateLoader(BuiltinTemplateLoader):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(DummyTemplateLoader, self).__init__()
|
super().__init__()
|
||||||
builder = mock.Mock()
|
builder = mock.Mock()
|
||||||
builder.config.templates_path = []
|
builder.config.templates_path = []
|
||||||
builder.app.translater = None
|
builder.app.translater = None
|
||||||
|
Loading…
Reference in New Issue
Block a user