本文介绍了有没有办法在不更改CSS的情况下使doxygen显示枚举数值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在doxygen输出中获取枚举成员的真实值。
例如,我有:

I want to get the real value of the enum member in the doxygen output.For instance I have:

///MyEnum
typedef enum My_Enum
{
MY_ENUM_0,///<MY_ENUM_0
MY_ENUM_1,///<MY_ENUM_1
MY_ENUM_2 ///<MY_ENUM_2
} My_Enum;

输出为:

MyEnum.
Enumerator:
MY_ENUM_0
      MY_ENUM_0.
MY_ENUM_1
      MY_ENUM_1.
MY_ENUM_2
      MY_ENUM_2.

我想要的是:

Enumerator:
MY_ENUM_0
          0 MY_ENUM_0.
MY_ENUM_1
          1 MY_ENUM_1.
MY_ENUM_2
          2 MY_ENUM_2.

或类似的东西。

推荐答案

我无法想到直接从doxygen做到这一点的方法。 Doxygen不是C编译器。因此,它不会得出枚举值,它是一个编译时常量。

There isn't a way to do this directly from doxygen that I can think of. Doxygen is not a C compiler. So it will not derive the value of an enum which is a compile-time constant.

doxygen可以做的最接近的事情是,因为它确实具有C预处理程序。因此,如果您为通过预处理器扩展派生的常量分配了一些值,则doxygen可以扩展宏并向您显示将要分配的内容。

The closest thing doxygen can do is selectively expand your macros since it does have a C preprocesor. So if you have some value assigned to a constant that is derived by preprocessor expansion, doxygen can expand the macros and show you what will be assigned.

基于TheCodeArtist的答案,您可能会考虑编写在doxygen之前运行的脚本,复制文件,然后搜索此模式:

Building on TheCodeArtist's answer, you might consider writing script that runs prior to doxygen, makes copies of your files, searches for this pattern:

enum *** {
    ***, ///< %VAL%:

并将每次出现的%VAL%替换为应为的值不能手动跟上数字。在doxygen运行之后,将需要替换包含%VAL%标记的原始文件。那不是一个特别优雅或强大的解决方案。

and replaces each occurrence of %VAL% with what the value should be so you aren't manually keeping up with the numbers. After doxygen runs the original files which contain the %VAL% tokens would need to be replaced. That's not a particularly elegant or robust solution.

这篇关于有没有办法在不更改CSS的情况下使doxygen显示枚举数值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 03:46