Skip to main content

Generate PlantUML diagram code from Java class files

Project description

GenUML - Generate PlantUML from Java class files

PyPI Version Build Status Code Coverage

This tool aids in creating PlantUML class diagrams by generating UML diagrams from Java class files. Diagrams can be generated from single class files, or generated diagrams can be inserted into PlantUML code based on comments containing the correct "pattern".

$ genuml --help
Usage: genuml [OPTIONS] COMMAND [ARGS]...

  Generate PlantUML class diagram DSL from Java class files.

Options:
  --version
  --help     Show this message and exit.

Commands:
  generate  Generate PlantUML for single given Java class file.
  insert    Insert diagrams into PlantUML containing pattern comments.

Some functionality, as well as the generated diagram style, are based on ObjectAid UML Explorer, an Eclipse plug-in which seems to no longer be supported.

Example usage

genuml insert --class-dir "WEB-INF/classes" plantuml-diagram.puml \
    | java -jar plantuml.jar -pipe > diagram.png

Some explanation:

  • Compiled classes are found in WEB-INF/classes.
  • plantuml-diagram.puml contains PlantUML code as well as "pattern" comments referencing specific classes contained in the given folders (see example).
    • This file will be processed with the generated diagrams being placed directly after their pattern comments. Transformed output will be printed to stdout (and in this example, piped directly to PlantUML).
  • plantuml.jar has been downloaded to the local folder.

Example PlantUML with pattern comments

@startuml
skinparam linetype polyline

' Pattern comments that will be processed by GenUML:
'!gen_java tests.data.ExampleClass
'!gen_java tests.data.ExampleAbstract
'!gen_java tests.data.ExampleInterface
'!gen_java tests.data.ExampleEnum: LOW HIGH

ExampleInterface *-- ExampleClass : implements
ExampleClass .> "0..1" ExampleEnum
ExampleClass -> ExampleAbstract

@enduml

which could then be used to generate this diagram:

PlantUML class diagram

Installation

Install from PyPI

With Python 3 installed on your system, you can run:

pip install genuml

To test that installation worked, run:

genuml --help

and you can uninstall at any time with:

pip uninstall genuml

Install from Github

To install the newest code directly from Github:

pip install git+https://github.com/samuller/genuml

And uninstall remains the same:

pip uninstall genuml

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

genuml-0.6.1.tar.gz (7.6 kB view hashes)

Uploaded Source

Built Distribution

genuml-0.6.1-py3-none-any.whl (7.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page