Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doxygen, too heavy to maintain? [closed]

I am currently starting using doxygen to document my source code. I have notice that the syntax is very heavy, every time I modify the source code, I also need to change the comment and I really have the impression to pass too much time modifying the comment for every change I make in the source code.

Do you have some tips to document my source code efficiently ?

Does some editor (or plugin for existing editor) for doxygen to do the following exist?

  • automatically track unsynchronized code/comment and warn the programmer about it.
  • automatically add doxygen comment format (template with parameter name in it for example) in the source code (template) for every new item

PS: I am working on a C/C++ project.

like image 417
Phong Avatar asked Mar 09 '10 09:03

Phong


People also ask

How long does doxygen take?

Doxygen takes about 12 hours to run on our code base. This is primarily because there is a lot of code to process (~1.5M lines).

How exclude code from doxygen?

How can I make doxygen ignore some code fragment? The new and easiest way is to add one comment block with a \cond command at the start and one comment block with a \endcond command at the end of the piece of code that should be ignored. This should be within the same file of course.

What does @{ mean in doxygen?

Doxygen will put members into the group whose definition has the highest "priority": e.g. An explicit \ingroup overrides an implicit grouping definition via @{ @} . Conflicting grouping definitions with the same priority trigger a warning, unless one definition was for a member without any explicit documentation.

Are doxygen commands case sensitive?

It is parsed by doxygen . The file may contain tabs and newlines for formatting purposes. The statements in the file are case-sensitive. Comments may be placed anywhere within the file (except within quotes). Comments begin with the # character and end at the end of the line.


2 Answers

Is it the Doxygen syntax you find difficult? Or is it the fact that you have to comment all of the functions now.

If it's the former, there may be a different tool that fits your coding style better. Keep in mind that Doxygen supports multiple commenting styles, so experiment until you find one you like.

If it's the latter, then tough it out. As a good programming practice, every public-facing function should have a comment header that explains:

  1. What the function does
  2. The parameters
  3. The return codes
  4. Any major warnings/limitations about the function.

This is true regardless of the documentation tool you use.

My big tip: Avoid the temptation to comment too much. Describe what you need, and no more. Doxygen gives you lots of tags, but you don't have to use them all.

  • You don't always need a @brief and a detailed description.
  • You don't need to put the function name in the comments.
  • You don't need to comment the function prototype AND implementation.
  • You don't need the file name at the top of every file.
  • You don't need a version history in the comments. (You're using a version control tool, right?)
  • You don't need a "last modified date" or similar.

As for your question: Doxygen has some configuration options to trigger warnings when the comments don't match the code. You can integrate this into your build process, and scan the Doxygen output for any warnings. This is the best way I have found to catch deviations in the code vs comments.

like image 198
myron-semack Avatar answered Oct 02 '22 17:10

myron-semack


I feel you get back what you put into comments, 5 minutes commenting a class well will in 3 months time when the class needs to be changed by someone else other than the original author (indeed sometimes by the original author) will take much less time to get to grips with.

I second the documentation support mentioned by David, in eclipse when you refactor parameter names it will rename the parameter in your docs section for example. I am not sure I would want it doing anything else automatically to be honest.

"every time I modify the source code, I also need to change the comment" Could be you're documenting too much. You should only have to change the documentation of a function if the change to it requires you to change every caller in some way (or if not actually change, at least check to make sure they weren't relying on obsolete behaviour), of if you're introducing new functionality that a new caller will rely on. So in theory it shouldn't be a massive overhead. Small changes, like optimizations and bugfixes within the function, usually don't need documenting.

like image 31
2 revs, 2 users 67% Avatar answered Oct 02 '22 18:10

2 revs, 2 users 67%