Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom tags with Doxygen

Tags:

doxygen

I am trying to figure out if there is a way to create a custom tag using Doxygen. I did find the ALIAS configuration file option but that does not do exactly what I need. Basically in my code I want to be able to write something like

/// \req Requirement #322 - blah blah 

And then have Doxygen create a list like it does for \bug and \todo commands for lines that have this custom tag. Is this possible with Doxygen?

like image 596
RishiD Avatar asked Feb 11 '09 14:02

RishiD


People also ask

What are doxygen tags?

Doxytag is a small command line based utility. It can generate tag files. These tag files can be used with doxygen to generate references to external documentation (i.e. documentation not contained in the input files that are used by doxygen).

How use doxygen HTML?

To use Doxygen, you simply comment your source code in a syntax that Doxygen can read. Doxygen then walks through your source files and creates HTML or LaTeX documentation based on those special comments.

Does doxygen work with C #?

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, Microsoft, and UNO/OpenOffice flavors), Fortran, and to some extent D.


2 Answers

The generalization of \bug and \todo is \xrefitem.

The solution I suggest is:

  • in Doxyfile:

    ALIASES += "req=\xrefitem req \"Requirement\" \"Requirements\" " 
  • in documented code:

    /// \req #42 - The system shall work in any situation 
like image 165
mouviciel Avatar answered Oct 13 '22 01:10

mouviciel


Thanks mouviciel! I have adopted your solution and extended it for my purposes.

The text below goes into my Doxyfile:

ALIASES += req{1}="\ref SRTX_\1 \"SRTX-\1\" " ALIASES += satisfy{1}="\xrefitem satisfy \"Satisfies requirement\" \"Requirement Implementation\" \1" ALIASES += verify{1}="\xrefitem verify \"Verifies requirement\" \"Requirement Verification\" \1" 

Where SRTX is the name of my project and is used as a prefix to requirements.

Then I create a file called Requirements.dox that provides a link between the requirement id and a URL for the requirement in my requirements management tool (an issue tracker in my case).

/** @page Requirements  @section Build1  @anchor SRTX_1113 <a href="https://foo.bar.com/mantis/view.php?id=1113">SRTX-1113</a>  @anchor SRTX_1114 <a href="https://foo.bar.com/mantis/view.php?id=1114">SRTX-1114</a>  */ 

One could also put the text of the requirement in the anchor tag if you didn't need to link to an external source.

In my code I have:

/**  * This is the basic executive that schedules processes.  * @satisfy{@req{1114}}  */ class Scheduler: public Process {     ... } 

And in my tests I put:

/**  * Provide a number of tests for process scheduling.  * @verify{@req{1114}}  */ class Scheduler_ut : public CppUnit::TestFixture {     ... } 

This gives me related pages for Requirements, Requirements Implementation, and Requirements Verification. It also provides Satisfies requirement and Verifies requirements sections in the class description (or function -- wherever you put the tag).

like image 43
Daniel Avatar answered Oct 12 '22 23:10

Daniel