Erotemic / xdoctest

A rewrite of Python's builtin doctest module (with pytest plugin integration) with AST instead of REGEX.
Apache License 2.0
205 stars 12 forks source link

Add Lark backend #120

Open Erotemic opened 2 years ago

Erotemic commented 2 years ago

A Lark backend allows us to have a well defined grammar for parsing docstrings and extracting doctests.

It might not be faster than the current whatever-i-did-to-get-it-working approach. But mine may have edge cases that a proper grammar would not.

Something like:

start? docstring
doctest: indented(python, '>>>')
example_item: doctest
example_items: list(example_item)
args: "Args: " indented(args_items)
example: "Example: " indented(example_items)
ignore: "Ignore: " indented(text)
dockblock: args | example | ignore | benchmark | misc
docstring: text | docblock