| 1 |
try: |
| 2 |
# For Python 3.8 and later |
| 3 |
import importlib.metadata as importlib_metadata |
| 4 |
except ImportError: |
| 5 |
# For everyone else |
| 6 |
import importlib_metadata |
| 7 |
|
| 8 |
from sphinx.util import logging |
| 9 |
|
| 10 |
from . import asset, builder, directive, domain |
| 11 |
|
| 12 |
logger = logging.getLogger(__name__) |
| 13 |
|
| 14 |
|
| 15 |
def setup(app): |
| 16 |
version = importlib_metadata.version('sphinxcontrib-spelling') |
| 17 |
logger.info('Initializing Spelling Checker %s', version) |
| 18 |
app.add_builder(builder.SpellingBuilder) |
| 19 |
# Register the 'spelling' directive for setting parameters within |
| 20 |
# a document |
| 21 |
app.add_directive('spelling', directive.LegacySpellingDirective) |
| 22 |
app.add_domain(domain.SpellingDomain) |
| 23 |
# Register an environment collector to merge data gathered by the |
| 24 |
# directive in parallel builds |
| 25 |
app.add_env_collector(asset.SpellingCollector) |
| 26 |
# Report guesses about correct spelling |
| 27 |
app.add_config_value('spelling_show_suggestions', False, 'env') |
| 28 |
# Limit the number of suggestions output |
| 29 |
app.add_config_value('spelling_suggestion_limit', 0, 'env') |
| 30 |
# Report the whole line that has the error |
| 31 |
app.add_config_value('spelling_show_whole_line', True, 'env') |
| 32 |
# Emit misspelling as a sphinx warning instead of info message |
| 33 |
app.add_config_value('spelling_warning', False, 'env') |
| 34 |
# Set the language for the text |
| 35 |
app.add_config_value('spelling_lang', 'en_US', 'env') |
| 36 |
# Set the language for the tokenizer |
| 37 |
app.add_config_value('tokenizer_lang', 'en_US', 'env') |
| 38 |
# Set a user-provided list of words known to be spelled properly |
| 39 |
app.add_config_value('spelling_word_list_filename', None, 'env') |
| 40 |
# Assume anything that looks like a PyPI package name is spelled properly |
| 41 |
app.add_config_value('spelling_ignore_pypi_package_names', False, 'env') |
| 42 |
# Assume words that look like wiki page names are spelled properly |
| 43 |
app.add_config_value('spelling_ignore_wiki_words', True, 'env') |
| 44 |
# Assume words that are all caps, or all caps with trailing s, are |
| 45 |
# spelled properly |
| 46 |
app.add_config_value('spelling_ignore_acronyms', True, 'env') |
| 47 |
# Assume words that are part of __builtins__ are spelled properly |
| 48 |
app.add_config_value('spelling_ignore_python_builtins', True, 'env') |
| 49 |
# Assume words that look like the names of importable modules are |
| 50 |
# spelled properly |
| 51 |
app.add_config_value('spelling_ignore_importable_modules', True, 'env') |
| 52 |
# Treat contributor names from git history as spelled correctly |
| 53 |
app.add_config_value('spelling_ignore_contributor_names', True, 'env') |
| 54 |
# Add any user-defined filter classes |
| 55 |
app.add_config_value('spelling_filters', [], 'env') |
| 56 |
# Set a user-provided list of files to ignore |
| 57 |
app.add_config_value('spelling_exclude_patterns', [], 'env') |
| 58 |
# Choose whether or not the misspelled output should be displayed |
| 59 |
# in the terminal |
| 60 |
app.add_config_value('spelling_verbose', True, 'env') |
| 61 |
return { |
| 62 |
"parallel_read_safe": True, |
| 63 |
"parallel_write_safe": True, |
| 64 |
"version": version, |
| 65 |
} |