Doxygen 和 git 用于自动获取文件版本信息

发布于 2025-01-07 14:18:30 字数 181 浏览 2 评论 0原文

有没有办法从 git 获取 Doxygen 的信息: 例如:

@version
@author
@date 

信息应自动包含在 Doxygen 注释中。

对于 @version 来说,获得标签信息可能会很不错。

非常感谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

菩提树下叶撕阳。 2025-01-14 14:18:30

我意识到这是一个较老的问题,但我只是想做同样的事情。

评论中的链接答案都不是解决此问题的好方法。我们可能希望在生成文档中包含例如 git 修订版,而无需在我们的工作源中使用 git 过滤器等。

幸运的是,Doxygen 支持在 Doxyfile 中使用环境变量,并提供各种可用于将信息放入生成的内容中的设置。 PROJECT_NUMBER 设置明确用于在文档中包含版本控制信息。

如果我们的 Doxyfile 中有这个:

PROJECT_NUMBER = $(PROJECT_NUMBER)

您可以像这样运行 doxygen 以在生成的文档中包含 git 修订版:

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

您也不仅限于提交 ID 。例如:

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

这使得我生成的 HTML 中的标题看起来像:

<div id="projectname">MyProject
 <span id="projectnumber">9dd847b (Fri Feb 1 15:36:13 2019 -0500)</span>
</div>

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
 <span id="projectnumber">9dd847b (Fri Feb 1 15:36:13 2019 -0500)</span>
</div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文