Debian Codegraph @

sphinxcontrib/spelling/asset.py

raw
1 #
2 # Copyright (c) 2020 Doug Hellmann. All rights reserved.
3 #
4 """Asset collector for additional spelling terms."""
5
6 import collections
7 import contextlib
8
9 from sphinx.environment.collectors import EnvironmentCollector
10 from sphinx.util import logging
11
12 logger = logging.getLogger(__name__)
13
14
15 class SpellingCollector(EnvironmentCollector):
16
17 def clear_doc(self, app, env, docname) -> None:
18 with contextlib.suppress(AttributeError, KeyError):
19 del env.spelling_document_words[docname]
20
21 def merge_other(self, app, env, docnames, other):
22 try:
23 other_words = other.spelling_document_words
24 except AttributeError:
25 other_words = {}
26
27 if not hasattr(env, 'spelling_document_words'):
28 env.spelling_document_words = collections.defaultdict(list)
29 env.spelling_document_words.update(other_words)
30
31 def process_doc(self, app, doctree):
32 pass