The case of returning multiple values (a tuple) at the same time in the google style docstring

A format seen on statckoverflow during the day (I can't find the original link):

def say_hello(name='world', age=2):
    """say hello to someone

    Say hello to the people who have the name you given.

    Args:
        name (str): The people's name you want to greet. world by default.
    
    Returns:
        tuple: tuple contains:
            name (str): name
            age (int): age

    """
    print(f"Hello {name}")
    return name, age

The effect of generating the document is as follows:
insert image description here
You can see that the two parameters are put into one line. I don’t know if there is any better solution. I will update it when I find it.

Case solved, case solved.
Just add a newline in the middle:

    Returns:
        tuple: tuple contains:
            name (str): name \n
            age (int): age

insert image description here

Guess you like

Origin blog.csdn.net/Crazy_zh/article/details/111706387