使用 Doxygen 在 python 代码中将数学公式记录为注释

Documenting math formulas as comments in python code using Doxygen

我的问题是 的扩展,我想要的是 Doxygen 输出与我的 python 源代码相同的注释行中的数学公式和文本。让我们举个例子:

# Create homogeneous probability matrix from the colors matrix
def create_probability_map(colors_map):
    """!\f$(x_1,y_1)\f$"""
    pass

当我 运行 上面的代码时,Doxygen 输出 correct math formula,如预期的那样。 但是,如果我在数学公式之前添加一些文本:

# Create homogeneous probability matrix from the colors matrix
def create_probability_map(colors_map):
    """Formula is: !\f$(x_1,y_1)\f$"""
    pass

输出不符合预期。 有人知道如何解决这个问题吗?

在尝试其他几种组合时,我发现如果文本在数学公式之后,Doxygen outputs 是正确的注释,如下所示:

# Create homogeneous probability matrix from the colors matrix
def create_probability_map(colors_map):
    """!\f$(x_1,y_1)\f$ is the formula"""
    pass

P.S:我还发现奇怪的是,据称 Doxygen 无法处理 Python 上的数学公式,如 documentation (specifically in here 中所述)。文档是否过时?

我尝试使用 doxygen 1.8.18 以下代码:

## \file

# Create homogeneous probability matrix from the colors matrix
def create_probability_map1(colors_map):
    """!\f$(x_1,y_1)\f$"""
    pass

# Create homogeneous probability matrix from the colors matrix
def create_probability_map2(colors_map):
    """Formula is: !\f$(x_2,y_2)\f$"""
    pass

# Create homogeneous probability matrix from the colors matrix
def create_probability_map3(colors_map):
    """!\f$(x_3,y_3)\f$ is the formula"""
    pass

# Create homogeneous probability matrix from the colors matrix
def create_probability_map4(colors_map):
    """!Formula is: \f$(x_4,y_4)\f$ is the formula"""
    pass

使用默认的 doxygen 配置设置,这会导致:

这对我来说看起来没问题,带有 """! 的文档字符串被视为 doxygen 注释,而带有 """ 的文档字符串被视为逐字/代码(如上述 [=22= 中所示) ] 在问题中)。