reprextest module like doctest
Opened this issue · 1 comments
https://docs.python.org/3/library/doctest.html
The doctest module searches for pieces of text that look like interactive Python sessions, and then executes those sessions to verify that they work exactly as shown.
This is useful for making sure that documentation is up-to-date and that examples still work.
It would be cool to have something like this for reprexes.
I was thinking about this for .md
files in READMEs, etc.
Seems hard to back out of all of the possible formats (like HTML). But for markdown-like ones, what about a regex that looked for Python triple-tick fencing that contains at least one of the "output" indicators?
# Captured
```python
x = 1
y = 2
x+y
#> 3
```
# Not captured
```python
x = 1
y = 2
```
We could then loop over these matches to run reprexlite for each group and replace the old text with the new output.
Also thoughts on letting the scoped variables accumulate over the course of different blocks in the same document? Would be nice for README's, but it also means that each block is no longer a standalone reprex.