Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2019-12-25 05:41:54 +0300
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2019-12-25 05:41:54 +0300
commitd717f5ae31d17533a5a20b581f571eb4a95b1b30 (patch)
tree65bb3a38edc57d2b5e70b19ca8996ccebd1e3951 /sphinx/environment
parentd82e7c12a177a6a547ba1e72540f079f64590f8a (diff)
parent869ba4f67947b97af90dc706fb7e6ed17946ccd3 (diff)
Merge branch '2.0'
Diffstat (limited to 'sphinx/environment')
-rw-r--r--sphinx/environment/__init__.py2
-rw-r--r--sphinx/environment/adapters/indexentries.py5
-rw-r--r--sphinx/environment/collectors/__init__.py19
3 files changed, 16 insertions, 10 deletions
diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py
index 25648e38b..aa2bfed99 100644
--- a/sphinx/environment/__init__.py
+++ b/sphinx/environment/__init__.py
@@ -640,7 +640,7 @@ class BuildEnvironment:
@property
def indexentries(self) -> Dict[str, List[Tuple[str, str, str, str, str]]]:
warnings.warn('env.indexentries() is deprecated. Please use IndexDomain instead.',
- RemovedInSphinx40Warning)
+ RemovedInSphinx40Warning, stacklevel=2)
from sphinx.domains.index import IndexDomain
domain = cast(IndexDomain, self.get_domain('index'))
return domain.entries
diff --git a/sphinx/environment/adapters/indexentries.py b/sphinx/environment/adapters/indexentries.py
index 68198040d..9394f92bc 100644
--- a/sphinx/environment/adapters/indexentries.py
+++ b/sphinx/environment/adapters/indexentries.py
@@ -12,8 +12,10 @@ import re
import unicodedata
from itertools import groupby
from typing import Any, Dict, Pattern, List, Tuple
+from typing import cast
from sphinx.builders import Builder
+from sphinx.domains.index import IndexDomain
from sphinx.environment import BuildEnvironment
from sphinx.errors import NoUri
from sphinx.locale import _, __
@@ -53,7 +55,8 @@ class IndexEntries:
# maintain links in sorted/deterministic order
bisect.insort(entry[0], (main, uri))
- for fn, entries in self.env.indexentries.items():
+ domain = cast(IndexDomain, self.env.get_domain('index'))
+ for fn, entries in domain.entries.items():
# new entry types must be listed in directives/other.py!
for type, value, tid, main, index_key in entries:
try:
diff --git a/sphinx/environment/collectors/__init__.py b/sphinx/environment/collectors/__init__.py
index eb16a9f25..137a10302 100644
--- a/sphinx/environment/collectors/__init__.py
+++ b/sphinx/environment/collectors/__init__.py
@@ -12,9 +12,12 @@ from typing import Dict, List, Set
from docutils import nodes
-from sphinx.application import Sphinx
from sphinx.environment import BuildEnvironment
+if False:
+ # For type annotation
+ from sphinx.application import Sphinx
+
class EnvironmentCollector:
"""An EnvironmentCollector is a specific data collector from each document.
@@ -27,7 +30,7 @@ class EnvironmentCollector:
listener_ids = None # type: Dict[str, int]
- def enable(self, app: Sphinx) -> None:
+ def enable(self, app: "Sphinx") -> None:
assert self.listener_ids is None
self.listener_ids = {
'doctree-read': app.connect('doctree-read', self.process_doc),
@@ -37,38 +40,38 @@ class EnvironmentCollector:
'env-get-outdated': app.connect('env-get-outdated', self.get_outdated_docs),
}
- def disable(self, app: Sphinx) -> None:
+ def disable(self, app: "Sphinx") -> None:
assert self.listener_ids is not None
for listener_id in self.listener_ids.values():
app.disconnect(listener_id)
self.listener_ids = None
- def clear_doc(self, app: Sphinx, env: BuildEnvironment, docname: str) -> None:
+ def clear_doc(self, app: "Sphinx", env: BuildEnvironment, docname: str) -> None:
"""Remove specified data of a document.
This method is called on the removal of the document."""
raise NotImplementedError
- def merge_other(self, app: Sphinx, env: BuildEnvironment,
+ def merge_other(self, app: "Sphinx", env: BuildEnvironment,
docnames: Set[str], other: BuildEnvironment) -> None:
"""Merge in specified data regarding docnames from a different `BuildEnvironment`
object which coming from a subprocess in parallel builds."""
raise NotImplementedError
- def process_doc(self, app: Sphinx, doctree: nodes.document) -> None:
+ def process_doc(self, app: "Sphinx", doctree: nodes.document) -> None:
"""Process a document and gather specific data from it.
This method is called after the document is read."""
raise NotImplementedError
- def get_updated_docs(self, app: Sphinx, env: BuildEnvironment) -> List[str]:
+ def get_updated_docs(self, app: "Sphinx", env: BuildEnvironment) -> List[str]:
"""Return a list of docnames to re-read.
This methods is called after reading the whole of documents (experimental).
"""
return []
- def get_outdated_docs(self, app: Sphinx, env: BuildEnvironment,
+ def get_outdated_docs(self, app: "Sphinx", env: BuildEnvironment,
added: Set[str], changed: Set[str], removed: Set[str]) -> List[str]:
"""Return a list of docnames to re-read.