Doxygen: How to link to annotated source code?

Viewed 6253

I have a very simple example Main.cpp file for my library, and I have a tutorial page for it. The page looks something like this:

/**
 *  @page simpleexample Simple Example
 *
 *  This example shows basic use. It is in \ref simple_example/Main.cpp.
 *
 *  And this is the description of the example.
 */

Now what this does is it replaces the simple_example/Main.cpp reference by a link to that file documentation. I would like it to go directly to the annotated source code.

Is there a way to do it without entirely disabling the per-file documentation? I'd like to have it, but i don't like that people need to click the Main.cpp link and then also the Go to the source code of this file. link once inside. I don't care too much about how the links in the Files section behave, although I'd rather have them go to file documentation, as they do by default.

I don't want to include the source code inside the tutorial page using \example either, as it is already there in small parts which are explained individually.

3 Answers

I tried some of the possibilities and what worked for me was to create separate pages for the example code.

 /**
 *  @page simpleexample Simple Example
 *
 *  This example shows basic use. It is in \ref simple_example_main.
 *
 *  And this is the description of the example.
 *
 *  @page simple_example_main Main.cpp
 *
 *  \include simple_example/Main.cpp
 */

That would give you the output

This example shows basic use. It is in Main.cpp

Whereas I found the direct insertion of code from the \include command rather useful, as it allows you to insert more than one source per page, and have some floating text between the code files.

In order to get (any) example to work, you need to set the example path, in the example above it would probably be something like

EXAMPLE_PATH           = simple_example
EXAMPLE_PATTERNS       = *
EXAMPLE_RECURSIVE      = YES
Related