Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
{
"metadata": {
"name": "",
"signature": "sha256:8cc04ebd48f148f0ed91ebc8e3dc05e795fdd5af1cf19d7c087a548c117182b8"
},
"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 committed to git repo to improve accessibility for all.\n"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%install_ext https://raw.githubusercontent.com/sberke/ipython-plantuml/master/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_magics"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 12
},
{
"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": 9,
"text": [
"['./plantuml.jar']"
]
}
],
"prompt_number": 9
},
{
"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": 13,
"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 0x1023b47d0>"
]
}
],
"prompt_number": 13
},
{
"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": [
"%install_ext http://raw.github.com/jrjohansson/version_information/master/version_information.py "
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Installed version_information.py. To use it, type:\n",
" %load_ext version_information\n"
]
}
],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%load_ext version_information\n",
"\n",
"%version_information jinja2,sphinx, pyzmq, pygments, tornado, nose, readline, gnureadline"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<table><tr><th>Software</th><th>Version</th></tr><tr><td>Python</td><td>2.7.1 64bit [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)]</td></tr><tr><td>IPython</td><td>2.3.0</td></tr><tr><td>OS</td><td>Darwin 11.4.2 x86_64 i386 64bit</td></tr><tr><td>jinja2</td><td>2.7.3</td></tr><tr><td>sphinx</td><td>1.2.3</td></tr><tr><td>pyzmq</td><td>14.4.0</td></tr><tr><td>pygments</td><td>1.6</td></tr><tr><td>tornado</td><td>4.0.2</td></tr><tr><td>nose</td><td>1.3.4</td></tr><tr><td>readline</td><td>6.2.4.1</td></tr><tr><td>gnureadline</td><td>6.3.3</td></tr><tr><td colspan='2'>Fri Oct 31 23:20:26 2014 PDT</td></tr></table>"
],
"json": [
"{\"Software versions\": [{\"version\": \"2.7.1 64bit [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)]\", \"module\": \"Python\"}, {\"version\": \"2.3.0\", \"module\": \"IPython\"}, {\"version\": \"Darwin 11.4.2 x86_64 i386 64bit\", \"module\": \"OS\"}, {\"version\": \"2.7.3\", \"module\": \"jinja2\"}, {\"version\": \"1.2.3\", \"module\": \"sphinx\"}, {\"version\": \"14.4.0\", \"module\": \"pyzmq\"}, {\"version\": \"1.6\", \"module\": \"pygments\"}, {\"version\": \"4.0.2\", \"module\": \"tornado\"}, {\"version\": \"1.3.4\", \"module\": \"nose\"}, {\"version\": \"6.2.4.1\", \"module\": \"readline\"}, {\"version\": \"6.3.3\", \"module\": \"gnureadline\"}]}"
],
"latex": [
"\\begin{tabular}{|l|l|}\\hline\n",
"{\\bf Software} & {\\bf Version} \\\\ \\hline\\hline\n",
"Python & 2.7.1 64bit [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] \\\\ \\hline\n",
"IPython & 2.3.0 \\\\ \\hline\n",
"OS & Darwin 11.4.2 x86\\_64 i386 64bit \\\\ \\hline\n",
"jinja2 & 2.7.3 \\\\ \\hline\n",
"sphinx & 1.2.3 \\\\ \\hline\n",
"pyzmq & 14.4.0 \\\\ \\hline\n",
"pygments & 1.6 \\\\ \\hline\n",
"tornado & 4.0.2 \\\\ \\hline\n",
"nose & 1.3.4 \\\\ \\hline\n",
"readline & 6.2.4.1 \\\\ \\hline\n",
"gnureadline & 6.3.3 \\\\ \\hline\n",
"\\hline \\multicolumn{2}{|l|}{Fri Oct 31 23:20:26 2014 PDT} \\\\ \\hline\n",
"\\end{tabular}\n"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 6,
"text": [
"Software versions\n",
"Python 2.7.1 64bit [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)]\n",
"IPython 2.3.0\n",
"OS Darwin 11.4.2 x86_64 i386 64bit\n",
"jinja2 2.7.3\n",
"sphinx 1.2.3\n",
"pyzmq 14.4.0\n",
"pygments 1.6\n",
"tornado 4.0.2\n",
"nose 1.3.4\n",
"readline 6.2.4.1\n",
"gnureadline 6.3.3\n",
"Fri Oct 31 23:20:26 2014 PDT"
]
}
],
"prompt_number": 6
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 6
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.