Skip to content

GoogleParser fails to parse multi-line parameter definitions correctly #97

Closed

Description

@coolbeevip

Test Case

def test_google_parser_multi_line_parameter_type() -> None:
    parser = GoogleParser()
    docstring = parser.parse(
        """Description of the function.

        Args:
            output_type (Literal["searchResults", "sourcedAnswer",
                "structured"]): The type of output. This can be one of the following:
                - "searchResults": Represents the search results.
                - "sourcedAnswer": Represents a sourced answer.
                - "structured": Represents a structured output format.

        Returns:
            bool: Indicates success or failure.

        """
    )
    assert docstring.params[0].arg_name == "output_type"

Output

docstring_parser/tests/test_google.py:45 (test_google_parser_multi_line_parameter_type)
'output_type (Literal["searchResults", "sourcedAnswer",\n        "structured"])' != 'output_type'

Expected :'output_type'
Actual   :'output_type (Literal["searchResults", "sourcedAnswer",\n        "structured"])'
<Click to see difference>

Root Cause

In the _build_meta method in docstring_parser/google.py, the code processes the desc (description) part after the colon to handle multi-line formatting, but it doesn't apply the same processing to the before part (parameter name and type) before the colon.

https://github.com/rr-/docstring_parser/blob/master/docstring_parser/google.py#L115-L123

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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