diff options
Diffstat (limited to 'sphinx/util/docutils.py')
-rw-r--r-- | sphinx/util/docutils.py | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/sphinx/util/docutils.py b/sphinx/util/docutils.py index 1ec01ddc4..3e36565f7 100644 --- a/sphinx/util/docutils.py +++ b/sphinx/util/docutils.py @@ -44,7 +44,7 @@ if False: from sphinx.config import Config # NOQA from sphinx.environment import BuildEnvironment # NOQA from sphinx.io import SphinxFileInput # NOQA - from sphinx.util.typing import RoleFunction, unicode # NOQA + from sphinx.util.typing import RoleFunction # NOQA __version_info__ = tuple(LooseVersion(docutils.__version__).version) @@ -70,13 +70,13 @@ def docutils_namespace(): def is_directive_registered(name): - # type: (unicode) -> bool + # type: (str) -> bool """Check the *name* directive is already registered.""" return name in directives._directives # type: ignore def register_directive(name, directive): - # type: (unicode, Type[Directive]) -> None + # type: (str, Type[Directive]) -> None """Register a directive to docutils. This modifies global state of docutils. So it is better to use this @@ -86,13 +86,13 @@ def register_directive(name, directive): def is_role_registered(name): - # type: (unicode) -> bool + # type: (str) -> bool """Check the *name* role is already registered.""" return name in roles._roles # type: ignore def register_role(name, role): - # type: (unicode, RoleFunction) -> None + # type: (str, RoleFunction) -> None """Register a role to docutils. This modifies global state of docutils. So it is better to use this @@ -102,7 +102,7 @@ def register_role(name, role): def unregister_role(name): - # type: (unicode) -> None + # type: (str) -> None """Unregister a role from docutils.""" roles._roles.pop(name, None) # type: ignore @@ -149,7 +149,7 @@ def patched_get_language(): from docutils.languages import get_language def patched_get_language(language_code, reporter=None): - # type: (unicode, Reporter) -> Any + # type: (str, Reporter) -> Any return get_language(language_code) try: @@ -162,7 +162,7 @@ def patched_get_language(): @contextmanager def using_user_docutils_conf(confdir): - # type: (unicode) -> Generator[None, None, None] + # type: (str) -> Generator[None, None, None] """Let docutils know the location of ``docutils.conf`` for Sphinx.""" try: docutilsconfig = os.environ.get('DOCUTILSCONFIG', None) @@ -179,7 +179,7 @@ def using_user_docutils_conf(confdir): @contextmanager def patch_docutils(confdir=None): - # type: (unicode) -> Generator[None, None, None] + # type: (str) -> Generator[None, None, None] """Patch to docutils temporarily.""" with patched_get_language(), using_user_docutils_conf(confdir): yield @@ -204,7 +204,7 @@ class sphinx_domains: self.enable() def __exit__(self, type, value, traceback): - # type: (unicode, unicode, unicode) -> None + # type: (str, str, str) -> None self.disable() def enable(self): @@ -221,7 +221,7 @@ class sphinx_domains: roles.role = self.role_func def lookup_domain_element(self, type, name): - # type: (unicode, unicode) -> Any + # type: (str, str) -> Any """Lookup a markup element (directive or role), given its name which can be a full name (with domain). """ @@ -250,14 +250,14 @@ class sphinx_domains: raise ElementLookupError def lookup_directive(self, name, lang_module, document): - # type: (unicode, ModuleType, nodes.document) -> Tuple[Type[Directive], List[nodes.system_message]] # NOQA + # type: (str, ModuleType, nodes.document) -> Tuple[Type[Directive], List[nodes.system_message]] # NOQA try: return self.lookup_domain_element('directive', name) except ElementLookupError: return self.directive_func(name, lang_module, document) def lookup_role(self, name, lang_module, lineno, reporter): - # type: (unicode, ModuleType, int, Reporter) -> Tuple[RoleFunction, List[nodes.system_message]] # NOQA + # type: (str, ModuleType, int, Reporter) -> Tuple[RoleFunction, List[nodes.system_message]] # NOQA try: return self.lookup_domain_element('role', name) except ElementLookupError: @@ -266,7 +266,7 @@ class sphinx_domains: class WarningStream: def write(self, text): - # type: (unicode) -> None + # type: (str) -> None matched = report_re.search(text) if not matched: logger.warning(text.rstrip("\r\n")) @@ -287,7 +287,7 @@ class LoggingReporter(Reporter): def __init__(self, source, report_level=Reporter.WARNING_LEVEL, halt_level=Reporter.SEVERE_LEVEL, debug=False, error_handler='backslashreplace'): - # type: (unicode, int, int, bool, unicode) -> None + # type: (str, int, int, bool, str) -> None stream = cast(IO, WarningStream()) super(LoggingReporter, self).__init__(source, report_level, halt_level, stream, debug, error_handler=error_handler) @@ -352,7 +352,7 @@ class SphinxFileOutput(FileOutput): super(SphinxFileOutput, self).__init__(**kwargs) def write(self, data): - # type: (unicode) -> unicode + # type: (str) -> str if (self.destination_path and self.autoclose and 'b' not in self.mode and self.overwrite_if_changed and os.path.exists(self.destination_path)): with open(self.destination_path, encoding=self.encoding) as f: @@ -408,7 +408,7 @@ __document_cache__ = None # type: nodes.document def new_document(source_path, settings=None): - # type: (unicode, Any) -> nodes.document + # type: (str, Any) -> nodes.document """Return a new empty document object. This is an alternative of docutils'. This is a simple wrapper for ``docutils.utils.new_document()``. It |