0

When I code in plain C there is quite a beautiful interaction between headers and c files in terms of documenting the code.

I tend to add the documentation on the cc files (and yes I am aware that most people prefare them in the headers), but by doing this my header is now a birds eye view of the cc file. I can, at a glance inspect large chunks of information about what is defined in the file.

For C++ classes this is even more useful, since I often want to see the private members of a class to give me an idea of what the class is meant to represent.

However if you start documenting every member within it, you now have large spacing between member variables filled with comments and no way to get a bird's eye view of the code.

What alternative could I use?

asked Oct 23, 2021 at 8:11
1
  • Any decent IDE or text editor will support code folding - that should give you the bird's eye view you're looking for. Commented Oct 23, 2021 at 17:48

1 Answer 1

3

Doxygen supports various ways to place your documentation comments, not just the big block before a declaration or definition.

Some ways to have documentation comments and keep your declarations together without intervening comment blocks are:

  • Use trailing documentation comments after (member) variables and/or enumerators:
    int var; /*!< Detailed description after the member */
    
  • Place the documentation for member functions with the out-of-class definition of the function
  • Use doxygen commands like \class, \fn or \var to link the comment block to the element it is documenting, rather than the placement of the comment block. For functions and variables, this has the drawback that you have to duplicate your declarations (once in the code and once in the comment block) and that it is not obvious if something has been documented or not.

Besides these options, many IDE's also have features to collapse various structures, like comment blocks, in such a way that they become unintrusive for looking at the actual code.

answered Oct 24, 2021 at 9:51

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.