Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which docstring format should we use? #747

Open
stevepiercy opened this issue Nov 22, 2024 · 2 comments
Open

Which docstring format should we use? #747

stevepiercy opened this issue Nov 22, 2024 · 2 comments

Comments

@stevepiercy
Copy link
Member

stevepiercy commented Nov 22, 2024

First which docstring format should we use?

https://stackoverflow.com/a/24385103/2214933

I prefer Google style for its simplicity and adaptability.

Right now the docstrings don't render well.

https://icalendar.readthedocs.io/en/latest/api.html#icalendar.prop.vBoolean

Originally posted by @stevepiercy in #745 (comment)

@niccokunzmann
Copy link
Member

I like the simplicity of the Google format, too.
I would give the decision to those who want to do the docs in this way next.

def square_root(n):
    """Calculate the square root of a number.

    Args:
        n: the number to get the square root of.
    Returns:
        the square root of n.
    Raises:
        TypeError: if n is not a number.
        ValueError: if n is negative.

    """
    pass

@stevepiercy
Copy link
Member Author

We should add an example with a description and an arg with multiple lines. It's not clear where to add line breaks in the example.

I prefer the latter example where it is clear and consistent that indents are 4 spaces.

Documentation should also link to the Google Styleguide.

https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings

"""A one-line summary of the module or program, terminated by a period.

Leave one blank line.  The rest of this docstring should contain an
overall description of the module or program.  Optionally, it may also
contain a brief description of exported classes and functions and/or usage
examples.

Args:
    table_handle:
        An open ``smalltable.Table`` instance.
    keys:
        A sequence of strings representing the key of each table row to
        fetch.  String keys will be UTF-8 encoded.
    require_all_keys:
        If True only rows with values set for all keys will be returned.

Returns:
    A dict mapping keys to the corresponding table row data
    fetched. Each row is represented as a tuple of strings. For
    example:

    .. code-block:: python
    
        {b'Serak': ('Rigel VII', 'Preparer'),
        b'Zim': ('Irk', 'Invader'),
        b'Lrrr': ('Omicron Persei 8', 'Emperor')}

    Returned keys are always bytes.  If a key from the keys argument is
    missing from the dictionary, then that row was not found in the
    table (and require_all_keys must have been False).

Raises:
    IOError:
        An error occurred accessing the smalltable.

"""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants