How to document python function parameter types?
There is a better way. We use
def my_method(x, y): """ my_method description @type x: int @param x: An integer @type y: int|string @param y: An integer or string @rtype: string @return: Returns a sentence with your variables in it """ return "Hello World! %s, %s" % (x,y)
That's it. In the PyCharm IDE this helps a lot. It works like a charm ;-)
You need to add an exclamation mark at the start of the Python docstring for Doxygen to parse it correctly.
def myMethod(self, name, image): """! Does something ... @param name String: name of the image @param image Image: instance of Image Class or a string indicating the filename. @return Return True if operation succeeded or False. """ return True
If using Python 3, you can use the function annotations described in PEP 3107.
def compile( source: "something compilable", filename: "where the compilable thing comes from", mode: "is this a single statement or a suite?"):
See also function definitions.