Typedef in a template class with Doxygen (C ++)

My question is how to comment on typedef in a template class with Doxygen. I will give an example to illustrate my question:

namespace fundamental { /** * Basic function */ template <typename T> class Base { public: T x; ///< x coordinate T y; ///< y coordinate }; typedef Base<float> Coordinate; ///< Point coordinate class } 

After using Doxygen to process the above codes, I can get an HTML page to show the definition of the Base class. However, for the typedef Coordinate command, it will not be displayed on the same page with the database. In fact, all typedef types are listed on the main page of the namespace along with all the classes in this namespace. I was wondering if it is possible to show the Coordinate class on a basic HTML page. Thus, the connection between the base and the coordinate will become much closer. Thank you

+8
c ++ doxygen
source share
6 answers

typedef is part of the namespace, so you must document the namespace to display it, i.e.:

 /// documentation for the namespace namespace fundamental { ... typedef Base<float> Coordinate; ///< Point coordinate class } 

Alternatively, you can use @relates , but this will cause the member to be associated with related functions of the base class:

 /// @relates Base /// Point coordinate class typedef Base<float> Coordinate; 

You can change this header to, for example, the members associated with it, by creating a layout file using doxygen -l , and then editing the two occurrences of the related element in the generated DoxygenLayout.xml as follows:

 <related title="Related Members"/> 
+5
source share

In the manual, I read the following:

Repeat this because it is often skipped: to document global objects (functions, typedefs, enum, macros, etc.) you must document the file in which they are defined. In other words, there must be at least <

/*! \file */ /*! \file */ or /** @file */ in this file.

+3
source share

There is also a link ( @sa ), useful for cross-referencing other objects.

+2
source share

You can also use the /sa command to manually place the link on the Base page.

 namespace fundamental { /** * Basic function * /sa Coordinate */ template <typename T> class Base { public: T x; ///< x coordinate T y; ///< y coordinate }; typedef Base<float> Coordinate; ///< Point coordinate class } 
+1
source share

Other answers will work, but if your typedef so closely related to the Base class that you want them to appear on the same Doxygen page, you may need to define a new namespace (within Fundamental ) that will include only Base and your typedef. Then doxygen will generate a page for namespace , which will include Base and your typedef.

A documentation definition for file will do the same, but it might be a more logical layout for your code.

0
source share

There are two other solutions to this problem. You can define groups using the @defgroup keyword and group the class and typedef type into one module. Another solution uses @relates

0
source share

All Articles