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

demo mode #13

Open
jankatins opened this issue Nov 13, 2015 · 0 comments
Open

demo mode #13

jankatins opened this issue Nov 13, 2015 · 0 comments

Comments

@jankatins
Copy link
Member

R has the concept of a demo: https://stat.ethz.ch/R-manual/R-devel/library/utils/html/demo.html

It would be nice if we had a demo function, which would take a module/function and turn it into jupyter notebook cells:

from ipyext.demo import notebook_demo as demo # make it cristall clear that we only work in the notebook
import matplotlib.demo # something which isn't there yet :-)
demo(matplotlib.demo)
# shows available demos, as that's a module
demo(matplotlib.demo.gridspec)
# would add some cells below which are prefilled with examples how to use gridspec

Demo would:

  • make sure that the function takes no argument
  • get the source of a function and dedent it
  • split the source into blocks (code + comments with ^# Text -> comments with ^#text stay as comments in the code cell)
  • remove # from all comment lines
  • add the blocks to the notebook (see here for an example how to do that

Only problem when using functions: we can't use %magics in demos. Not sure if there is a workaround that, maybe treat #%magic ... as code, aka s/#%/%/ before splitting into blocks?

@jankatins jankatins mentioned this issue Nov 13, 2015
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant