Crates.io | cargo-languagetool |
lib.rs | cargo-languagetool |
version | 0.4.2 |
source | src |
created_at | 2024-05-26 13:43:19.964406 |
updated_at | 2024-09-08 22:26:11.716587 |
description | A third-party cargo extension for checking grammar in the documentation and comments. |
homepage | https://github.com/rnbguy/cargo-languagetool |
repository | https://github.com/rnbguy/cargo-languagetool |
max_upload_size | |
id | 1252584 |
size | 85,732 |
cargo languagetool
[!WARNING]
The command is still at alpha stage. Do not expect too much.
Improve the quality of your documentation. Use correct English words and grammar, let anyone understand your documentation, allow anyone to use your code, and reduce the time people need to spend to know how the crate works and what it does. Good examples are necessary, but correct spelling and understandable explanations are worth no less.
This is a fork of cargo-grammarly
. Thanks to iddm
for their prior work.
Grammarly discontinued their developer API. So, I decided to switch to LanguageTool. LanguageTool is free, open-source and has a free public API.
cargo install --git https://github.com/rnbguy/cargo-languagetool
cargo languagetool
# or
cargo languagetool src/
$ cargo languagetool --help
A third-party cargo extension for checking grammar in the documentation and comments.
Usage: cargo languagetool [OPTIONS] [PATHS]...
Arguments:
[PATHS]... [default: .]
Options:
--hostname <HOSTNAME>
[env: LANGUAGETOOL_HOSTNAME=] [default: https://api.languagetoolplus.com]
-p, --port <PORT>
[env: LANGUAGETOOL_PORT=]
-u, --username <USERNAME>
[env: LANGUAGETOOL_USERNAME=]
-a, --api-key <API_KEY>
[env: LANGUAGETOOL_API_KEY=]
--disable-categories <DISABLE_CATEGORIES>
--enable-categories <ENABLE_CATEGORIES>
--disable-rules <DISABLE_RULES>
--enable-rules <ENABLE_RULES>
--enable-only
--language <LANGUAGE>
[default: en-US]
--picky
--no-cache
Disable cache query.
--show-all
Show all doc comments (even cached).
-h, --help
Print help
-V, --version
Print version
The utility works out of the box. However, if you want to use your
premium key, you may want to put it in the .env
file
or as an environment variable as:
LANGUAGETOOL_USERNAME=jane@doe.com
LANGUAGETOOL_API_KEY=1234abcd
If you would like to use your own server, you can put the server URL in the
.env
or as an environment variable as:
LANGUAGETOOL_HOSTNAME=http://localhost
LANGUAGETOOL_PORT=8010
[!TIP]
You can useltrs docker
(languagetool-rust
CLI) to launch a locallanguagetool
docker container.
The utility simply grabs all the doc comments (///
, //!
, #![doc = "text"]
and #[doc = "text"]
) from your crate's source code and sends it to the
languagetool
grammar checking API using the
languagetool-rust
crate. If there are any mistakes in
your texts, they are printed using the way the rustc
compiler prints its
warnings and errors, using the annotate-snippets
crate.
The doc comments are parsed using the syn
and proc_macro2
crates. These are
used specifically to know where in the code these comments are. Doing it with
regular expressions would waste a lot of time.