Oh interesting, I use a similar approach for my own github projects (e.g., mlxtend and biopandas), that is having parsers for docstring -> markdown -> static-html
In my experience so far, this works very well for
(1) having the examples inside the docstrings (e.g. useful if someone wants to check the documentation in an IDE, via help(func) in an interactive env, or func? in ipython).
(2) testing the examples (and the function to some extend as well) as part of the unit tests and continuous integration
(3) generating the markdown and html docs
But like you said, the problem with doctests to execute correctly would be that there might be some annoying overhead that is bad for readability -- on the other hands, users would have a working example that they could paste into an active session to experiment with it, and we'd be sure that the written example is correct and up to date with the current function implementation.
I am wondering though if it wouldn't be better to use the "doctest" syntax for the example section in the docstrings as it is commonly done. By that, I mean
>>> import tensorflow
>>> with tf.InteractiveSession():
>>> ... some code
This would make everything a bit easier and more natural to users of other packages like numpy, scipy, scikit-learn ... (plus it is easier to test it locally before committing without parsing the docstrings). On the other hand, the current docstring parser would need to be adjusted. But that should be pretty straight-forward, just putting an ``` in a line above the first `>>>` and adding a new line with ``` after the last `>>>`
What do you think?
Best,
Sebastian