Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux tool to check spelling of comments in c/c++ source code

What software do you suggest to check spelling of comments contained in c/c++ source code (especially doxygen comments)? I'm looking something that will parse only comments so I can easily find mistakes and correct them.

The question is general but to be more specific - I'm using CodeLite IDE.

like image 753
adf88 Avatar asked Sep 06 '10 17:09

adf88


People also ask

How do I spell check in Linux?

aspell command is used as a spell checker in Linux. Generally, it will scan the given files or anything from standard input then it check for misspellings. Finally it allows the user to correct the words interactively.

How do I spell check in Vim?

vim Spell checker Spell CheckingTo turn on the vim spell checker run :set spell . To turn it off run :set nospell . If you always want the spell checker to be on, add set spell to your vimrc. You can turn spelling on only for certain filetypes using an auto command.

How do I enable spell check in VS code?

Open up VS Code and hit F1 and type ext select install and type code-spell-checker hit enter and reload window to enable.


2 Answers

Emacs has ispell-comments-and-strings which works pretty well from inside the editor. It relies on the syntax highlighting mechanism to identify comments and strings, so it works with any language for which you have good highlighting.

No idea if how you make it work with your IDE.

like image 116
dmckee --- ex-moderator kitten Avatar answered Oct 13 '22 00:10

dmckee --- ex-moderator kitten


I needed something like this too. It needed to be able to run not only on Linux though.

I've seen that spell checking is often paired with an IDE (like with eclipse). I wanted a tool that was completely independent of any IDE however, because I wanted to be able to run it in automated/scripted contexts like Travis-CI builds or AppVeyor CI builds.

Looked around a little for such a tool and then decided to write my own.

What I came up with was pyspellcode which meets these needs. It's a python script that uses clang and hunspell which should readily run on Linux at least. The script:

  1. runs clang to get its AST dump output,
  2. reads through the AST info and finds the comment nodes,
  3. passes the words from those to hunspell for checking, and then
  4. reports back words that weren't recognized.

What was an interesting surprise for me is how deeply clang parses C++ comments even into doxygen elements and embedded HTML markup. This made it possible to use clang's AST to do things like ignore words nested within <code>...</code> blocks and I took advantage of that in the script.

The script's available from GitHub as a Zlib licensed open source project. It's just alpha software at the moment with at least one parsing bug in it but if there's interest in it, I'll give it more priority.

Hope this helps!

like image 41
Louis Langholtz Avatar answered Oct 13 '22 02:10

Louis Langholtz