Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Parsing of last RST params definition (incorrectly) includes rest-of-docs. #86

Copy link
Copy link
@thorwhalen

Description

@thorwhalen
Issue body actions

Consider this function:

def create_user(username: str, age: int = 20, is_active: bool = True) -> dict:
    """
    Creates a user with the given username, age, and activity status.

    Some more description here.
    Taking several lines.

    :param username: The username of the user.
    :type username: str
    :param age: The age of the user. Defaults to 20.
    :type age: int
    :param is_active: Indicates if the user is active. Defaults to True.
    :type is_active: bool
    :return: A dictionary representing the created user.
    :rtype: dict

    Example:

    >>> create_user("Alice", 25)
    {'username': 'Alice', 'age': 25, 'is_active': True}
    
    """
    return {"username": username, "age": age, "is_active": is_active}

from docstring_parser import parse

t = parse(create_user.__doc__)

The docs are valid RST docs, but are not parsed correctly.

Expected:

assert t.meta[-1].type_name == 'dict'}
assert t.many_returns[-1].type_name   == 'dict'

Actual:

assert t.meta[-1].type_name == 'dict\nExample:\n\n>>> create_user("Alice", 25)\n{\'username\': \'Alice\', \'age\': 25, \'is_active\': True}'
assert t.many_returns[-1].type_name   == 'dict\nExample:\n\n>>> create_user("Alice", 25)\n{\'username\': \'Alice\', \'age\': 25, \'is_active\': True}'
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.