7
votes

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

2
Can you show how the above markup is embedded in a comment block or .md file?doxygen
I've added the complete file contents in the question.Patrick

2 Answers

13
votes

Try with \code

  \code{.cpp}
  class Cpp {};
  \endcode
3
votes

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