Skip to main content
gamedev.net
🔒 Locked

Commentary extractor

Started by Eldritch 10 replies 800+ views
Original Post
Eldritch
Eldritch
Is there any way to quickly extract ALL comments from a C/CPP/H file??
SiCrane
SiCrane
Define "extract"? Do you mean remove all the comments in a file? Create a new file with just the comments from the old file? Create a web page based on the comments in a file?
Eldritch
Eldritch
Ok, I was a bit unclear, sorry for that :)

What I am looking for is something that can extract all comments from C/C++ files (either /* */ or // comments) and save them elsewhere, preferrably in HTML format, but any format is good enough.
Eldritch
Eldritch
Heh, well.. Doxygen is the program I am wishing not to use, since I would have to edit all my source comments, and I have a lot... to say the least ;) The program I need is one that would not require any special markup but would take the comments as they are.
ZQJ
ZQJ
Well, a simple lex program should be able to do it. My regular expression knowledge isn't great and I can't exactly remember some of the lex syntax, but google for flex/lex (and I'm sure somebody on here could knock out a solution in 30 seconds).
Zipster
Zipster
If you have access to a Unix shell, all you would need is grep:
grep // header.h source.c

Easily adaptable for old-school C-style comments as well.
Nitage
Nitage
It shouldn't be that hard to write one yourself that dumps plain text.

The only thing you'd need to watch out for are \ at the end of a line and //, */, /* in strings.
tolsen
tolsen
Maybe you should check out doc-o-matic (www.doc-o-matic.com).
Zipster
Zipster
A quick search also uncovered this handy applictation.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.