sdbbs
sdbbs

Reputation: 5384

Documenting included header files in .c files with Doxygen comments?

I have noticed, that when using Doxygen to document a .c file, the list of includes in the given file is also included in the output, for instance:

https://agnix.sourceforge.net/documentation/api/bridge_8c.html

bridge_c_doxygen_page

Now, what I typically do, is include some general comments before a given "include block" ("intro comments"), and then some specific comments on the same line as the include line:

...
/*
* The following includes are required for 
* the code to compile:
*/

#include <stdio.h> // contains printf()
#include <netinet/in.h> // contains sockaddr_in
...

Is it possible to have these kinds of comments formatted for Doxygen, (either "intro comments", or "on same line" - hopefully both), such that I get them output in the final documentation for that .C file?

Essentially, for the above example, I'd get an output like this (screenshot is from manually hacked HTML, to get a mock-up of desired output):

bridge_c_doxygen_hacked

(I guess, this could be seen as a somewhat of a "literal programming" approach)

Upvotes: 1

Views: 1220

Answers (1)

Filippo
Filippo

Reputation: 126

If you want Doxygen recognizes a file to insert it in documentation, you should use

/** <- (this format is recognized by Doxygen)
 * @file    name_of_file.h
 * 
 * @brief   What is
 * 
 * @author  You
 * 
 * @date    03/01/2023
 * 
 * @par     Put the title of the paragraph
 * Write the content of the paragraph
 */

at the beginning of your header file (note: @file is mandatory).

Read also Doxygen guide

Upvotes: 1

Related Questions