Search code examples
pythonpycharmdocstringepytext

In docstring, how to give multiple parameters the same description (using EpyText tags)?


For IDEs where hovering over a function call displays help (e.g. PyCharm), rather than create multiple lines with the same description for multiple parameters ... is there a way to simplify by tagging multiple parameters to use the same description?

So instead of this (using EpyText tags) ...

def myfunc(a, b, c, d):
    """
    @param a: integer along the "a" dimension.  
    @param b: integer along the "b" dimension.  
    @param c: integer along the "c" dimension.  
    @param d: integer along the "d" dimension.
    """
    pass

... would like something like this (which doesn't render) ...

def myfunc(a, b, c, d):
    """
    @param a,b,c,d: integer along the corresponding dimension.  
    """
    pass

In the ideal solution not only would there be efficiency of code but also of display (in the rendered help balloon). That is, all parameters sharing a description would also be listed on the same line (of the balloon text) and have the shared description shown only once.

Alternatives to EpyText can be considered as well.


Solution

  • Epytext doesn't support that, but the NumPy style supports grouping parameters with the same type and description:

    def myfunc(a, b, c, d):
        """
        Parameters
        ----------
        a, b, c, d : int
            Integer along the corresponding dimension.
        """
        pass