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

Integration into Jupyter notebook #2

Open
jhermann opened this issue Mar 7, 2020 · 5 comments
Open

Integration into Jupyter notebook #2

jhermann opened this issue Mar 7, 2020 · 5 comments

Comments

@jhermann
Copy link

jhermann commented Mar 7, 2020

Has anyone tried napkin in a notebook?

Not sure if it needs special integration code, or maybe some convenience additions…

@pinetr2e
Copy link
Owner

pinetr2e commented Mar 8, 2020

Using napkin in notebook will be great especially if there is already some supports for PlantUML.

Actually, I am not using notebook after I tried that quite long time ago. I might try notebook again soon.

@jhermann
Copy link
Author

jhermann commented Mar 8, 2020

@pinetr2e This might help to get you going in case you're using Debian platforms:
1and1/debianized-jupyterhub: ♃ Debian packaging of JupyterHub, a multi-user server for Jupyter notebooks

Or try it in a Docker container…

@pinetr2e
Copy link
Owner

pinetr2e commented Aug 16, 2020

Related to this issue, for the Emacs users, Org babel integration is now supported.
Please check https://github.com/pinetr2e/ob-napkin

@pleabargain
Copy link

Has anyone tried napkin in a notebook?

Not sure if it needs special integration code, or maybe some convenience additions…

I have
https://github.com/pleabargain/ipynb/blob/master/napkin_UML_test.ipynb

Not much joy.

It would be great to get a sample working on Colab!

@philipsd6
Copy link

You can do it like this:

import napkin
from IPython.display import Image

@napkin.seq_diagram()
def distributed_control(c):
    user = c.object("User")
    order = c.object("Order")
    orderLine = c.object("OrderLine")
    product = c.object("Product")
    customer = c.object("Customer")

    with user:
        with order.calculatePrice():
            with orderLine.calculatePrice():
                product.getPrice("quantity:number")
                with customer.getDiscountedValue(order):
                    order.getBaseValue().ret("value")
                    c.ret("discountedValue")

napkin.generate(output_format="plantuml_png", output_dir="/tmp")
Image(filename="/tmp/distributed_control.png")

It would definitely be nicer if napkin.generate() could just return an object that has the Jupyter _display_FMT methods to automatically display it.

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

No branches or pull requests

4 participants