简体   繁体   中英

Documenting math formulas as comments in python code using Doxygen

my question is an extension of this one , and what i want is Doxygen to output the math formulas and text that are in the same comment line of my python source code. Let's take the following example:

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

When I run the above code, Doxygen outputs the correct math formula , as expected. However, if I add some text before the 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

The output is not as expected. Does anyone know how to fix this?

输出不符合预期

While trying other several combinations, I found out that Doxygen outputs the correct comment if the text is after the math formula, as follows:

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

PS: I also found it strange that supposedly Doxygen can't process math formulas on Python, as stated on the documentation (specifically in here ). Is the documentation out of date?

I tried with doxygen 1.8.18 the following code:

## \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

with default doxygen configuration settings, this results in:

在此处输入图像描述

This looks all OK to me the doc strings with """! are seen as doxygen comments and with just """ are seen as verbatim / code (as also shown in the mentioned link in the question).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM