diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-12-14 21:14:11 +0300 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-12-15 17:57:43 +0300 |
commit | 6bc357140dbb074eb0d590c1226009f83f97862e (patch) | |
tree | a7c8d2087ee1f50dadb5ca78343ac10c6959b740 /sphinx/registry.py | |
parent | 0031c9b4822ae9684888ae90bc70d6ceb3313581 (diff) |
Replace all "unicode" type by "str"
Diffstat (limited to 'sphinx/registry.py')
-rw-r--r-- | sphinx/registry.py | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/sphinx/registry.py b/sphinx/registry.py index f155048c4..89e87cdbd 100644 --- a/sphinx/registry.py +++ b/sphinx/registry.py @@ -43,7 +43,7 @@ if False: from sphinx.environment import BuildEnvironment # NOQA from sphinx.ext.autodoc import Documenter # NOQA from sphinx.io import SphinxFileInput # NOQA - from sphinx.util.typing import RoleFunction, TitleGetter, unicode # NOQA + from sphinx.util.typing import RoleFunction, TitleGetter # NOQA logger = logging.getLogger(__name__) @@ -51,76 +51,76 @@ logger = logging.getLogger(__name__) # Values are Sphinx version that merge the extension. EXTENSION_BLACKLIST = { "sphinxjp.themecore": "1.2" -} # type: Dict[unicode, unicode] +} class SphinxComponentRegistry: def __init__(self): # type: () -> None #: special attrgetter for autodoc; class object -> attrgetter - self.autodoc_attrgettrs = {} # type: Dict[Type, Callable[[Any, unicode, Any], Any]] + self.autodoc_attrgettrs = {} # type: Dict[Type, Callable[[Any, str, Any], Any]] #: builders; a dict of builder name -> bulider class - self.builders = {} # type: Dict[unicode, Type[Builder]] + self.builders = {} # type: Dict[str, Type[Builder]] #: autodoc documenters; a dict of documenter name -> documenter class - self.documenters = {} # type: Dict[unicode, Type[Documenter]] + self.documenters = {} # type: Dict[str, Type[Documenter]] #: css_files; a list of tuple of filename and attributes - self.css_files = [] # type: List[Tuple[unicode, Dict[unicode, unicode]]] + self.css_files = [] # type: List[Tuple[str, Dict[str, str]]] #: domains; a dict of domain name -> domain class - self.domains = {} # type: Dict[unicode, Type[Domain]] + self.domains = {} # type: Dict[str, Type[Domain]] #: additional directives for domains #: a dict of domain name -> dict of directive name -> directive - self.domain_directives = {} # type: Dict[unicode, Dict[unicode, Any]] + self.domain_directives = {} # type: Dict[str, Dict[str, Any]] #: additional indices for domains #: a dict of domain name -> list of index class - self.domain_indices = {} # type: Dict[unicode, List[Type[Index]]] + self.domain_indices = {} # type: Dict[str, List[Type[Index]]] #: additional object types for domains #: a dict of domain name -> dict of objtype name -> objtype - self.domain_object_types = {} # type: Dict[unicode, Dict[unicode, ObjType]] + self.domain_object_types = {} # type: Dict[str, Dict[str, ObjType]] #: additional roles for domains #: a dict of domain name -> dict of role name -> role impl. - self.domain_roles = {} # type: Dict[unicode, Dict[unicode, Union[RoleFunction, XRefRole]]] # NOQA + self.domain_roles = {} # type: Dict[str, Dict[str, Union[RoleFunction, XRefRole]]] # NOQA #: additional enumerable nodes #: a dict of node class -> tuple of figtype and title_getter function - self.enumerable_nodes = {} # type: Dict[Type[nodes.Node], Tuple[unicode, TitleGetter]] # NOQA + self.enumerable_nodes = {} # type: Dict[Type[nodes.Node], Tuple[str, TitleGetter]] #: HTML inline and block math renderers #: a dict of name -> tuple of visit function and depart function - self.html_inline_math_renderers = {} # type: Dict[unicode, Tuple[Callable, Callable]] # NOQA - self.html_block_math_renderers = {} # type: Dict[unicode, Tuple[Callable, Callable]] # NOQA + self.html_inline_math_renderers = {} # type: Dict[str, Tuple[Callable, Callable]] + self.html_block_math_renderers = {} # type: Dict[str, Tuple[Callable, Callable]] #: js_files; list of JS paths or URLs - self.js_files = [] # type: List[Tuple[unicode, Dict[unicode, unicode]]] + self.js_files = [] # type: List[Tuple[str, Dict[str, str]]] #: LaTeX packages; list of package names and its options - self.latex_packages = [] # type: List[Tuple[unicode, unicode]] + self.latex_packages = [] # type: List[Tuple[str, str]] #: post transforms; list of transforms self.post_transforms = [] # type: List[Type[Transform]] #: source paresrs; file type -> parser class - self.source_parsers = {} # type: Dict[unicode, Type[Parser]] + self.source_parsers = {} # type: Dict[str, Type[Parser]] #: source inputs; file type -> input class - self.source_inputs = {} # type: Dict[unicode, Type[Input]] + self.source_inputs = {} # type: Dict[str, Type[Input]] #: source suffix: suffix -> file type - self.source_suffix = {} # type: Dict[unicode, unicode] + self.source_suffix = {} # type: Dict[str, str] #: custom translators; builder name -> translator class - self.translators = {} # type: Dict[unicode, Type[nodes.NodeVisitor]] + self.translators = {} # type: Dict[str, Type[nodes.NodeVisitor]] #: custom handlers for translators #: a dict of builder name -> dict of node name -> visitor and departure functions - self.translation_handlers = {} # type: Dict[unicode, Dict[unicode, Tuple[Callable, Callable]]] # NOQA + self.translation_handlers = {} # type: Dict[str, Dict[str, Tuple[Callable, Callable]]] #: additional transforms; list of transforms self.transforms = [] # type: List[Type[Transform]] @@ -136,7 +136,7 @@ class SphinxComponentRegistry: self.builders[builder.name] = builder def preload_builder(self, app, name): - # type: (Sphinx, unicode) -> None + # type: (Sphinx, str) -> None if name is None: return @@ -151,7 +151,7 @@ class SphinxComponentRegistry: self.load_extension(app, entry_point.module_name) def create_builder(self, app, name): - # type: (Sphinx, unicode) -> Builder + # type: (Sphinx, str) -> Builder if name not in self.builders: raise SphinxError(__('Builder name %s not registered') % name) @@ -165,7 +165,7 @@ class SphinxComponentRegistry: self.domains[domain.name] = domain def has_domain(self, domain): - # type: (unicode) -> bool + # type: (str) -> bool return domain in self.domains def create_domains(self, env): @@ -191,7 +191,7 @@ class SphinxComponentRegistry: def add_directive_to_domain(self, domain, name, obj, has_content=None, argument_spec=None, override=False, **option_spec): - # type: (unicode, unicode, Any, bool, Any, bool, Any) -> None + # type: (str, str, Any, bool, Any, bool, Any) -> None logger.debug('[app] adding directive to domain: %r', (domain, name, obj, has_content, argument_spec, option_spec)) if domain not in self.domains: @@ -207,7 +207,7 @@ class SphinxComponentRegistry: directives[name] = obj def add_role_to_domain(self, domain, name, role, override=False): - # type: (unicode, unicode, Union[RoleFunction, XRefRole], bool) -> None + # type: (str, str, Union[RoleFunction, XRefRole], bool) -> None logger.debug('[app] adding role to domain: %r', (domain, name, role)) if domain not in self.domains: raise ExtensionError(__('domain %s not yet registered') % domain) @@ -218,7 +218,7 @@ class SphinxComponentRegistry: roles[name] = role def add_index_to_domain(self, domain, index, override=False): - # type: (unicode, Type[Index], bool) -> None + # type: (str, Type[Index], bool) -> None logger.debug('[app] adding index to domain: %r', (domain, index)) if domain not in self.domains: raise ExtensionError(__('domain %s not yet registered') % domain) @@ -231,7 +231,7 @@ class SphinxComponentRegistry: def add_object_type(self, directivename, rolename, indextemplate='', parse_node=None, ref_nodeclass=None, objname='', doc_field_types=[], override=False): - # type: (unicode, unicode, unicode, Callable, Type[nodes.TextElement], unicode, List, bool) -> None # NOQA + # type: (str, str, str, Callable, Type[nodes.TextElement], str, List, bool) -> None logger.debug('[app] adding object type: %r', (directivename, rolename, indextemplate, parse_node, ref_nodeclass, objname, doc_field_types)) @@ -254,7 +254,7 @@ class SphinxComponentRegistry: def add_crossref_type(self, directivename, rolename, indextemplate='', ref_nodeclass=None, objname='', override=False): - # type: (unicode, unicode, unicode, Type[nodes.TextElement], unicode, bool) -> None + # type: (str, str, str, Type[nodes.TextElement], str, bool) -> None logger.debug('[app] adding crossref type: %r', (directivename, rolename, indextemplate, ref_nodeclass, objname)) @@ -273,7 +273,7 @@ class SphinxComponentRegistry: object_types[directivename] = ObjType(objname or directivename, rolename) def add_source_suffix(self, suffix, filetype, override=False): - # type: (unicode, unicode, bool) -> None + # type: (str, str, bool) -> None logger.debug('[app] adding source_suffix: %r, %r', suffix, filetype) if suffix in self.source_suffix and not override: raise ExtensionError(__('source_suffix %r is already registered') % suffix) @@ -285,7 +285,7 @@ class SphinxComponentRegistry: logger.debug('[app] adding search source_parser: %r', args) if len(args) == 1: # new sytle arguments: (source_parser) - suffix = None # type: unicode + suffix = None # type: str parser = args[0] # type: Type[Parser] else: # old style arguments: (suffix, source_parser) @@ -318,18 +318,18 @@ class SphinxComponentRegistry: self.source_parsers[suffix] = parser def get_source_parser(self, filetype): - # type: (unicode) -> Type[Parser] + # type: (str) -> Type[Parser] try: return self.source_parsers[filetype] except KeyError: raise SphinxError(__('Source parser for %s not registered') % filetype) def get_source_parsers(self): - # type: () -> Dict[unicode, Type[Parser]] + # type: () -> Dict[str, Type[Parser]] return self.source_parsers def create_source_parser(self, app, filename): - # type: (Sphinx, unicode) -> Parser + # type: (Sphinx, str) -> Parser parser_class = self.get_source_parser(filename) parser = parser_class() if isinstance(parser, SphinxParser): @@ -345,7 +345,7 @@ class SphinxComponentRegistry: self.source_inputs[filetype] = input_class def get_source_input(self, filetype): - # type: (unicode) -> Type[Input] + # type: (str) -> Type[Input] try: return self.source_inputs[filetype] except KeyError: @@ -356,7 +356,7 @@ class SphinxComponentRegistry: raise SphinxError(__('source_input for %s not registered') % filetype) def add_translator(self, name, translator, override=False): - # type: (unicode, Type[nodes.NodeVisitor], bool) -> None + # type: (str, Type[nodes.NodeVisitor], bool) -> None logger.debug('[app] Change of translator for the %s builder.' % name) if name in self.translators and not override: raise ExtensionError(__('Translator for %r already exists') % name) @@ -417,35 +417,35 @@ class SphinxComponentRegistry: return self.post_transforms def add_documenter(self, objtype, documenter): - # type: (unicode, Type[Documenter]) -> None + # type: (str, Type[Documenter]) -> None self.documenters[objtype] = documenter def add_autodoc_attrgetter(self, typ, attrgetter): - # type: (Type, Callable[[Any, unicode, Any], Any]) -> None + # type: (Type, Callable[[Any, str, Any], Any]) -> None self.autodoc_attrgettrs[typ] = attrgetter def add_css_files(self, filename, **attributes): self.css_files.append((filename, attributes)) def add_js_file(self, filename, **attributes): - # type: (unicode, **unicode) -> None + # type: (str, **str) -> None logger.debug('[app] adding js_file: %r, %r', filename, attributes) self.js_files.append((filename, attributes)) def add_latex_package(self, name, options): - # type: (unicode, unicode) -> None + # type: (str, str) -> None logger.debug('[app] adding latex package: %r', name) self.latex_packages.append((name, options)) def add_enumerable_node(self, node, figtype, title_getter=None, override=False): - # type: (Type[nodes.Node], unicode, TitleGetter, bool) -> None + # type: (Type[nodes.Node], str, TitleGetter, bool) -> None logger.debug('[app] adding enumerable node: (%r, %r, %r)', node, figtype, title_getter) if node in self.enumerable_nodes and not override: raise ExtensionError(__('enumerable_node %r already registered') % node) self.enumerable_nodes[node] = (figtype, title_getter) def add_html_math_renderer(self, name, inline_renderers, block_renderers): - # type: (unicode, Tuple[Callable, Callable], Tuple[Callable, Callable]) -> None + # type: (str, Tuple[Callable, Callable], Tuple[Callable, Callable]) -> None logger.debug('[app] adding html_math_renderer: %s, %r, %r', name, inline_renderers, block_renderers) if name in self.html_inline_math_renderers: @@ -455,7 +455,7 @@ class SphinxComponentRegistry: self.html_block_math_renderers[name] = block_renderers def load_extension(self, app, extname): - # type: (Sphinx, unicode) -> None + # type: (Sphinx, str) -> None """Load a Sphinx extension.""" if extname in app.extensions: # alread loaded return @@ -477,7 +477,7 @@ class SphinxComponentRegistry: if not hasattr(mod, 'setup'): logger.warning(__('extension %r has no setup() function; is it really ' 'a Sphinx extension module?'), extname) - metadata = {} # type: Dict[unicode, Any] + metadata = {} # type: Dict[str, Any] else: try: metadata = mod.setup(app) @@ -500,7 +500,7 @@ class SphinxComponentRegistry: app.extensions[extname] = Extension(extname, mod, **metadata) def get_envversion(self, app): - # type: (Sphinx) -> Dict[unicode, unicode] + # type: (Sphinx) -> Dict[str, str] from sphinx.environment import ENV_VERSION envversion = {ext.name: ext.metadata['env_version'] for ext in app.extensions.values() if ext.metadata.get('env_version')} @@ -524,7 +524,7 @@ def merge_source_suffix(app, config): def setup(app): - # type: (Sphinx) -> Dict[unicode, Any] + # type: (Sphinx) -> Dict[str, Any] app.connect('config-inited', merge_source_suffix) return { |