diff options
| author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-07-06 12:27:36 +0900 |
|---|---|---|
| committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-07-06 12:42:26 +0900 |
| commit | be673a714db80d3596f811ccf5421d5653cbe559 (patch) | |
| tree | 9a57ed8a1249eaee555760d909533dba128e02d4 /sphinx/environment | |
| parent | f076afd920b0b36d63608a63fae72f484d4bd65e (diff) | |
| download | sphinx-git-be673a714db80d3596f811ccf5421d5653cbe559.tar.gz | |
Migrate to py3 style type annotation: sphinx.environment.collectors.indexentries
Diffstat (limited to 'sphinx/environment')
| -rw-r--r-- | sphinx/environment/collectors/indexentries.py | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/sphinx/environment/collectors/indexentries.py b/sphinx/environment/collectors/indexentries.py index 2d8af7887..9c86779fc 100644 --- a/sphinx/environment/collectors/indexentries.py +++ b/sphinx/environment/collectors/indexentries.py @@ -8,34 +8,31 @@ :license: BSD, see LICENSE for details. """ +from typing import Any, Dict, Set + +from docutils import nodes + from sphinx import addnodes +from sphinx.application import Sphinx +from sphinx.environment import BuildEnvironment from sphinx.environment.collectors import EnvironmentCollector from sphinx.util import split_index_msg, logging -if False: - # For type annotation - from typing import Dict, Set # NOQA - from docutils import nodes # NOQA - from sphinx.applicatin import Sphinx # NOQA - from sphinx.environment import BuildEnvironment # NOQA - logger = logging.getLogger(__name__) class IndexEntriesCollector(EnvironmentCollector): name = 'indices' - def clear_doc(self, app, env, docname): - # type: (Sphinx, BuildEnvironment, str) -> None + def clear_doc(self, app: Sphinx, env: BuildEnvironment, docname: str) -> None: env.indexentries.pop(docname, None) - def merge_other(self, app, env, docnames, other): - # type: (Sphinx, BuildEnvironment, Set[str], BuildEnvironment) -> None + def merge_other(self, app: Sphinx, env: BuildEnvironment, + docnames: Set[str], other: BuildEnvironment) -> None: for docname in docnames: env.indexentries[docname] = other.indexentries[docname] - def process_doc(self, app, doctree): - # type: (Sphinx, nodes.document) -> None + def process_doc(self, app: Sphinx, doctree: nodes.document) -> None: docname = app.env.docname entries = app.env.indexentries[docname] = [] for node in doctree.traverse(addnodes.index): @@ -50,8 +47,7 @@ class IndexEntriesCollector(EnvironmentCollector): entries.append(entry) -def setup(app): - # type: (Sphinx) -> Dict +def setup(app: Sphinx) -> Dict[str, Any]: app.add_env_collector(IndexEntriesCollector) return { |
