SpellingCI: No more spelling mistakes in your markdown flies!

Inakos
Inakos
Feb 14, 2017 · 4 min read
Image for post
Image for post

Spelling CI / Sheldon

You probably know the feeling…

…when you fix a very important issue in that “super cool” open-source project. You keep all your attention to those parts of the code where your changes could affect something, you run the tests until you can confirm: “It is fixed now, I am sure”; but then again, you run all the tests again up until, as the brave developer you are, you click the “open pull request” button. You are happy because you know the problem is fixed, everyone is going to love you… but a reviewer appears and rejects your changes because, on the documentation, you wrote “wihle” instead of “while”. Damn!

Image for post
Image for post

You have to pay as much attention to your documentation as to your code, but when English is not your mother tongue, you will definitely have to spend time improving your grammar and spelling. If your problems have to do with grammar, sorry man, but you’ll have to continue studying… But if they are related to spelling, here at we developed a tool to help you out with that…

Sheldon

Image for post
Image for post

Sheldon is a simple Erlang Application for spell checking. You can find it . Its API accepts a text (iodata() for Erlangers) and checks all the words. If sheldon doesn't understand a word it will try to help you with some suggestions. For suggestions we were inspired highly by the Elixir project .

Let’s try:

1> sheldon:start().
ok
2> sheldon:check("My name is Felipe and I am aware wrote wihle instead of while once").
#{bazinga => <<"Too bad, I'll have a virgin Cuba Libre.">>,
misspelled_words => [#{candidates => ["while","wile"],line_number => 1,word => "wihle"},
#{candidates => ["flipe","feline"],line_number => 1,word => "Felipe"}]}

Sheldon has detected our misspelled word ("wihle") and the line where it is; it also gave us some suggestions ("while" and "wile") and a bazinga message.

But wait! sheldon doesn't recognize my royal name ("Felipe"). I confess that the "feline" suggestion is cool too, but my parents wouldn't be happy if I switch it now. This is because sheldonworks with a dictionary and, as expected, it is impossible to have all the words there. We have 2 choices here: update the dictionary or escape the word. Let's escape!

sheldon gives you the possibility to escape some words like "Felipe" in this example. We only have to create a configuration map like this.

3> Config = #{ignore_words => ["Felipe"]}.
#{ignore_words => ["Felipe"]}
4> sheldon:check("My name is Felipe and I am aware wrote wihle instead of while once", Config).
#{bazinga => <<"Does it affect me? Then suffer in silence.">>,
misspelled_words => [#{candidates => ["while","wile"],line_number => 1,word => "wihle"}]}

Great, now “Felipe” is ignored.

That was a very simple example, but sheldon also provides the way to ignore patterns or blocks of code. For that you can check this .

But… what if one day we are the Pull Request Reviewers? How can we prevent someone from writing “wihle”, even if we think “wihle” is correctly spelled?

Spelling CI

At Inaka we also wrote . It is a continuous integration tool built on top of sheldon. Basically you must log in using your Github account and select the Github projects you want to check.

spellingci is only integrated with Github platform. It works for both public and private repositories.

By default, it will check the spelling for all the .md and .markdown files in your branch, but you can configure spellingci in order to check different ones or ignore some words, patterns, blocks of code… all through a configuration json file.

Every time sheldon finds a misspelled word, it will write a comment there with the suggested words.

Image for post
Image for post

Lovely, isn’t it?

Conclusion

As software developers, we tend to focus entirely on the code and sometimes we forget about the spelling. With sheldon and spellingci, at least we have help. For example, this blog is a Github repository, so now we are going to check our post with sheldon/spellingci

And remember: for grammar… keep studying!

Erlang Battleground

Strange and funny battle stories found while programming in…

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store