Skip to content

Commit

Permalink
More fixes for sphinxcontrib.spelling 5.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
avylove committed Aug 13, 2020
1 parent ccf77ff commit 747f828
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
24 changes: 22 additions & 2 deletions setup_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@


RE_VERSION = re.compile(r'__version__\s*=\s*[\'\"](.+)[\'\"]$')
DIR_SPELLING = 'build/doc/spelling/'


def get_version(filename, encoding='utf8'):
Expand Down Expand Up @@ -63,7 +64,21 @@ def print_all_spelling_errors(path):
Print all spelling errors in the path
"""

return max(print_spelling_errors(os.path.join(path, filename)) for filename in os.listdir(path))
rtn = 0
for filename in os.listdir(path):
if print_spelling_errors(os.path.join(path, filename)):
rtn = 1

return rtn


def spelling_clean_dir(path):
"""
Remove spelling files from path
"""

for filename in os.listdir(path):
os.unlink(os.path.join(path, filename))


if __name__ == '__main__':
Expand All @@ -72,12 +87,17 @@ def print_all_spelling_errors(path):
if len(sys.argv) < 2:
sys.exit(0)

# Print misspelled word list
if sys.argv[1] == 'spelling-clean':
spelling_clean_dir(DIR_SPELLING)
sys.exit(0)

# Print misspelled word list
if sys.argv[1] == 'spelling':
if len(sys.argv) > 2:
sys.exit(print_spelling_errors(sys.argv[2]))
else:
sys.exit(print_all_spelling_errors('build/doc/spelling/'))
sys.exit(print_all_spelling_errors(DIR_SPELLING))

# Unknown option
else:
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ deps =
sphinx_rtd_theme

commands=
{envpython} setup_helpers.py spelling-clean
{envpython} setup.py spelling
{envpython} setup_helpers.py spelling
{envpython} setup.py html

0 comments on commit 747f828

Please sign in to comment.