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

Idea: spellcheck as part of the tests? #118

Closed
carols10cents opened this issue Jun 28, 2016 · 9 comments
Closed

Idea: spellcheck as part of the tests? #118

carols10cents opened this issue Jun 28, 2016 · 9 comments
Milestone

Comments

@carols10cents
Copy link
Member

Maybe this is more work than it's worth, considering that we'd need to ignore code blocks and add words like "enum" to whatever dictionary that gets used, buuuut it's a thought I had that I wanted to see what other people thought.

aspell suggests "enema" for "enum", btw.

@carols10cents carols10cents added this to the all milestone Jun 28, 2016
@steveklabnik
Copy link
Member

I like this idea!

@carols10cents
Copy link
Member Author

https://github.com/azerupi/mdBook/issues/141 is relevant to these interests!

@JIghtuse
Copy link
Contributor

JIghtuse commented Oct 9, 2016

So, in #275 I found a few spellings thanks to aspell.

Now I discovered a needed change to tell aspell about encodings of "personal dictionaries" it uses. It is now possible to generate a dictionary file with valid words (should be reviewed manually, but can be created only once and updated incrementally when new specific words appear) and then check book contents with global "language" dictionary and a personal one.

Here is a script to generate dictionary and check files if dictionary exists: https://gist.github.com/JIghtuse/0a92074f56007d2010396063aa221bf5#file-spellcheck-sh

And here is a current dictionary file for the book: https://gist.github.com/JIghtuse/0a92074f56007d2010396063aa221bf5#file-dictionary-txt

Would be glad to help integrating it into CI! 😸

@carols10cents
Copy link
Member Author

carols10cents commented Oct 9, 2016

That would be awesome!!!

I think the requirements for getting this into CI are:

  • If there are misspellings, the script should exit with a non-zero status, and hopefully print out what's misspelled so that we can fix them easily.
  • If there are not misspellings, the script should exit with a 0 status.
  • Add your script and dictionary to the repo, in the root is fine
  • Add the invocation of your script to .travis.yml, probably at the beginning of the script section, let's see how that feels

Bonus (optional) tasks, I can take care of these if you want:

  • Make a second PR that isn't meant to be merged that has a misspelling to test out the failure case
  • Add documentation to the README on how to set up and run aspell locally, and how to add words to the dictionary

Please let me know if any of this is unclear or if you get stuck with anything!

@JIghtuse
Copy link
Contributor

@carols10cents pretty clear, thanks! I'll try to make these changes asap.

JIghtuse added a commit to JIghtuse/book that referenced this issue Nov 24, 2016
JIghtuse added a commit to JIghtuse/book that referenced this issue Nov 24, 2016
@JIghtuse
Copy link
Contributor

Hey! I finally implemented it.

aspell can be weird at times! I've made a few workarounds.

  • I didn't found a way to show line number with typo. Solution: script uses grep to find it. Not a great solution due to possible false positives, but I don't know how to improve it for now.

  • aspell thinks it is fine to modify personal dictionary even if no errors was found. So dictionary passed to aspell cannot live in git. Solution: copy dictionary to /tmp and pass this path to aspell.

JIghtuse added a commit to JIghtuse/book that referenced this issue Nov 24, 2016
JIghtuse added a commit to JIghtuse/book that referenced this issue Nov 24, 2016
@JIghtuse
Copy link
Contributor

@carols10cents please look at the last three commits in https://github.com/JIghtuse/book/commits/master and if it is fine, I'll create a PR.

@JIghtuse
Copy link
Contributor

JIghtuse commented Nov 24, 2016

As an alternative, here is a python script doing the same checks: https://gist.github.com/JIghtuse/a059d63bf31b56c0e71ac03e69584f48

Code looks a bit clearer for me and doesn't have aspell quirks, but it generates a bit more false positives, so it is needed to extend dictionary with words like:

السلام
عليكم
שָׁלוֹם
Здравствуйте
नमस्ते
こんにちは

Also, there is no interactive mode like aspell provides, but probably this script is easier to maintain than proposed bash solution. What do you think?

@carols10cents
Copy link
Member Author

@JIghtuse the bash script solution looks fine to me!! I'm excited to see it in action-- open that PR! :)

JIghtuse added a commit to JIghtuse/book that referenced this issue Nov 28, 2016
JIghtuse added a commit to JIghtuse/book that referenced this issue Nov 28, 2016
JIghtuse added a commit to JIghtuse/book that referenced this issue Nov 28, 2016
JIghtuse added a commit to JIghtuse/book that referenced this issue Nov 28, 2016
JIghtuse added a commit to JIghtuse/book that referenced this issue Dec 1, 2016
JIghtuse added a commit to JIghtuse/book that referenced this issue Dec 1, 2016
amitu pushed a commit to FifthTry/rust-book that referenced this issue Jun 1, 2021
AbrarNitk pushed a commit to FifthTry/rust-book that referenced this issue Jun 2, 2021
ch13-04 の comprehensive を「包括的な」に
AbrarNitk pushed a commit to FifthTry/rust-book that referenced this issue Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants