Skip to content

Commit

Permalink
Merge pull request #123 from 12rambau/master
Browse files Browse the repository at this point in the history
add a verbose parameter
  • Loading branch information
dhellmann authored Apr 30, 2021
2 parents 7612743 + 8a8e9b8 commit 29df599
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ ChangeLog
/.coverage
/.testrepository/
/cover/
.eggs/
28 changes: 28 additions & 0 deletions docs/source/customize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,29 @@ Input Options
=============

``spelling_lang='en_US'``

String specifying the language, as understood by PyEnchant and
enchant. Defaults to ``en_US`` for US English.

``tokenizer_lang='en_US'``

String specifying the tokenizer language as understood by PyEnchant
and enchant. Defaults to ``en_US`` for US English.

``spelling_word_list_filename='spelling_wordlist.txt'``

String specifying a file containing a list of words known to be
spelled correctly but that do not appear in the language dictionary
selected by ``spelling_lang``. The file should contain one word per
line. Refer to the `PyEnchant tutorial`_ for details. Use a list to add
multiple files.

``spelling_word_list_filename=['spelling_wordlist.txt','another_list.txt']``

Same as above, but with several files of correctly spelled words.

``spelling_exclude_patterns=['ignored_*']``

A list of glob-style patterns that should be ignored when checking spelling.
They are matched against the source file names relative to the source
directory, using slashes as directory separators on all platforms. See Sphinx's
Expand All @@ -41,10 +50,12 @@ Output Options
==============

``spelling_show_suggestions=False``

Boolean controlling whether suggestions for misspelled words are
printed. Defaults to False.

``spelling_show_whole_line=True``

Boolean controlling whether the contents of the line containing each
misspelled word is printed, for more context about the location of each
word. Defaults to True.
Expand All @@ -54,37 +65,54 @@ Output Options
Boolean controlling whether a misspelling is emitted as a sphinx
warning or as an info message. Defaults to False.

``spelling_verbose=True``

Choose whether or not the misspelled output should be displayed in the terminal. Defaults to True.

Word Filters
============

Enable or disable the built-in filters to control which words are
returned by the tokenizer to be checked.

``spelling_ignore_pypi_package_names=False``

Boolean controlling whether words that look like package names from
PyPI are treated as spelled properly. When ``True``, the current
list of package names is downloaded at the start of the build and
used to extend the list of known words in the dictionary. Defaults
to ``False``.

``spelling_ignore_wiki_words=True``

Boolean controlling whether words that follow the CamelCase
conventions used for page names in wikis should be treated as
spelled properly. Defaults to ``True``.

``spelling_ignore_acronyms=True``

Boolean controlling treatment of words that appear in all capital
letters, or all capital letters followed by a lower case ``s``. When
``True``, acronyms are assumed to be spelled properly. Defaults to
``True``.

``spelling_ignore_python_builtins=True``

Boolean controlling whether names built in to Python should be
treated as spelled properly. Defaults to ``True``.

``spelling_ignore_importable_modules=True``

Boolean controlling whether words that are names of modules found on
``sys.path`` are treated as spelled properly. Defaults to ``True``.

``spelling_ignore_contributor_names=True``

Boolean controlling whether contributor names taken from the git
history for the repository are considered as spelled correctly.

``spelling_filters=[]``

List of importable filter classes to be added to the tokenizer that
produces words to be checked. For example,
``["enchant.tokenize.MentionFilter"]``. The classes should be
Expand Down
11 changes: 5 additions & 6 deletions sphinxcontrib/spelling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ def setup(app):
# Set the language for the tokenizer
app.add_config_value('tokenizer_lang', 'en_US', 'env')
# Set a user-provided list of words known to be spelled properly
app.add_config_value('spelling_word_list_filename',
None,
'env')
app.add_config_value('spelling_word_list_filename', None, 'env')
# Assume anything that looks like a PyPI package name is spelled properly
app.add_config_value('spelling_ignore_pypi_package_names', False, 'env')
# Assume words that look like wiki page names are spelled properly
Expand All @@ -55,9 +53,10 @@ def setup(app):
# Add any user-defined filter classes
app.add_config_value('spelling_filters', [], 'env')
# Set a user-provided list of files to ignore
app.add_config_value('spelling_exclude_patterns',
[],
'env')
app.add_config_value('spelling_exclude_patterns', [], 'env')
# Choose whether or not the misspelled output should be displayed
# in the terminal
app.add_config_value('spelling_verbose', True, 'env')
return {
"parallel_read_safe": True,
"parallel_write_safe": True,
Expand Down
2 changes: 1 addition & 1 deletion sphinxcontrib/spelling/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def _find_misspellings(self, docname, doctree):
loc = (docname, lineno) if lineno else docname
if self.config.spelling_warning:
logger.warning(msg, location=loc)
else:
elif self.config.spelling_verbose:
logger.info(msg, location=loc)
yield "%s:%s: (%s) %s %s\n" % (
self.env.doc2path(docname, None),
Expand Down

0 comments on commit 29df599

Please sign in to comment.