Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Google style support #34

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

Merged
merged 8 commits into from
Oct 11, 2023
Merged

Conversation

staticf0x
Copy link
Contributor

@staticf0x staticf0x commented Oct 11, 2023

This PR adds basic support for google style docstrings.

Resources used:

Supported features

  • Function description, short and long
  • Arguments parsed into a list
  • Return values, raised exceptions, yields for generators
  • Example, note, todo blocks
  • Multiline argument descriptions
  • Indented argument descriptions
  • Inline markdown
  • Underscore escaping (__init__.py, __str__, ...)
  • RST-like links
  • Literal blocks
    • Same as with RST-like links

Example

Screenshot from Sublime Text 4 before this change:

before

and after with the support enabled:

after

This is the code used for this example:

def something(a: str) -> str:
    """Do **something**. But not __init__.py.

    Some longer description here, that's allowed.
    See ``Args`` in `self`.

    Args:
        a (str): some arg with type
                 with multiline
                 comment
        b:
            some arg without type
        *args: Yayaya
        **kwargs: dadada

    Returns:
        str: the same *stuff*

    Raises:
        ValueError: if something bad happens
                    but y'know
        KeyError: if something else equally bad happens

    Examples:
        Use it like this.

    Note:
        Do not use this function. Or https://github.com.

    Todo:
        * Not sure
        * Test
    """
    return a

Copy link
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @staticf0x

@krassowski krassowski merged commit a254a49 into python-lsp:main Oct 11, 2023
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

Successfully merging this pull request may close these issues.

2 participants