cargo-spellcheck
Check your spelling with hunspell
and/or languagetool
.
Usecase
Run cargo spellcheck --fix
or cargo spellcheck fix
to fix all your documentation comments
in order to avoid narsty types all over the place.
Meant as a helper simplifying review as well as possibly improving CI
after a learning phase for custom/topic specifc lingo.
cargo spellcheck
has a return code 1
if any unknown words are found, and 0
on success.
Test Cases
Check
Interactive fixing
Improvement requests tracked in issue #7.
Features
- Parse doc comments from arbitrary files
- Decent error printing
-
cargo-spellcheck check
- Spell checking using
hunspell
- Merge multiline doc comments
- Grammar check using
languagetool
http API - False positive reduction
- Follow module declarations rather than blindly recurse
- Be
markdown
aware- Handle doctests with
```rust
as virtual files skeptic-like - Verify all types of links: direct urls and href
- Handle doctests with
- Check
README.md
files -
cargo-spellcheck fix --interactive
- Improve interactive user interface with
crossterm
- Ellipsize overly long statements with
...
-
cargo-spellcheck fix
- Learn topic lingo and filter false-positive-suggestions when
fix --interactive
is passed - Handle cargo workspaces
- Re-wrap doc comments
- Word split validation
hunspell
and languagetool
are currently the two supported featuresets.
Configuration
# Linux: /home/alice/.config/cargo_spellcheck/config.toml
# Windows: C:\Users\Alice\AppData\Roaming\cargo_spellcheck\config.toml
# macOS: /Users/Alice/Library/Preferences/cargo_spellcheck/config.toml
[]
= "127.0.0.1:8010"
[]
# lang and name of `.dic` file
= "en_US"
# OS specific additives
# Linux: [ /usr/share/myspell ]
# Windows: []
# macOS [ /home/alice/Libraries/hunspell, /Libraries/hunspell ]
= []
= []
Installation
cargo install cargo-spellcheck
To increase verbosity use CARGO_SPELLCHECK=cargo_spellcheck=trace
to see internal details or
add -v
(multiple) to increase verbosity.
Hunspell
Requires the native library
# Fedora 30+
# Ubuntu 19.10+
# Mac OS X
and building should succeed just fine.
LanguageTool
Run a instance of the LanguageTool server i.e. as container .