View Source Plantuml.Encoding behaviour (Plantuml v0.1.1)

This module provides functions to encode/decode PlantUML's diagrams.

See PlantUML's Documentation on text encoding.

Link to this section Summary

Functions

Decodes an encoded diagram.

Encodes a diagram.

Link to this section Callbacks

@callback decode(encoded_diagram :: String.t()) :: decoded_diagram :: String.t()
@callback encode(diagram :: String.t()) :: encoded_diagram :: String.t()

Link to this section Functions

Link to this function

decode(encoded_diagram, opts \\ [])

View Source
@spec decode(encoded_diagram :: String.t(), opts :: keyword()) ::
  diagram :: String.t()

Decodes an encoded diagram.

options

Options

  • :method - the encoding method, can be either :deflate or :hex. Defaults to :deflate

examples

Examples

iex> Plantuml.Encoding.decode("Syp9J4vLqBLJSCfFib9mB2t9ICqhoKnEBCdCprC8IYqiJIqkuGBAAUW2rJY256DHLLoGdrUSoWK0")
"Alice -> Bob: Authentication Request\nBob --> Alice: Authentication Response\n"

iex> Plantuml.Encoding.decode("416C696365202D3E20426F623A2041757468656E7469636174696F6E20526571756573740A426F62202D2D3E20416C6963653A2041757468656E7469636174696F6E20526573706F6E73650A", method: :hex)
"Alice -> Bob: Authentication Request\nBob --> Alice: Authentication Response\n"
Link to this function

encode(diagram, opts \\ [])

View Source
@spec encode(diagram :: String.t(), opts :: keyword()) ::
  encoded_diagram :: String.t()

Encodes a diagram.

options

Options

  • :method - the encoding method, can be either :deflate or :hex. Defaults to :deflate

examples

Examples

iex> Plantuml.Encoding.encode("Alice -> Bob: Authentication Request\nBob --> Alice: Authentication Response\n")
"Syp9J4vLqBLJSCfFib9mB2t9ICqhoKnEBCdCprC8IYqiJIqkuGBAAUW2rJY256DHLLoGdrUSoWK0"

iex> Plantuml.Encoding.encode("Alice -> Bob: Authentication Request\nBob --> Alice: Authentication Response\n", method: :hex)
"416C696365202D3E20426F623A2041757468656E7469636174696F6E20526571756573740A426F62202D2D3E20416C6963653A2041757468656E7469636174696F6E20526573706F6E73650A"