Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reprextest module like doctest #16

Open
jayqi opened this issue Feb 20, 2021 · 1 comment
Open

reprextest module like doctest #16

jayqi opened this issue Feb 20, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@jayqi
Copy link
Owner

jayqi commented Feb 20, 2021

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.

@jayqi jayqi added the enhancement New feature or request label Feb 20, 2021
@pjbull
Copy link

pjbull commented Mar 13, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants