# Doxygen code blocks

This topic is 4949 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

In my pseudo code blocks in comments ive been using <code> blocks and <br> for newlines. Is there any type of block I can use to preserve formatting (i.e tabs and newlines?). Google and Doxygen FAQ doesn't seem to have anything.

##### Share on other sites
IIRC, you can prefix every line with | or > and it'll work.

edit: my mistake, that's not available in Doxygen, I was thinking NaturalDocs, I don't know if Doxygen supports this, I'd say it seems that using HTML is the only way

##### Share on other sites
The Doxygen tags are @code/@endcode, e.g.
@code//This will appear in Doxygen documentation as a block of codeclass foo{};@endcode

There are also @verbatim/@endverbatim that give the text, including tabs and spaces verbatim, w/o code highlighting.

##### Share on other sites
Quote:
 Original post by CouvillionThe Doxygen tags are @code/@endcode, e.g.@code//This will appear in Doxygen documentation as a block of codeclass foo{};@endcodeThere are also @verbatim/@endverbatim that give the text, including tabs and spaces verbatim, w/o code highlighting.

namespace Xml{/**\brief Xml Element@code	Xml::Element child = root("Child");<br>	Xml::Element child = root();	for( ; child ; child = child.Sibling("Child"))<br>		//...	string name = child["name"];<br>	int age = child.Int("age");<br>	bool dead = child.Bool("isdead");@endcode*/class Element{    public:        //...    private:        //...};/**\brief Xml Document<code>	Xml::Document doc = "mydoc.xml";	Xml::Element root = doc();<br>	Xml::Element root = doc("Root");</code>*/class Document{    public:       //...    private:       //...};}

this is confusing. If I replace <code> with @code, like above it stops the whole namespace being parsed, and as such the class doesn't show up in the documentation. I think maybe I've done something wrong (it isn't used for this?). Thanks.

##### Share on other sites
Quote:
Original post by Genjix
Quote:
 Original post by CouvillionThe Doxygen tags are @code/@endcode, e.g.@code//This will appear in Doxygen documentation as a block of codeclass foo{};@endcodeThere are also @verbatim/@endverbatim that give the text, including tabs and spaces verbatim, w/o code highlighting.

*** Source Snippet Removed ***
this is confusing. If I replace <code> with @code, like above it stops the whole namespace being parsed, and as such the class doesn't show up in the documentation. I think maybe I've done something wrong (it isn't used for this?). Thanks.

@code and @endcode have to be on separate lines. To make a single word appear as code in Doxygen, use something like this:

/**  The word @c class is shown as code, or at least in a typewriter font.*/

Also, you can use a "\" instead of "@".

##### Share on other sites
most useful. Thank you.

1. 1
2. 2
3. 3
Rutin
22
4. 4
frob
17
5. 5

• 9
• 33
• 13
• 13
• 10
• ### Forum Statistics

• Total Topics
632580
• Total Posts
3007194

×