NOhs
NOhs

Reputation: 2830

How to insert the project name in a comment in doxygen?

I often use the project name in comments I write. However, up until now I hardcoded it. Now I realized that if the project name were to change, I would have to go through all the documentation parts and change it. Therefore, I wanted to ask if it is possible to simply reference the project name in the comment and let doxygen fill it out later.

/*! \brief This is the main function of the (project_name) project
*/
int main()
{
    return 0;
}

Upvotes: 2

Views: 2711

Answers (2)

StoneThrow
StoneThrow

Reputation: 6295

I know your question is from ages ago, and you've probably found an answer or moved on. But fwiw, I had a similar need and didn't find a direct answer here or at other similar Stack Overflow questions, so I'll offer what worked for me:

In my Doxygen comment block, the command \doxyconfig <config_option> is what did the trick.

E.g., my Doxyfile:

PROJECT_NAME = hello-world
PROJECT_NUMBER = 0.1.0

INPUT = "C:/dev/hello-world/src" 
INPUT += "C:/dev/hello-world/doc/mainpage.txt"

OUTPUT_DIRECTORY = "C:/dev/hello-world/doc"

OUTPUT_LANGUAGE = English

FILE_PATTERNS = *.c *.h
RECURSIVE = YES

...and my mainpage.txt, which you'll note is referenced as an INPUT value in the Doxyfile above:

/**
 * @mainpage Main page
 * This page is for project @doxyconfig PROJECT_NAME
 */

The resulting output in the HTML landing page:

This page is for project hello-world

Upvotes: 1

MattOnyx
MattOnyx

Reputation: 172

I think what you are looking for is environment variables, which you can read about here. The one you are looking for should be $(PROJECT_NAME). To use it, see this answer.

Upvotes: 1

Related Questions