Skip to content

Add a spell checker for libcore/libstd documentation #74697

Open
@jyn514

Description

@jyn514
Member

From #74141:

@pickfire: Did you go through this with some kind of type checkers like cargo-spellcheck?
@euclio: I made a super hacky custom rustdoc pass that ran a spellchecker over markdown compiled to plain text.

It would be great to have a tool that automated spell-checking for the docs. @pickfire suggested cargo spellcheck which had some trouble with bootstrap. Maybe we could somehow modify it to work with bootstrap so it runs as part of tidy?

Activity

added
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools
on Jul 23, 2020
pickfire

pickfire commented on Jul 24, 2020

@pickfire
Contributor

Maybe we should also ping the author here @drahnr. He may have some ideas?

drahnr

drahnr commented on Jul 24, 2020

@drahnr
Contributor

@pickfire @jyn514 glad to hear there is interest in using cargo-spellcheck!

The error you see is very most likely caused by an older version which had issues parsing args properly, note that I plan to release v0.3.0 is planned for this WE / early next week which should resolve quite a few issues.
In the meantime you could give yesterdays alpha.6 release a shot which should have the traversal + arg parse issues resolved (at least works in the CI https://ci.spearow.io/teams/main/pipelines/cargo-spellcheck/jobs/master-validate/builds/117 ) note that the garbled output for multiline comments is the biggest remaining topic for multiline comments in this alpha which will be fixed in v0.3.0

If there are specific issues I would be very happy to get things working for you :)

pickfire

pickfire commented on Jul 24, 2020

@pickfire
Contributor

It has a dependency on autotools and libtool which is unfortunate ... could we get them to avoid that somehow? -- @jyn514 #74141 (comment)

@drahnr What do you think?

drahnr

drahnr commented on Jul 24, 2020

@drahnr
Contributor

@drahnr What do you think?

@pickfire As @euclio already stated in #74141 (comment) - it should not be required anymore since v0.3.0-alpha.4 / c041dca66b966610d216ec23aeb4cf386adcf54a which incorporates the latest hunspell-sys which uses cc without any C-buildtools to create the static lib from hunspell source files, so that should be ☑️ if not please open a ticket :)

pickfire

pickfire commented on Jul 24, 2020

@pickfire
Contributor

It doesn't work and probably displayed the wrong error.

Error: Failed to parse manifest file /home/ivan/src/pickfire/rs/rust/src/bootstrap/Cargo.toml: No such file or directory (os error 2)
drahnr

drahnr commented on Jul 24, 2020

@drahnr
Contributor

@pickfire could you please open an issue with information on how to reproduce and commit sha / release so I can test / reproduce the issue?

drahnr

drahnr commented on Jul 27, 2020

@drahnr
Contributor

v0.3.0-beta.1 should resolve this and a few more issues with the rust lang code base, let me know if this is sufficient for the time being or if anything particular feature is badly needed.

pickfire

pickfire commented on Jul 28, 2020

@pickfire
Contributor

@drahnr I checked, a lot better but still not sufficient yet. Looks like UTF-8 handling still needs some tweak to make it work without panicking.

drahnr

drahnr commented on Jul 28, 2020

@drahnr
Contributor

Found the root cause, v0.3.0-beta.5 should do the trick 🎉

jyn514

jyn514 commented on Jul 28, 2020

@jyn514
MemberAuthor

I tried running it: it showed no output for ~three seconds then exited. With -vvvv I get the following output:

$ cargo spellcheck -vvvv
[2020-07-28T20:52:40Z WARN  cargo_spellcheck] Loading configuration from /home/joshua/.config/cargo_spellcheck/config.toml, due to: No such file or directory (os error 2)
[2020-07-28T20:52:40Z DEBUG cargo_spellcheck::traverse] Running on inputs ["/home/joshua/src/rust"] / recursive=true
[2020-07-28T20:52:40Z DEBUG cargo_spellcheck::traverse] Processing /home/joshua/src/rust -> /home/joshua/src/rust
[2020-07-28T20:52:40Z DEBUG cargo_spellcheck::traverse] Running on absolute dirs ["/home/joshua/src/rust"] 
[2020-07-28T20:52:40Z DEBUG cargo_spellcheck::traverse] Found a total of 1 files to check 
[2020-07-28T20:52:40Z DEBUG cargo_spellcheck::traverse] Failed to complete /home/joshua/src/rust/src/bootstrap/Cargo.toml from filesystem
[2020-07-28T20:52:40Z DEBUG cargo_spellcheck::traverse] Failed to complete /home/joshua/src/rust/src/rustc/Cargo.toml from filesystem
[2020-07-28T20:52:40Z DEBUG cargo_spellcheck::traverse] Failed to complete /home/joshua/src/rust/src/librustc_codegen_llvm/Cargo.toml from filesystem
[2020-07-28T20:52:40Z DEBUG cargo_spellcheck::traverse] Failed to complete /home/joshua/src/rust/src/tools/cargotest/Cargo.toml from filesystem
[2020-07-28T20:52:40Z DEBUG cargo_spellcheck::traverse] Failed to complete /home/joshua/src/rust/src/tools/error_index_generator/Cargo.toml from filesystem
[2020-07-28T20:52:40Z DEBUG cargo_spellcheck::traverse] Failed to complete /home/joshua/src/rust/src/tools/linkchecker/Cargo.toml from filesystem
[2020-07-28T20:52:40Z DEBUG cargo_spellcheck::traverse] Failed to complete /home/joshua/src/rust/src/tools/rust-demangler/Cargo.toml from filesystem
[2020-07-28T20:52:40Z DEBUG cargo_spellcheck::traverse] Failed to complete /home/joshua/src/rust/src/tools/rustdoc/Cargo.toml from filesystem
[2020-07-28T20:52:40Z DEBUG cargo_spellcheck::traverse] Failed to complete /home/joshua/src/rust/src/tools/rls/Cargo.toml from filesystem
[2020-07-28T20:52:40Z DEBUG cargo_spellcheck::traverse] Failed to complete /home/joshua/src/rust/src/tools/rustdoc-themes/Cargo.toml from filesystem
[2020-07-28T20:52:41Z DEBUG cargo_spellcheck::checker] Running Hunspell checks
[2020-07-28T20:52:41Z DEBUG cargo_spellcheck::checker::hunspell] Dictionary search path /usr/share/myspell/ is not a directory
[2020-07-28T20:52:41Z DEBUG cargo_spellcheck::checker::hunspell] Dictionary search path /usr/share/hunspell/ is not a directory
[2020-07-28T20:52:41Z DEBUG cargo_spellcheck::checker::hunspell] Dictionary search path /usr/share/myspell/dicts/ is not a directory

It looks like it's skipping almost all the directories? And not running checks on the ones that it did find, because the /usr/share/* paths weren't found? I would expect both of those to be warnings, not DEBUG logging.

I installed hunspell (with sudo apt install hunspell) and now it appears to at least be doing something:

error: spellcheck(Hunspell)
  --> /home/joshua/src/rust/src/tools/unicode-table-generator/src/skiplist.rs:7
   |
 7 |  This will get packed into a single u32 before inserting into the data set.
   |                                     ^^^
   |
   |
   |   Possible spelling mistake found.
   |

error: spellcheck(Hunspell)
   --> /home/joshua/src/rust/src/tools/unicode-table-generator/src/skiplist.rs:14
    |
 14 |  our largest sets are around ~1400 offsets long.
    |                              ^^^^^
    |
    |
    |   Possible spelling mistake found.
    |

However these warnings aren't particularly helpful - u32 is a builtin type and ~ is not a misspelling, it means approximation. @drahnr is there a way to add a whitelist of keywords or ignore symbols?

30 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-help-wantedCall for participation: Help is requested to fix this issue.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @drahnr@GuillaumeGomez@pickfire@jyn514@hkBst

        Issue actions

          Add a spell checker for libcore/libstd documentation · Issue #74697 · rust-lang/rust