0

I have a Python code, and I recently discovered Doxygen which generates the documentation automatically from the source code. If I understood correctly, to make the generated code well detected by Doxygen, the doc string should be like this :

def f(self, x, y):
    """!Compute the sum

    @param x first number
    @param y second number
    @return sum of x and y
    """
    return x + y

But with Vscode, the snippet, when I pointto this method, is no longer displayed correctly (cf Fig. 1)

When I enter the docstring in this format

"""Compute the sum

Parameters
----------
x : int
    first number
y : int
    second number

Returns
-------
    int
    sum of x and y
"""

it is correctly displayed in VScode (Fig. 2)

enter image description here enter image description here

But with this second method, Doxygen no longer recognizes the parameters, and in the generated HTML page, the docstring is just displayed in verbatim mode (like with three ` in markdown)

Is there a way to combine both ways? So that Doxygen correctly catches the parameters as well as VSCode?

3
  • Which version of doxygen are you using? did you have a look at the doxygen setting PYTHON_DOCSTRING = NO? Commented Apr 25 at 8:29
  • I did try that, but there it just converts this into markdown, and no longer lists the arguments in a pretty way (cf gist.github.com/user-attachments/assets/…) Commented Apr 25 at 8:37
  • Indeed as the x : int first parameter is not something understood by doxygen as being special (and I think in python / vscode there are also no checks on completeness as there would have been when using \param in a doxygen run.) Commented Apr 25 at 8:45

1 Answer 1

0

As mentioned in the documentation, there is also another way to document Python code using comments that start with "##" or "##<". So, your script might look somewhat like this

def f(self, x, y):
    ## Compute the sum

    # @param x first number
    # @param y second number
    # @return sum of x and y
    
    return x + y
Sign up to request clarification or add additional context in comments.

5 Comments

See my comment ate the original question.
This is the same problem as before : Doxygen works well, but vscode no longer recognizes the parameters
Do you have doxygen extension installed in vs code?
@NaveedAhmed which extension ? I have this one marketplace.visualstudio.com/items/?itemName=bbenoist.Doxygen, but is does not display correctly in VScode. Is there another extension ? I quickly looked at the list in the market, but without success yet...
In the left vertical bar VSCode, click the extensions icon and search for doxygen. You will get many options, just install the one you thing would work for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.