Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add comments to fenced code block within doxygen documentation

I am using fenced code blocks in Doxygen using the markdown syntax. This makes it easy to add a simple code example, like this:

~~~~~{.cpp}
void doSomething()
   {
   }
~~~~~

When I try to add comments into the fenced code block using two forward slashes, Doxygen seems to remove the slashes. So when I write this:

~~~~~{.cpp}
void doSomething()
   {
   // This function should do something
   }
~~~~~

I get this output:

void doSomething()
   {
This function should do something
   }

How can I tell Doxygen to keep the comments in the fenced code block?

EDIT:

The complete file looks like this (we use the standard Doxygen extension of .dox for documentation-only files):

/*!
\page PATTERN_SAMPLE Sample

~~~~~{.cpp}
void doSomething()
   {
   // This function should do something
   }
~~~~~
*/

The result looks like this: Result

like image 772
Patrick Avatar asked Jul 02 '13 13:07

Patrick


People also ask

How do I add comments in doxygen?

To add a new Doxygen comment for a function simply generate it. Type /** , /*! , /// or //! and then press Enter . A stub will be generated for you in case your function has parameters, returns a value or throws an exception.

How do you write a doxygen comment?

Comment blocks in VHDLDoxygen will extract comments starting with "--!". There are only two types of comment blocks in VHDL; a one line "--!" comment representing a brief description, and a multi-line "--!" comment (where the "--!" prefix is repeated for each line) representing a detailed description.

How do I comment out a code in doxygen C++?

Once specified, you can generate the comment stub by typing the respective “///” or “/**” above a function, or by using the (Ctrl+/) shortcut.

What is @brief in doxygen?

Putting the command @brief will generate a short description of the function when you generate the doxygen documentation. That short description can be extended if you want. Follow this answer to receive notifications.


2 Answers

Try with \code

  \code{.cpp}
  class Cpp {};
  \endcode
like image 182
gammay Avatar answered Nov 25 '22 21:11

gammay


I encountered the same issue. No need to change code format. You can specify STRIP_CODE_COMMENTS as NO: this setting outputs the source code with the comment.

# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
# special comment blocks from generated source code fragments. Normal, C++ and
# Fortran comments will always remain visible.
# The default value is: YES.

STRIP_CODE_COMMENTS    = NO
like image 23
Addo Zhang Avatar answered Nov 25 '22 19:11

Addo Zhang