Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doxygen and git for automated file version information

Tags:

git

doxygen

is there a way to get information for Doxygen from git: For instance for:

@version
@author
@date 

The information should be automatically included in the Doxygen comments.

For @version it would be nice to get maybe the tag information.

Many thanks in advance!

like image 491
Stefan Avatar asked Feb 22 '12 10:02

Stefan


1 Answers

I realize this is an older question, but I was just trying to do the same thing.

Neither of the linked answers in the comments are a great solution to this issue. We may want to include e.g. a git revision in the generated documentation without mucking about with git filters and so forth in our working sources.

Fortunately, Doxygen supports the use of environment variables in your Doxyfile, and provides various settings that can be used to place information in your generated content. The PROJECT_NUMBER setting is meant explicitly for including version control information in your documentation.

If we have this in our Doxyfile:

PROJECT_NUMBER = $(PROJECT_NUMBER)

You can run doxygen like this to include the git revision in your generated docs:

PROJECT_NUMBER=$(git rev-parse --short HEAD) doxygen

You're not limited to just the commit id, either. For example:

PROJECT_NUMBER=$(git log -1 --format "%h (%cd)") doxygen

This makes the title in my generated HTML look like:

<div id="projectname">MyProject
&#160;<span id="projectnumber">9dd847b (Fri Feb 1 15:36:13 2019 -0500)</span>
</div>
like image 80
larsks Avatar answered Nov 15 '22 04:11

larsks