17

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.

NullUserException
  • 83,810
  • 28
  • 209
  • 234
adf88
  • 4,277
  • 1
  • 23
  • 21
  • gedit has automatic spellchecking. It doesn't, as far as I know, parse only comments, but you could use the Find functionality to find each instance of `//`. Those will be highlighted so you can quickly see them. Not posted as answer because doesn't fully match your requirements. – Saladin Akara Sep 06 '10 at 17:27
  • 1
    I'd suggest the novel idea that you don't limit spell checking to the comments. Keep a project-specific dictionary, and add your global variable and function names to it after considering whether a correctly spelled word would be superior to an abbreviation. The first spell check pass over a major project can be a surprise, of course. – RBerteig Sep 06 '10 at 21:38
  • I didn't thought about this solution probably because of a huge amount of words. But actually it is reasonable to me! Post it as an answer and you'll get upvote from me. – adf88 Sep 07 '10 at 08:34
  • RBerteig: how this "project-specific dictionary" is supposed to be implemented? And do you mean each variable or function name should be kept in it, just like plain word from the comment? – mip Sep 08 '10 at 12:42
  • Yes, each (or almost each), at least I see it this way, otherwise it wouldn't have sense. This approach has some imperfection - particular in-comment mistakes can be omitted because of the word being considered as some identifier. Advantages? Well maybe a very little - sometimes it may be easier to finding misspelled identifiers i.e. after refactoring. – adf88 Sep 10 '10 at 06:04

3 Answers3

7

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.

dmckee --- ex-moderator kitten
  • 98,632
  • 24
  • 142
  • 234
2

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!

Louis Langholtz
  • 2,913
  • 3
  • 17
  • 40
0

A good place to check doxygen comments seems to be doxygen itself. But it doesn't check spelling :?.

Quick, workaround that comes to my mind which may work I think, is to generate LaTeX output and then use LaTeX for spell checking. Another solution might be use of doxygen's Perl Module output format and write some code in Perl for spell checking (with Aspell or Ispell for example).

With an IDE it's much simpler, because any decent IDE should support spell checking for doc-comments (Eclipse CDT is an example)

albert
  • 8,285
  • 3
  • 19
  • 32
mip
  • 8,355
  • 6
  • 53
  • 72