How to show the code snippet that is commented with Doxygen? - doxygen

Is is possible to show the source code being commented with Doxygen?
I have tried the following:
if (u[index] == ']') /**< Detailed description after the member */
and only got the following result:
< Detailed description after the member
Is there any way to force Doxygen to show the code snippet along with the comment?

If you want to show a code snippet and not from the source code itself, use #code, #endcode to enclose a code snippet within the class/method documentation.

No, but you can configure doxygen to include a source browser that contains the code, and put links from the generated documentation to the source code.

Related

Generate link to relevant line of source code

I have documented my code with doxygen. The generated docs consist of:
a page with the documentation as I put between /** ... */, and
a page with the source-code itself (without the documentation between /** ... */).
Now my question is: Is there a way to generate links such that one can reach the page with the source code opened on the relevant line directly from the documentation?
To show visually what I would like to obtain:
I would like to have a button "Go to source" (shown in red, decorated with an arrow just for here).
Which would land me on the right line of the source code (possibly with a highlight, as shown here).
The following option does exactly that:
SOURCE_BROWSER = YES
Thanks #albert!

Remove line-though comments in VS Code

I am writing API doc comments and would like to include code examples in a comment block with comments included in this same block. I have change the font color for the block comments themselves but not for the comments in the comment.
Is there a way to edit the colors/text-decorations of these? I find it too dark and difficult to read. This happens with every theme I have installed.
This is not related to VS Code, you can highlight an example of the code usage using JSDoc tags. In your instance you're looking for #example:
/**
* #example
* myFunc('calling my func');
*/
function myFunc(args) {
}
And you will see your code sample highlighted in VS Code:

Doxygen: extract specific doxygen defines into separate documentaion

I have some source code (STM32 Peripherial Lib) with existing doxygen parameters which my Doxygen Builds without Problems.
For my project I want to generate a document with all functions in each file and a specific information which I want to add to the functions. But I want to keep the old informations for another doxygen configuration.
Is that possible?
I already added this for testing:
\ifnot "SECTION_DEFINE"
<normal Doxygen Parameters from original Source Code>
\elsif "SECTION_DEFINE"
#brief Function Check TODO
\endif
With this I could deactivate the existing documentation, but I need to write this \ifnot \elsif \endif to every function.
Can I just declare a Tag and only generate the documentation for this specific tag?
Kind regards
Andi
You may create a "related page" where only your additional information will be displayed with the \xrefitem command. As \xrefitem will also create a special text section within your original documentation you may want to combine it with your original idea of using section labels and conditional documentation. To top this concept off, use aliases in order to make your documentation more readable.
Consider this example code:
/** ST documentation
* foobar
* \exclusive for andi's function \endif
*/
void andreas(void);
/** ST documentation
* foobar
* \exclusive for beni's function \endif
*/
void benjamin(void);
You may use this alias in your Doxyfile: exclusive=\if SECTION_DEFINE \xrefitem viparea "Exclusive" "VIPs".
As long as SECTION_DEFINE is not defined, the "exclusive" information will not be included in your documentation. As soon as this section is defined, a "related page" (here: viparea.html) is created in your HTML documentation containing your documented items (here: andreas and benjamin) with the exclusive paragraph behind the command. The result:

doxygen auto reference external links?

I use some external libraries in my project, e.g. libev.
I realize I can use markdown (or href) and put
[libev](http://software.schmorp.de/pkg/libev.html)
in my document.
However that only works in a single place, and I don't want to have to put that in the dozens of places I refer to libev.
If it's "ClientWatcher" (one of my classes), doxygen auto links to the class.
Is there some way to tell doxygen to make all occurrences of the word "libev" auto link to http://software.schmorp.de/pkg/libev.html (for example)
If you add
ALIASES += libev="libev"
to Doxygen's configuration file you can use the \libev command to generate a link, like so
/** #mainpage
* See \libev for more info.
*/

Doxygen #link to a URL doesn't generate the link correctly

I have added this to a class comment:
#link http://www.google.com Google #endlink
However, when I generate documentation using doxygen, the link text is indeed "Google", but the link is to:
file:///media/portable/Examples/Doxygen/link/html/classClass1.html
Can anyone explain what is going wrong?
I think you are using \link incorrectly. From the doxygen documentation, \link is used to refer to objects like a file, class or member and takes a reference to one of these as its first argument. For example, if I wanted to refer to a class method func in the class myClass, I would use
\link myClass::func link text ... \endlink
with all of the remaining arguments considered to be text for a link. I think your problem is that you do not pass a valid object as the first argument. I would guess that classClass1 is the next object in the file where you tried to include the link and this is what the \link command is refering to.
Linking to URLs
Doxygen will generate URL links automatically, so there is no need to surround the link with \link and \endlink or any other commands. So remove those and see if that fixes the problem.
To manually specify link text, use the HTML 'a' tag:
link text
For more information about how doxygen handles automatic linking see this documentation page.