Closed aaren closed 9 years ago
beda4ba is a first attempt.
May need to think about what code block options mean in the context of ipython.
Also, what to do with figures? Ipython embeds figures in the .ipynb. I don't think we need to do that. My idea was more that you can switch to editing in the notebook if you want to.
I think it would be a good idea to output text and code but not execute code blocks. That way you could import the document using IPython notebook and let IPython handle running the code.
Pweb.weave goes like this:
def weave(self, shell="python"):
"""Weave the document, equals -> parse, run, format, write"""
if not self.isparsed:
self.parse()
self.run(shell)
self.format()
self.write()
So you'd have to disable the call to self.run
somehow.
How about passing shell as None
to trigger this? Wouldn't be hard to rewrite run to do this.
Then implement a command line switch to trigger the no run behaviour and make this default if the output format is a notebook.
what is tricky is that the processor and the formatter are linked
in Pweb.run
:
self.executed = runner.getresults()
and in Pweb.format
:
self.formatter.setexecuted(copy.deepcopy(self.executed))
The executed
comes from mapping _runcode
in the processor onto the list of
chunks.
We can avoid this by bypassing the call to the processor.
I think I'd rather have this functionality in Pweave-convert script, because its just converting the document to JSON and not running the code.
good point.
ignore dddfc89 and 560e105. I rebased over them. Not sure how to get github to stop referencing them.
Can you make a pull request with the correct version? And send me an example that I can test it with?
There is a test file in the pull request.
Hey all. I'm really interested in this feature and was wondering what the status was for integrating this PR into master?
Thanks!
Hi :). Glad someone might find it useful.
I was a bit busy, hence the slowness in writing it up. I think there is a good deal of improvement that could be done, so I wouldn't consider this a stable interface. It is a proof of concept though.
Have you tried out my branch? This really needs documenting, but maybe you can work it out from the tests?
Hey you all. Thanks for the replies. I haven't been able to test out the branch, however, wanted to ask about the status of this project in general? I think we've lost momentum here, but there seems to be quite a bit of momentum, here: https://github.com/paulgb/runipy
Thoughts? :)
@nehalecky If you want to create notebooks from markdown have a look at notedown, which I made recently. I'm open to ideas on new features, but the core is taking markdown and turning it into an IPython notebook.
@aaren, wow, thanks for the tip. Don't know know I missed it until now. Nice library, I am going to look at it more closely when I have time. Thank you so much! :clap:!
This is now merged to master. Sorry for the delay.
There are currently these output formats:
A really powerful addition would be an IPython notebook formatter. Then docs written in markdown could be converted to notebooks.
I don't think it would be too hard, as the IPython notebook is just a JSON.