mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add type-check annotations to sphinx.writers
This commit is contained in:
parent
0d1875e2b5
commit
3407ef0ca8
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -12,16 +12,23 @@
|
|||||||
from docutils import writers
|
from docutils import writers
|
||||||
from docutils.writers.docutils_xml import Writer as BaseXMLWriter
|
from docutils.writers.docutils_xml import Writer as BaseXMLWriter
|
||||||
|
|
||||||
|
if False:
|
||||||
|
# For type annotation
|
||||||
|
from typing import Any, Tuple # NOQA
|
||||||
|
from sphinx.builders import Builder # NOQA
|
||||||
|
|
||||||
|
|
||||||
class XMLWriter(BaseXMLWriter):
|
class XMLWriter(BaseXMLWriter):
|
||||||
|
|
||||||
def __init__(self, builder):
|
def __init__(self, builder):
|
||||||
|
# type: (Builder) -> None
|
||||||
BaseXMLWriter.__init__(self)
|
BaseXMLWriter.__init__(self)
|
||||||
self.builder = builder
|
self.builder = builder
|
||||||
if self.builder.translator_class:
|
if self.builder.translator_class:
|
||||||
self.translator_class = self.builder.translator_class
|
self.translator_class = self.builder.translator_class
|
||||||
|
|
||||||
def translate(self, *args, **kwargs):
|
def translate(self, *args, **kwargs):
|
||||||
|
# type: (Any, Any) -> None
|
||||||
self.document.settings.newlines = \
|
self.document.settings.newlines = \
|
||||||
self.document.settings.indents = \
|
self.document.settings.indents = \
|
||||||
self.builder.env.config.xml_pretty
|
self.builder.env.config.xml_pretty
|
||||||
@ -36,18 +43,21 @@ class PseudoXMLWriter(writers.Writer):
|
|||||||
"""Formats this writer supports."""
|
"""Formats this writer supports."""
|
||||||
|
|
||||||
config_section = 'pseudoxml writer'
|
config_section = 'pseudoxml writer'
|
||||||
config_section_dependencies = ('writers',)
|
config_section_dependencies = ('writers',) # type: Tuple[unicode]
|
||||||
|
|
||||||
output = None
|
output = None
|
||||||
"""Final translated form of `document`."""
|
"""Final translated form of `document`."""
|
||||||
|
|
||||||
def __init__(self, builder):
|
def __init__(self, builder):
|
||||||
|
# type: (Builder) -> None
|
||||||
writers.Writer.__init__(self)
|
writers.Writer.__init__(self)
|
||||||
self.builder = builder
|
self.builder = builder
|
||||||
|
|
||||||
def translate(self):
|
def translate(self):
|
||||||
|
# type: () -> None
|
||||||
self.output = self.document.pformat()
|
self.output = self.document.pformat()
|
||||||
|
|
||||||
def supports(self, format):
|
def supports(self, format):
|
||||||
|
# type: (unicode) -> bool
|
||||||
"""This writer supports all format-specific elements."""
|
"""This writer supports all format-specific elements."""
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user