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
Class %hierarchy
and graphiz %%dot
magics
#1854
Conversation
%hierarchy magic draws class hierarchy of a given class or class of a given instance. It relies on Sphinx's inheritance_diagram extension.
It's great to see people making creative use of the magic system, but this does raise a question about how much we want to ship as part of IPython. We do have an extension system, and my inclination is that this belongs as a separate extension. Others may disagree, though. Your concerns:
|
Can these magic commands go into IPython? I will fix what you suggested if it is likely. I think drawing class hierarchy is pretty general so having it in IPython is good. |
I've posted on the mailing list about it, and how we can make it easier to find third party extensions. We'll see if anyone else weighs in. My own feeling is that it would be best to do this as a separate extension for now, so that you can easily work on it and make more frequent updates than IPython's release schedule. Installing an extension is very simple with the |
Thanks. Yea, maybe it should be a separate extension. |
I am probably +1 on these being separate extensions. But we are discussing on the list where such extensions should be hosted. |
The feeling on the list is that you can use gist.github.com to host extensions (or, of course, set up a regular repository on Github/Bitbucket/etc.). Then we can list them in an index - I've set up a draft here: http://wiki.ipython.org/Extensions_Index The conversation's still going on on the mailing list, so feel free to join in. http://mail.scipy.org/mailman/listinfo/ipython-dev |
I changed them into a separate extension. |
Great, thanks. We'll keep you updated on anything we decide about extensions in the future. Would you like to add the extension to the index? It's a wiki, so just create an account and edit the page, adding a section like that for physics. |
Thanks for the mention. I edited the page. |
Thanks. Can I suggest that you manipulate the screenshot in an image editor to put the two cells side by side? That would make better use of the space on the page. |
I just removed the screenshot. I thought it was small enough. Maybe I will put the side-by-side one sometime later. |
I think it's OK to include screenshots, I was just thinking that there's width to spare, while we don't want to make people scroll too much. |
(Not that there's much need to scroll, but I hope one day we'll have 100 extensions on that page ;-) ) |
This PR introduces two magics.
First magic is
%hierarchy
. This magic command draws hierarchy of given class or the class of given instance. For example, the following shows class hierarchy of currently running IPython shell.Second magic is
%%dot
. You can write graphiz dot language in a cell using this magic. Example:I have two concerns:
run_dot
, which runs thedot
command to produce the figure, is heavily borrowed from Sphinx extension. I am not sure if there are any copyright problem.self.shell.display_formatter.format
to get "full path" (something likeIPython.zmq.zmqshell.ZMQInteractiveShell
) of a class. Maybe there is a better way to do that.