sphinx-autorun
sphinx-autorun copied to clipboard
Remember objects created in previous blocks?
First off, thanks for maintaining this package. Wonderful work!
I have docs that have code example interspersed with text. It might look like this:
Subsetting Ranges
=================
There are many ways to subset a PyRanges object. Each returns a new PyRanges object and does not change the old one.
.. runblock:: pycon
>>> import pandas as pd
>>> import pyranges as pr
>>> gr = pr.load_dataset("chipseq")
Chromosome only
~~~~~~~~~~~~~~~
.. runblock:: pycon
>>> import pandas as pd # ignore
>>> import pyranges as pr # ignore
>>> gr = pr.load_dataset("chipseq") # ignore
>>> gr["chrX"]
Is there a way to let me reuse the object gr
in the second pycon block? I can use the #ignore hack, but it would be nice to be able to avoid it.
I'm not entirely sure how to implement this yet, but it sounds like a useful feature. I'd definitely accept a PR for this. :stuck_out_tongue:
I'll try to look into it soon, but I can't commit to anything for now.
Only just came across this extension but from a stackoverflow question that then points to a now old fork which claims to do this.