Is there a convenient way to document a C++ concept in doxygen? I would like to have some kind of documentation like this in the boost documentation.
From the Doxygen www site: "Doxygen is the de facto standard tool for generating documentation from annotated C++ sources, but it also supports other popular programming languages such as C, Objective-C, C#, PHP, Java, Python, IDL (Corba and Microsoft flavors), Fortran, VHDL, Tcl, and to some extent D."
Description. This is a command line tool that converts Doxygen generated XML files into markdown files (or JSON). You can use the generated Markdown files to create beautiful C++ documentation using with MkDocs, GitBook, VuePress, Hugo, Docsify, or any other static site generator that supports markdown.
How can I make doxygen ignore some code fragment? The new and easiest way is to add one comment block with a \cond command at the start and one comment block with a \endcond command at the end of the piece of code that should be ignored.
After some struggling with Doxygen, I finally came to the following solution.
Define a group for your concept: using pages is not that appropriate since a page should indicate its subpages (from top to bottom of the tree), while groups indicate potentially many parents groups. This allows:
Example
/*!@defgroup measurement_functor_concepts Measurement function objects
* @ingroup generalconcepts
* @{
* @par Description
* blablabla
*
* @par Notations
* Let @c F be the type of the function object, @c f an instance.
*
* @par Valid Expressions
* - @c f function object is ...
* - <b>f.result()</b> returns ...
* @}
*/
Define a custom command concept
with one argument:
ALIASES += concept{1}="@ingroup \1\n@par Implemented concepts:\n@ref \1"
The command:
Implemented concepts
providing a link to the implemented concept.Indicate that a particular class/struct implements the concept:
//!@brief Does things...
//!@concept{measurement_functor_concepts}
template <class T>
struct my_struct: public std::unary_function<T, void> {};
I did not find a way to generate a nice documentation like in Boost (nice tables for the valid expression, etc), but at least this organization of the documentation separates things properly.
What you can do is define a custom tag called Concept, which you can then use as you describe. An example of this is to use the alias mechanism in Doxygen, something like:
ALIASES += "con=\xrefitem con \"Concept\" \"Concepts\" "
You can use \tparam
to comment/document on template parameters.
I currently use separate manual pages to document concepts and group the with \section
and \subsection
. I can then link to them with \ref
. This works as long as you describe concepts with tables as in the link you gave, but unfortunately will not enable links to single sections.
I also have an alias to create a list of concepts that a type models.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With