This is pretty cool.
For one of my projects, I tried something similar where I had code blocks in README.md like:
Usage
-----
`pip install bar` and import `foo`:
```python
import foo from bar
```
Run `foo.alice` with default arguments:
```python
foo.alice()
```
Run `foo.bob` while specifying `baz`:
```python
foo.bob(baz=0)
```
And a Makefile like: .PHONY: demo
demo: venv
@. .venv/bin/activate; sed -n '/^```python/,/^```/p' < README.md | sed '/^```/d' | python
.PHONY: venv
venv: .venv/bin/activate requirements.txt
@. .venv/bin/activate; pip install -qU pip
@. .venv/bin/activate; pip install -qUr requirements.txt
.venv/bin/activate:
@python3 -m venv .venv
So you could run all those README.md code blocks with: make demo