Skip to content

Commit

Permalink
Treat Python console snippets as rst
Browse files Browse the repository at this point in the history
Docstrings that have console snippets embedded like:
```
"""
    Return the argument.

    >>> o = object()
"""
```

Render much nicer if parsed as RST.
  • Loading branch information
zsol committed Jun 1, 2024
1 parent 33668b6 commit fbfb2a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions py_wtf/indexer/documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
r"|(::\n)" # literal blocks
r"|((^|\n)\.\. )" # definitions
r"|([^`]``[^`]+``[^`])" # inline literal
r"|((^|\n)>>> )" # python console snippet
)


Expand Down
7 changes: 7 additions & 0 deletions tests/indexer/test_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ def test_is_rst() -> None:
"""
)
assert is_rst("hello\n.. foo:\nbar")
assert is_rst(">>> 1+1")
assert is_rst(
"""foo bar
>>> print(1)
1
"""
)


def test_description_content_type_md() -> None:
Expand Down

0 comments on commit fbfb2a7

Please sign in to comment.