diff --git a/src/tyro/_docstrings.py b/src/tyro/_docstrings.py index d020ba76..8e1107c1 100644 --- a/src/tyro/_docstrings.py +++ b/src/tyro/_docstrings.py @@ -364,8 +364,6 @@ def get_callable_description(f: Callable) -> str: if docstring is None: return "" - docstring = _strings.dedent(docstring) - if dataclasses.is_dataclass(f): default_doc = f.__name__ + str(inspect.signature(f)).replace(" -> None", "") # type: ignore if docstring == default_doc: @@ -373,11 +371,4 @@ def get_callable_description(f: Callable) -> str: import docstring_parser - parsed_docstring = docstring_parser.parse(docstring) - - parts: List[str] = [] - if parsed_docstring.short_description is not None: - parts.append(parsed_docstring.short_description) - if parsed_docstring.long_description is not None: - parts.append(parsed_docstring.long_description) - return "\n".join(parts) + return docstring_parser.parse(docstring).description diff --git a/tests/test_helptext.py b/tests/test_helptext.py index 92e271e7..64ea8a17 100644 --- a/tests/test_helptext.py +++ b/tests/test_helptext.py @@ -39,6 +39,22 @@ class Helptext: assert "Documentation 3 (default: 3)" in helptext +def test_helptext_paragraphs() -> None: + @dataclasses.dataclass + class Helptext: + """ + First + + Second + + Third + """ + + usage, *lines = get_helptext_with_checks(Helptext).split("\n") + assert usage.startswith("usage:") + assert lines[:7] == ["", "First", "", "Second", "", "Third", ""] + + def test_helptext_sphinx_autodoc_style() -> None: @dataclasses.dataclass class Helptext: