Giter VIP home page Giter VIP logo

iplantuml's Introduction

image

What is it?

This Python package defines a PlantUML cell magic for IPython. It lets you generate UML diagrams as inline SVG in your notebook. I'll add embellishments as needed. But, for now, I just needed something that worked and existed as a package (in pypi).

I based my code on Steven Burke's plantuml gist.

Installation

First, install IPlantuml with pip.

pip install iplantuml

Then, install plantuml. On Debian based system you can install plantuml package. Otherwise you can download plantuml.jar and copy it to /usr/local/bin/plantuml.jar.

sudo apt install plantuml

Alternatively you can set a custom path for plantuml.jar during installation

git clone https://github.com/jbn/IPlantUML.git
cd IPlantUML
python setup.py install iplantuml --jarpath /my/custom/path/plantuml.jar

Usage

In Ipython, first,

import iplantuml

then, create a cell like,

%%plantuml --jar

@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml

The output will be the generated SVG UML diagram using the plantuml.jar on your local system. To utilise remote rendering on plantweb omit the --jar argument:

%%plantuml

@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml

By default, the magic removes the intermediate (tmp.uml) and target (tmp.svg) files. However, if you enter a name in the %%plantuml line, it retains both files of $name.uml and $name.svg. For example,

%%plantuml auth

@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
@enduml

generates and retains auth.uml and auth.svg.

iplantuml's People

Contributors

bitaxis avatar igrmk avatar jacobdr avatar jbn avatar nikolai-hlubek avatar ryancollingwood avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

iplantuml's Issues

Error when using "plantuml.jar"

Hello and thanks for a nice plugin. Have an issue when using "plantuml.jar".

From the code:

try:
    output = None
    if use_web:
        output = plantuml_web(uml_path)
    else:
        plantuml_path = os.path.abspath(args.plantuml_path or PLANTUMLPATH)
        plantuml_exec(uml_path, plantuml_path=plantuml_path)
    svg_name = output[0]
    return SVG(filename=svg_name)
finally:

When "use_web" is "false" the output variable will be "None" meaning that there will be an exception on line:

svg_name = output[0]

Suggests that the line above is changed to:

        output = plantuml_exec(uml_path, plantuml_path=plantuml_path)

Command "python setup.py egg_info" failed with error code 1

Hi,

maybe you can help - I get following error:

pip2 install iplantuml
Collecting iplantuml
  Using cached IPlantUML-0.0.3.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-wli4gI/iplantuml/setup.py", line 18
        print(line, end='')
                       ^
    SyntaxError: invalid syntax
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-wli4gI/iplantuml/

I have to use pip2 as I have python3 as well on my system.

Show PlantUML syntax errors properly

This package works great (and is simple) in colab.research.google.com (it's how I'm using it).

But, whenever there's a mistake in the PlantUML source, there's a traceback that is not useful, instead of a helpful error that PlantUML's server is giving.

For example, in the following cell, note is mistyped with a space in the middle: no te which is a syntax error:

%%plantuml

@startuml
Alice->Bob: Authentication Request
no te right of Bob: Bob thinks about it
Bob->Alice: Authentication Response
@enduml

If I try that on the PlantUML server, I see this info:

image

If I try it in colab, I get this:

---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
[<ipython-input-61-2db41d0c2e9c>](https://localhost:8080/#) in <module>()
----> 1 get_ipython().run_cell_magic('plantuml', '', '\n@startuml\nAlice->Bob: Authentication Request\nno te right of Bob: Bob thinks about it\nBob->Alice: Authentication Response\n@enduml')


4 frames
[/usr/lib/python3.7/subprocess.py](https://localhost:8080/#) in check_call(*popenargs, **kwargs)
    361         if cmd is None:
    362             cmd = popenargs[0]
--> 363         raise CalledProcessError(retcode, cmd)
    364     return 0
    365 


CalledProcessError: Command '['plantweb', '--format', 'auto', 'e7a6b5e9-9c57-49b2-9bde-1ae3e8bbadbd.uml']' returned non-zero exit status 1.

Add caching

If the PlantUML script is the same, there is no reason to refetch or send to the JVM. Add a decorator that caches if the script matches the last one.

Add the point event feature of SVG output

Hi,Since Plantuml original exported SVG support,so we could add hyperlink inside the UML rendering,could we change the SVG out put set up to support this features?
Thanks!

Conversion message from plantweb seems sent to the jupyter output

Hello,
I am trying to use plantuml in a jupyter notebook (jupyter 6.4.0). iplantuml process the Bob/Alice example fine but it also prints this message just before the svg output:

Writing output for /home/jf/gitCours/MCS_python/jupyter/ada01c00-65da-4b72-8c8d-df573196bc2d.uml to ada01c00-65da-4b72-8c8d-df573196bc2d.svg

It seems that this message is generated by plantweb, when I tested it in command line. I think that iplantuml should not forward this to the output, just the svg. No ?
Below the screenshot of my test.
Regards.
Capture d’écran du 2021-08-04 23-44-17

Documentation doesn't seem correct

This:

%%plantuml auth

gets an error.

This, on the other hand,

%%plantuml --jar 

@startuml auth
etc.

works, but, the image returned to the notebook by the magic is the temp name, not the given name, resulting in a file-not-found.

Using iplantuml 0.1.1 with jupyterlab 2.2.6 and Python 3.9.5.

It it possible to use Iplantuml for jupyter-lab?

when I import in my notebook I get:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-3db08b9b1ba5> in <module>
----> 1 import iplantuml

ModuleNotFoundError: No module named 'iplantuml'

IPlantUML 0.0.5 can't be installed #2381

pypi/warehouse#2381

Errors occured when pip install iplantuml.

Error 1: TypeError

C:\Users\Administrator>pip install iplantuml
Collecting iplantuml
Using cached IPlantUML-0.0.5.tar.gz
Building wheels for collected packages: iplantuml
....
....
File "c:\users\admini~1\appdata\local\temp\pip-build-fw7jij\iplantuml\setup.py", line 79, in initialize_options
super().initialize_options()
TypeError: super() takes at least 1 argument (0 given)

Error 2: no such option "--jarpath"

C:\Users\Administrator>pip install iplantuml --jarpath ./plantuml.jar

Usage:
pip install [options] [package-index-options] ...
pip install [options] -r [package-index-options] ...
pip install [options] [-e] ...
pip install [options] [-e] ...
pip install [options] <archive url/path> ...

no such option: --jarpath

plantweb --format auto file.txt fails to format AsciiMath / Latex

I copied this example from Math in PlantUML

@startuml
Bob -> Alice : Can you solve: <math>ax^2+bx+c=0</math>
Alice --> Bob: <math>x = (-b+-sqrt(b^2-4ac))/(2a)</math>
@enduml

to p.uml

In a JupyterLab notebook, I have this code cell

%%bash
plantweb --format auto p.uml

The generated p.svg does not shows beautiful math, it still shows the AsciiMath code:

p

But when I changed the code cell to

%%bash
plantweb --format png p.uml

the generated p.png looks beautifully formatted.
p

The --format auto and --format svg do not correctly format the AsciiMath and jLatexMath code.

no such option: --jarpath

following the README to specify a custom jar path on installation I get a 'no such option: --jarpath' error.

the command i used:

pip install iplantuml --jarpath /usr/local/bin/plantuml.jar

invalid command -plantuml'

Hello,
I have a problem with you'r command, i would like to change the path because i use windows10.
When i try "python setup.py install iplantuml --jarpath /my/custom/path/plantuml.jar" it's return me my command are invalid 'iplantuml" command ?
It's weird because i have clone with no problem the repo :/

image

Customization of PlantUML jar path (& Java binary?)

First, thanks for the good work! If find this extension to be a simple yet very useful example of the potential behind Jupyter :)

The current mechanism allowing path customization for the PlantUML .jar file uses an option passed to setup.py at install time. This precludes pip install iplantuml and seems unnecessarily unwieldy to me.

Why not use an age-old but customization-friendly environment variable for this purpose insead? Something like PLANTUML_JAR_FILE would do the trick.

Or maybe the java executable could even be part of the variable (like https://pypi.python.org/pypi/sphinxcontrib-plantuml does it) so it would be more PLANTUML_RUN_COMMAND.

The second option would be extra convenient in situations where the Java binary is not on the PATH. For example my Windows dev box has no JRE installed, but a version of it is bundled with PyCharm: I'd rather not have its java.exe on the PATH but wouldn't mind using it for the specific purpose of running PlantUML, just as the plantuml4idea plugin runs it inside PyCharm (I am fully aware, however, that this is a matter of convenience and consider the ability to customize this of lesser importance than customizing the .jar path).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.