Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add spelling_warning configuration option #116

Merged
merged 4 commits into from
Nov 5, 2020

Conversation

rscohn2
Copy link
Contributor

@rscohn2 rscohn2 commented Nov 5, 2020

Resolves #108

Adds a config option: spelling_warning that will emit misspellings as sphinx warning instead of info message. The sphinx warning format is better suited for IDE's that no how to parse error/warnings and automatically navigate to the file/line. Also, you can invoke sphinx with -q and still see warnings.

msg_parts.append(self.format_suggestions(suggestions))
msg_parts.append(context_line)
msg = ':'.join(msg_parts)
logger.info(msg)
if self.config.spelling_warning:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be less surprising to users if we have a consistent log format and only change the level of the log message based on the option. Does logger.info() accept the location argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I updated the PR. It makes the code simpler, too.

Here is an example with warning and -q. badlink is there to show what other warnings looks like:

rscohn2@rscohn1-MOBL:test$ sphinx-build -M spelling "source" "build" -q
/home/rscohn2/local/Projects/doc/test/source/index.rst:11: WARNING: Unknown target name: "badlink".
/home/rscohn2/local/Projects/doc/test/source/index.rst:9: WARNING: Spell check: sntence: Misspelling in a sntence.
WARNING: Found 1 misspelled words
rscohn2@rscohn1-MOBL:test$

Here is info and no -q:

rscohn2@rscohn1-MOBL:test$ sphinx-build -M spelling "source" "build"
Running Sphinx v3.3.0
Initializing Spelling Checker 7.0.3.dev2
making output directory... done
Ignoring wiki words
Ignoring acronyms
Ignoring Python builtins
Ignoring importable module names
Ignoring contributor names
Looking for custom word list in /home/rscohn2/local/Projects/doc/test/source/spelling_wordlist.txt
Scanning contributors
building [mo]: targets for 0 po files that are out of date
building [spelling]: all documents
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index

/home/rscohn2/local/Projects/doc/test/source/index.rst:11: WARNING: Unknown target name: "badlink".
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
/home/rscohn2/local/Projects/doc/test/source/index.rst:9: Spell check: sntence: Misspelling in a sntence.
Writing /home/rscohn2/local/Projects/doc/test/build/spelling/index.spelling

WARNING: Found 1 misspelled words
build succeeded, 2 warnings.
rscohn2@rscohn1-MOBL:test$

@dhellmann dhellmann merged commit 111866f into sphinx-contrib:master Nov 5, 2020
@dhellmann
Copy link
Member

Thanks! I'll work on a release to include this new feature soon.

@rscohn2
Copy link
Contributor Author

rscohn2 commented Nov 5, 2020 via email

@dhellmann
Copy link
Member

I have released this in https://pypi.org/project/sphinxcontrib-spelling/7.1.0/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

spelling and sphinx warning behavior differences
2 participants