Skip to content

Comments

Google style support#34

Merged
krassowski merged 8 commits intopython-lsp:mainfrom
staticf0x:google-style-support
Oct 11, 2023
Merged

Google style support#34
krassowski merged 8 commits intopython-lsp:mainfrom
staticf0x:google-style-support

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