gopuml

package module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2021 License: MIT Imports: 4 Imported by: 0

README

Build Status Go Report Card Coverage Status

gopuml

gopuml is a CLI tool to compile Plant UML into images and links.

It has support for generating png, svg and txt output either as files or links. gopuml is built in golang and leverages plantuml.com to generate the output.

Example:

gopuml can convert this example text into an svg file or a link.

Plant UML
@startuml Example
Bob -> Alice : hello
@enduml
Generated SVG file

example.svg

https://www.plantuml.com/plantuml/svg/SYWkIImgAStDKN2jICmjo4dbSifFKj2rKt3CoKnELR1Io4ZDoSddSaZDIodDpG44003__m00

Table of Contents

Usage

Install

go install github.com/lonnblad/gopuml/cmd/gopuml@v0.2.0

Compiling UML

The command used to compile the Plant UML to different formats.

gopuml build [files]

To test the build feature in the gopuml repository:

gopuml build example/example.puml

Options
  • -f, --format

    The format to use when compiling the Plant UML, defaults to: svg.

    Supported formatters are:

    • png, will format the content as .png
    • svg, will format the content as .svg
    • txt, will format the content as .txt
  • --server

    The Server URL to use when the style used is link, defaults to: https://www.plantuml.com/plantuml.

  • --style

    The style to use when compiling the Plant UML, defaults to: file.

    Supported styles are:

    • file, will write the formatted content to a file
    • link, will write a link to the formatted content to stdout
    • out, will write the formatted content to stdout
Development Environment

gopuml supports running a local webserver which will automatically reload the rendered version of the Plant UML as they are updated

gopuml serve [files]

To test the serve feature in the gopuml repository:

gopuml serve example/example.puml

Options
  • -p, --port

The port to use to serve the HTML page, defaults to: 8080.

Examples

These examples can be found here.

example.puml

The source Plant UML.

@startuml Example
Bob -> Alice : hello
@enduml
Compile files
Compiles example.png.

gopuml build -f png example/example.puml

example.png

Compiles example.svg.

gopuml build -f svg example/example.puml

example.svg

Compiles example.txt.

gopuml build -f txt example/example.puml

     ┌───┐          ┌─────┐
     │Bob│          │Alice│
     └─┬─┘          └──┬──┘
       │    hello      │
       │──────────────>│
     ┌─┴─┐          ┌──┴──┐
     │Bob│          │Alice│
     └───┘          └─────┘

gopuml build -f png --style link example/example.puml

gopuml build -f svg --style link example/example.puml

gopuml build -f txt --style link example/example.puml

Documentation

Overview

Package gopuml have utility functions for compression and encoding according to: https://plantuml.com/text-encoding

Examples

An example where the raw content of a file is compressed and encoded.

rawContent, err := os.ReadFile(pumlFilepath)
...
compressed, err := gopuml.Deflate(rawContent)
...
encoded := gopuml.Encode(compressed)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deflate

func Deflate(input []byte) (_ []byte, err error)

Deflate will run the Deflate compression algorithm on the input.

func Encode

func Encode(input []byte) []byte

Encode will encode the input in a similar way as base64.

Types

This section is empty.

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL