Last active
December 9, 2020 01:46
-
-
Save sberke/bb90ff09193a8888d7f7 to your computer and use it in GitHub Desktop.
Demo of plantUML in ipython notebook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:12fe6177be926091299c51577d78556d3ae0d7e4887fc679494a522b5f281ba9" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Demo of the [plantuml](http://plantuml.sourceforge.net/) magics example posted on [stack overflow](http://stackoverflow.com/questions/20303335/ipython-notebook-plantuml-extension) to enable plantuml users to create inline UML diagrams.\n", | |
"\n", | |
"_note_ python module on original stack overflow post was published on gist to improve accessibility for all.\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"%install_ext https://gist.githubusercontent.com/sberke/7360a4b7aa79aefccbb0/raw/f19a8910c847421977daa7a8c893bb7d77aa78b5/plantuml_magics.py" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"Installed plantuml_magics.py. To use it, type:\n", | |
" %load_ext plantuml_magics\n" | |
] | |
} | |
], | |
"prompt_number": 1 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"%load_ext plantuml" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 2 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"For this example [plantuml.jar](http://sourceforge.net/projects/plantuml/files/plantuml.jar/download) is located in the current working directory." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"import glob\n", | |
"glob.glob(r'./*.jar')" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 3, | |
"text": [ | |
"['./plantuml.jar']" | |
] | |
} | |
], | |
"prompt_number": 3 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"%%plantuml figure1\n", | |
"\n", | |
"@startuml\n", | |
"Alice -> Bob: Authentication Request\n", | |
"Bob --> Alice: Authentication Response\n", | |
"@enduml " | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 4, | |
"svg": [ | |
"<svg height=\"155pt\" style=\"width:241px;height:155px;\" version=\"1.1\" viewBox=\"0 0 241 155\" width=\"241pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs><filter height=\"300%\" id=\"f1\" width=\"300%\" x=\"-1\" y=\"-1\"><feGaussianBlur result=\"blurOut\" stdDeviation=\"2.0\"/><feColorMatrix in=\"blurOut\" result=\"blurOut2\" type=\"matrix\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .4 0\"/><feOffset dx=\"4.0\" dy=\"4.0\" in=\"blurOut2\" result=\"blurOut3\"/><feBlend in=\"SourceGraphic\" in2=\"blurOut3\" mode=\"normal\"/></filter></defs><g><line style=\"stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;\" x1=\"33\" x2=\"33\" y1=\"38.4883\" y2=\"117.1094\"/><line style=\"stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;\" x1=\"214.5\" x2=\"214.5\" y1=\"38.4883\" y2=\"117.1094\"/><rect fill=\"#FEFECE\" filter=\"url(#f1)\" height=\"30.4883\" style=\"stroke: #A80036; stroke-width: 1.5;\" width=\"47\" x=\"8\" y=\"3\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacingAndGlyphs\" textLength=\"33\" x=\"15\" y=\"23.5352\">Alice</text><rect fill=\"#FEFECE\" filter=\"url(#f1)\" height=\"30.4883\" style=\"stroke: #A80036; stroke-width: 1.5;\" width=\"47\" x=\"8\" y=\"116.1094\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacingAndGlyphs\" textLength=\"33\" x=\"15\" y=\"136.6445\">Alice</text><rect fill=\"#FEFECE\" filter=\"url(#f1)\" height=\"30.4883\" style=\"stroke: #A80036; stroke-width: 1.5;\" width=\"40\" x=\"192.5\" y=\"3\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacingAndGlyphs\" textLength=\"26\" x=\"199.5\" y=\"23.5352\">Bob</text><rect fill=\"#FEFECE\" filter=\"url(#f1)\" height=\"30.4883\" style=\"stroke: #A80036; stroke-width: 1.5;\" width=\"40\" x=\"192.5\" y=\"116.1094\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"14\" lengthAdjust=\"spacingAndGlyphs\" textLength=\"26\" x=\"199.5\" y=\"136.6445\">Bob</text><polygon fill=\"#A80036\" points=\"202.5,65.4883,212.5,69.4883,202.5,73.4883,206.5,69.4883\" style=\"stroke: #A80036; stroke-width: 1.0;\"/><line style=\"stroke: #A80036; stroke-width: 1.0;\" x1=\"33.5\" x2=\"208.5\" y1=\"69.4883\" y2=\"69.4883\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"13\" lengthAdjust=\"spacingAndGlyphs\" textLength=\"147\" x=\"40.5\" y=\"65.0566\">Authentication Request</text><polygon fill=\"#A80036\" points=\"44.5,94.7988,34.5,98.7988,44.5,102.7988,40.5,98.7988\" style=\"stroke: #A80036; stroke-width: 1.0;\"/><line style=\"stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 2.0,2.0;\" x1=\"38.5\" x2=\"213.5\" y1=\"98.7988\" y2=\"98.7988\"/><text fill=\"#000000\" font-family=\"sans-serif\" font-size=\"13\" lengthAdjust=\"spacingAndGlyphs\" textLength=\"157\" x=\"50.5\" y=\"94.3672\">Authentication Response</text></g></svg>" | |
], | |
"text": [ | |
"<IPython.core.display.SVG at 0x10a4496d0>" | |
] | |
} | |
], | |
"prompt_number": 4 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"[@chickenbit](http://chickenbit.com/blog/2014/10/inline-plantuml-diagrams-in-ipython-notebook/)\n", | |
"\n", | |
"eol" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 4 | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment