Documentation
¶
Overview ¶
Package gopuml renders PlantUML diagram source to SVG, PNG and text.
It is a Go reimplementation of PlantUML v1.2026.8 (MIT variant).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrSyntax matches every *SyntaxError. ErrSyntax = errors.New("plantuml: syntax error") // ErrNoDiagram reports a source without a diagram, or a diagram or // page index out of range. ErrNoDiagram = errors.New("plantuml: no diagram found") // ErrUnsupportedDiagram reports a diagram type or family this // implementation does not provide. ErrUnsupportedDiagram = errors.New("plantuml: diagram type not supported") // ErrUnsupportedFormat reports a format a diagram type cannot produce. ErrUnsupportedFormat = errors.New("plantuml: format not supported for this diagram") // ErrGraphvizNotFound reports that the Graphviz dot program is missing. ErrGraphvizNotFound = errors.New("plantuml: Graphviz dot not found") // ErrGraphvizTimeout reports a dot run stopped after the timeout. ErrGraphvizTimeout = errors.New("plantuml: Graphviz dot timed out") // ErrGraphvizFailed reports a dot run that failed. ErrGraphvizFailed = errors.New("plantuml: Graphviz dot failed") // ErrAccessDenied reports a file or URL the security profile does not // allow. ErrAccessDenied = security.ErrDenied // ErrDecode reports text that is not encoded diagram source. ErrDecode = code.ErrNoCompression )
Errors returned by the package. Test for them with errors.Is; a syntax error is also a *SyntaxError, usable with errors.As.
Functions ¶
Types ¶
type Block ¶
type Block struct {
// Name is the name given on the start line, such as "login" for
// "@startuml login", or "".
Name string
// Family is the word after @start, in lower case, such as "uml".
Family string
// Type is the diagram type upstream detects, such as "SEQUENCE" or
// "CLASS", or "" for a block with an error.
Type string
// Description is upstream's description, such as "(2 participants)" or
// "(Error)".
Description string
// Err is the syntax status: nil, a *SyntaxError, or an error matching
// ErrUnsupportedDiagram.
Err error
// contains filtered or unexported fields
}
Block is one @start/@end block of a source, with its diagram.
func Inspect ¶
Inspect lists the blocks of a source with their diagram type and syntax status, without drawing them.
type Define ¶
type Define struct {
Name, Value string
}
Define is a preprocessor definition, like -DNAME=VALUE on the command line.
type Options ¶
type Options struct {
// Format is the output format.
Format Format
// Diagram and Page select what Render draws: the index of the
// @start/@end block and the page within it, both from 0.
Diagram, Page int
// NoMetadata omits the embedded source from SVG and PNG output.
NoMetadata bool
// NoErrorImage returns syntax errors without an error image.
NoErrorImage bool
// Defines are preprocessor definitions, in order.
Defines []Define
// Config lines are inserted after the start line of every diagram.
Config []string
// IncludePaths are directories searched by !include.
IncludePaths []string
// Theme is applied to every diagram, like !theme.
Theme string
// DarkMode renders with upstream's dark color mapping.
DarkMode bool
// SecurityProfile is upstream's profile name, such as SANDBOX or
// INTERNET; empty means LEGACY.
SecurityProfile string
// DotPath is the Graphviz dot program; empty means it is searched for.
DotPath string
// DotTimeout stops dot after this duration; zero means 30 seconds.
DotTimeout time.Duration
// FS resolves includes and themes. When nil, the operating system's
// file system is used, subject to the security profile.
FS fs.FS
// Dir is the directory of the source, against which relative includes
// are resolved.
Dir string
// Filename is the name of the source, as %filename() returns it.
Filename string
}
Options configure one call; they do not affect other calls. A nil *Options means the zero value.
type Result ¶
type Result struct {
// Data is the output: an image, or text for TXT and UTXT.
Data []byte
// Width and Height are the size of the image in pixels.
Width, Height int
// Description is upstream's description, such as "(2 participants)".
Description string
// Pages is the number of pages of the rendered diagram.
Pages int
// Diagrams is the number of @start/@end blocks of the source.
Diagrams int
}
Result is a rendered page.
type SyntaxError ¶
type SyntaxError struct {
// Line is the 1-based line of the error in the source.
Line int
// Message is upstream's message, for example "Syntax Error? (Assumed
// diagram type: sequence)".
Message string
}
SyntaxError is a diagram with a syntax error.
func (*SyntaxError) Error ¶
func (e *SyntaxError) Error() string
func (*SyntaxError) Is ¶
func (e *SyntaxError) Is(target error) bool
Is makes errors.Is(err, ErrSyntax) true for a *SyntaxError.
type UnsupportedError ¶
type UnsupportedError struct {
// Line is the 1-based line of the source that shows the type.
Line int
// Message explains what is not supported, for example "mindmap
// diagrams are not supported yet".
Message string
}
UnsupportedError is a diagram whose type or family this implementation does not provide.
func (*UnsupportedError) Error ¶
func (e *UnsupportedError) Error() string
func (*UnsupportedError) Is ¶
func (e *UnsupportedError) Is(target error) bool
Is makes errors.Is(err, ErrUnsupportedDiagram) true for an *UnsupportedError.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
plantuml
command
Command plantuml is a drop-in replacement for java -jar plantuml.jar.
|
Command plantuml is a drop-in replacement for java -jar plantuml.jar. |
|
plantuml-wasm
command
Command plantuml-wasm is the WebAssembly entry point of the renderer.
|
Command plantuml-wasm is the WebAssembly entry point of the renderer. |
|
internal
|
|
|
abel
Package abel is the entity model shared by the graph diagrams (class, object, description, state): entities, links, groups, together blocks, notes, the hide, show, remove and restore rules, and the namespace of names.
|
Package abel is the entity model shared by the graph diagrams (class, object, description, state): entities, links, groups, together blocks, notes, the hide, show, remove and restore rules, and the namespace of names. |
|
activitydiagram
Package activitydiagram parses activity diagrams in the legacy syntax ("(*) --> "First step""): the ActivityDiagram model (upstream's activitydiagram package), the factory and its commands in upstream's order (upstream's activitydiagram.command package and its note command), and the drawing, laid out by Graphviz dot through internal/svek.
|
Package activitydiagram parses activity diagrams in the legacy syntax ("(*) --> "First step""): the ActivityDiagram model (upstream's activitydiagram package), the factory and its commands in upstream's order (upstream's activitydiagram.command package and its note command), and the drawing, laid out by Graphviz dot through internal/svek. |
|
activitydiagram3
Package activitydiagram3 parses, lays out and draws activity diagrams in the new syntax: upstream's activitydiagram3 package with its ftile, ftile.vertical, ftile.vcompact and ftile.vcompact.cond subpackages (one Go package, as they form a cycle upstream; the ftile files carry the "ftile_", "ftile_vertical_", "ftile_vcompact_" and "ftile_vcompact_cond_" prefixes) and svek's UGraphicForSnake.
|
Package activitydiagram3 parses, lays out and draws activity diagrams in the new syntax: upstream's activitydiagram3 package with its ftile, ftile.vertical, ftile.vcompact and ftile.vcompact.cond subpackages (one Go package, as they form a cycle upstream; the ftile files carry the "ftile_", "ftile_vertical_", "ftile_vcompact_" and "ftile_vcompact_cond_" prefixes) and svek's UGraphicForSnake. |
|
asciiart
Package asciiart is upstream's asciiart package, for the ASCII (TXT) and Unicode (UTXT) text art.
|
Package asciiart is upstream's asciiart package, for the ASCII (TXT) and Unicode (UTXT) text art. |
|
asciiverse
Package asciiverse is upstream's asciiverse package: the character grid (InfinitePlan, InfiniteString) the text formats ATXT and UTXT are drawn on, and the blocks drawn on it (AsciiBlock and its decorators, note boxes, group frames, else separators and tables).
|
Package asciiverse is upstream's asciiverse package: the character grid (InfinitePlan, InfiniteString) the text formats ATXT and UTXT are drawn on, and the blocks drawn on it (AsciiBlock and its decorators, note boxes, group frames, else separators and tables). |
|
classdiagram
Package classdiagram parses class diagrams, and object diagrams, which upstream also parses with its class factory: the ClassDiagram model (upstream's classdiagram and objectdiagram packages, which refer to each other and form one Go package per design D2, objectdiagram_*.go), the factory and its commands in upstream's order, and the drawing (ExportDiagram), laid out by Graphviz dot through internal/svek.
|
Package classdiagram parses class diagrams, and object diagrams, which upstream also parses with its class factory: the ClassDiagram model (upstream's classdiagram and objectdiagram packages, which refer to each other and form one Go package per design D2, objectdiagram_*.go), the factory and its commands in upstream's order, and the drawing (ExportDiagram), laid out by Graphviz dot through internal/svek. |
|
cli
Package cli is upstream's command line interface: flags, parsing and help, compatible with java -jar plantuml.jar.
|
Package cli is upstream's command line interface: flags, parsing and help, compatible with java -jar plantuml.jar. |
|
code
Package code encodes and decodes diagram source in the PlantUML URL text format.
|
Package code encodes and decodes diagram source in the PlantUML URL text format. |
|
command
Package command provides the line-oriented regex command framework used by diagram parsers.
|
Package command provides the line-oriented regex command framework used by diagram parsers. |
|
command/regex
Package regex compiles upstream's command patterns for Go's RE2 engine.
|
Package regex compiles upstream's command patterns for Go's RE2 engine. |
|
conformance
Package conformance compares rendered output with reference renders from Java PlantUML.
|
Package conformance compares rendered output with reference renders from Java PlantUML. |
|
core
Package core extracts diagram blocks from input text, detects the diagram type and builds error diagrams.
|
Package core extracts diagram blocks from input text, detects the diagram type and builds error diagrams. |
|
decoration
Package decoration is upstream's net.sourceforge.plantuml.decoration: the types of the links of graph diagrams (LinkType with its two LinkDecor heads, its LinkStyle and its LinkMiddleDecor) and WithLinkType, the base of the links.
|
Package decoration is upstream's net.sourceforge.plantuml.decoration: the types of the links of graph diagrams (LinkType with its two LinkDecor heads, its LinkStyle and its LinkMiddleDecor) and WithLinkType, the base of the links. |
|
decoration/symbol
Package symbol is upstream's decoration.symbol: the shapes drawn around a text (database, queue, node, cloud, folder...), small as a participant head or an entity (AsSmall), or big as a container (AsBig).
|
Package symbol is upstream's decoration.symbol: the shapes drawn around a text (database, queue, node, cloud, folder...), small as a participant head or an entity (AsSmall), or big as a container (AsBig). |
|
descdiagram
Package descdiagram parses description diagrams (use case, component and deployment diagrams): the DescriptionDiagram model (upstream's descdiagram package), the factory and its commands in upstream's order (upstream's descdiagram.command package, whose Labels and StringWithArrow the class diagram commands also use), and the drawing, laid out by Graphviz dot through internal/svek.
|
Package descdiagram parses description diagrams (use case, component and deployment diagrams): the DescriptionDiagram model (upstream's descdiagram package), the factory and its commands in upstream's order (upstream's descdiagram.command package, whose Labels and StringWithArrow the class diagram commands also use), and the drawing, laid out by Graphviz dot through internal/svek. |
|
dot
Package dot locates and runs the Graphviz dot executable.
|
Package dot locates and runs the Graphviz dot executable. |
|
engine
Package engine parses and draws diagram sources, as upstream's SourceStringReader and BlockUml.
|
Package engine parses and draws diagram sources, as upstream's SourceStringReader and BlockUml. |
|
errdiagram
Package errdiagram draws the built-in images of upstream's net.sourceforge.plantuml.error package and its friends:
|
Package errdiagram draws the built-in images of upstream's net.sourceforge.plantuml.error package and its friends: |
|
export
Package export writes a drawn diagram in an output format: upstream's core.TextBlockExporter with FileFormatOption, the Scale kinds and the ImageData results.
|
Package export writes a drawn diagram in an output format: upstream's core.TextBlockExporter with FileFormatOption, the Scale kinds and the ImageData results. |
|
jfmt
Package jfmt formats numbers exactly like the Java library calls that PlantUML uses for its output.
|
Package jfmt formats numbers exactly like the Java library calls that PlantUML uses for its output. |
|
jmath
Package jmath is a deterministic, Java-compatible math library.
|
Package jmath is a deterministic, Java-compatible math library. |
|
json
Package json manages JSON data with the semantics of PlantUML's fork of the minimal-json library (net.sourceforge.plantuml.json).
|
Package json manages JSON data with the semantics of PlantUML's fork of the minimal-json library (net.sourceforge.plantuml.json). |
|
klimt
Package klimt is the drawing model: shapes, text blocks and the UGraphic abstraction that output drivers implement, displays and stereotypes, links, the style system (CSS-like style sheets, the embedded skins, skinparam conversion) and the skin parameters.
|
Package klimt is the drawing model: shapes, text blocks and the UGraphic abstraction that output drivers implement, displays and stereotypes, links, the style system (CSS-like style sheets, the embedded skins, skinparam conversion) and the skin parameters. |
|
klimt/color
Package color is PlantUML's color model: XColor values, the HColor kinds diagrams use (simple colors, automatic colors, color schemes, gradients), the color parser with the HTML color names, the per-element Colors of a command, the color mappers for dark mode, monochrome and reversed output, and the HSL and HSLuv arithmetic of the preprocessor color functions.
|
Package color is PlantUML's color model: XColor values, the HColor kinds diagrams use (simple colors, automatic colors, color schemes, gradients), the color parser with the HTML color names, the per-element Colors of a command, the color mappers for dark mode, monochrome and reversed output, and the HSL and HSLuv arithmetic of the preprocessor color functions. |
|
klimt/font
Package font holds upstream's font model (UFont, UFontFace, FontStack, FontStyle) and the StringBounder text measurement.
|
Package font holds upstream's font model (UFont, UFontFace, FontStack, FontStyle) and the StringBounder text measurement. |
|
klimt/g2d
Package g2d is the raster output driver: upstream's klimt.drawing.g2d (UGraphicG2d and its Driver*G2d) with EmptyImageBuilder, drawing on an ARGB image that internal/png writes as PNG.
|
Package g2d is the raster output driver: upstream's klimt.drawing.g2d (UGraphicG2d and its Driver*G2d) with EmptyImageBuilder, drawing on an ARGB image that internal/png writes as PNG. |
|
klimt/g2d/dejavu
Package dejavu embeds the DejaVu fonts behind Java's logical fonts on the reference image (fonts-dejavu 2.37) and loads their glyph outlines as Java gets them from FreeType: unhinted, scaled with FreeType's fixed point arithmetic, in 26.6 fixed point.
|
Package dejavu embeds the DejaVu fonts behind Java's logical fonts on the reference image (fonts-dejavu 2.37) and loads their glyph outlines as Java gets them from FreeType: unhinted, scaled with FreeType's fixed point arithmetic, in 26.6 fixed point. |
|
klimt/geom
Package geom holds the geometry value types of the drawing model: points, dimensions, rectangles, lines, cubic curves, bounding boxes and the small alignment and position enums.
|
Package geom holds the geometry value types of the drawing model: points, dimensions, rectangles, lines, cubic curves, bounding boxes and the small alignment and position enums. |
|
klimt/rose
Package rose is upstream's skin.rose: the components that draw the elements of sequence diagrams (message arrows, participant heads and lines, notes, groupings, dividers, delays, references, boxes) and the Rose skin that builds them.
|
Package rose is upstream's skin.rose: the components that draw the elements of sequence diagrams (message arrows, participant heads and lines, notes, groupings, dividers, delays, references, boxes) and the Rose skin that builds them. |
|
klimt/svg
Package svg is the SVG output driver, upstream's klimt.drawing.svg: UGraphicSvg dispatches shapes to the Driver*Svg drivers, which write them into SvgGraphics, a minimal DOM (XMLDocument, XMLNode) serialized by XMLWriter without any newline, as upstream.
|
Package svg is the SVG output driver, upstream's klimt.drawing.svg: UGraphicSvg dispatches shapes to the Driver*Svg drivers, which write them into SvgGraphics, a minimal DOM (XMLDocument, XMLNode) serialized by XMLWriter without any newline, as upstream. |
|
klimt/svg/svgtest
Package svgtest runs the drawing scripts of the SVG golden tests of the svg and export packages.
|
Package svgtest runs the drawing scripts of the SVG golden tests of the svg and export packages. |
|
png
Package png reads and writes the PNG features upstream uses: the text chunk that embeds the diagram source.
|
Package png reads and writes the PNG features upstream uses: the text chunk that embeds the diagram source. |
|
security
Package security applies security profiles to file and URL access.
|
Package security applies security profiles to file and URL access. |
|
sequencediagram
Package sequencediagram parses, lays out (Teoz engine) and draws sequence diagrams.
|
Package sequencediagram parses, lays out (Teoz engine) and draws sequence diagrams. |
|
server
Package server serves rendered diagrams over HTTP, with the routes of upstream's built-in server (--http-server) and of plantuml-server.
|
Package server serves rendered diagrams over HTTP, with the routes of upstream's built-in server (--http-server) and of plantuml-server. |
|
statediagram
Package statediagram parses state diagrams: the StateDiagram model (upstream's statediagram package), the factory and its commands in upstream's order (upstream's statediagram.command package), and the drawing, laid out by Graphviz dot through internal/svek.
|
Package statediagram parses state diagrams: the StateDiagram model (upstream's statediagram package), the factory and its commands in upstream's order (upstream's statediagram.command package), and the drawing, laid out by Graphviz dot through internal/svek. |
|
svek
Package svek lays out graph-based diagrams (class and object diagrams in this release) with Graphviz dot and draws them, as upstream's svek package: it measures the image of each entity, writes the DOT graph (DotStringFactory, with a subgraph per group and the HTML tables that reserve the room of labels and quantifiers), has a layout engine compute it, reads node positions, cluster boxes and edge paths back from the SVG document the engine returns (SvgResult), and draws the result (SvekResult): clusters, nodes, then edges with their arrow heads (internal/svek/extremity), labels, quantifiers and qualifier boxes.
|
Package svek lays out graph-based diagrams (class and object diagrams in this release) with Graphviz dot and draws them, as upstream's svek package: it measures the image of each entity, writes the DOT graph (DotStringFactory, with a subgraph per group and the HTML tables that reserve the room of labels and quantifiers), has a layout engine compute it, reads node positions, cluster boxes and edge paths back from the SVG document the engine returns (SvgResult), and draws the result (SvekResult): clusters, nodes, then edges with their arrow heads (internal/svek/extremity), labels, quantifiers and qualifier boxes. |
|
svek/extremity
Package extremity is upstream's svek.extremity: the decorations drawn at the ends of the links of graph diagrams (arrow heads, diamonds, crow's feet, circles...) and in their middle, with upstream's AbstractExtremityFactory.
|
Package extremity is upstream's svek.extremity: the decorations drawn at the ends of the links of graph diagrams (arrow heads, diamonds, crow's feet, circles...) and in their middle, with upstream's AbstractExtremityFactory. |
|
text
Package text holds located source lines and string helpers with the exact semantics of the Java methods upstream relies on.
|
Package text holds located source lines and string helpers with the exact semantics of the Java methods upstream relies on. |
|
themes
Package themes holds the themes bundled with the program: the theme files of PlantUML v1.2026.8 whose license allows bundling them (see NOTICE for the themes that are left out and why).
|
Package themes holds the themes bundled with the program: the theme files of PlantUML v1.2026.8 whose license allows bundling them (see NOTICE for the themes that are left out and why). |
|
tim
Package tim implements the PlantUML preprocessor (variables, macros, control flow, functions, builtins and includes).
|
Package tim implements the PlantUML preprocessor (variables, macros, control flow, functions, builtins and includes). |
|
uml
Package uml holds what every UML diagram type shares: the diagram base (upstream's AbstractDiagram, UgDiagram and TitledDiagram), the annotations (title, caption, legend, header, footer, main frame, scale), the multi-line command shapes and the common commands of net.sourceforge.plantuml.command.CommonCommands.
|
Package uml holds what every UML diagram type shares: the diagram base (upstream's AbstractDiagram, UgDiagram and TitledDiagram), the annotations (title, caption, legend, header, footer, main frame, scale), the multi-line command shapes and the common commands of net.sourceforge.plantuml.command.CommonCommands. |
|
version
Package version describes this implementation and the upstream release it reproduces.
|
Package version describes this implementation and the upstream release it reproduces. |
|
tools
|
|
|
bench
command
Command bench compares the start time and the rendering time of this implementation with the upstream jar, on the same machine and with the same dot for both (passed through GRAPHVIZ_DOT).
|
Command bench compares the start time and the rendering time of this implementation with the upstream jar, on the same machine and with the same dot for both (passed through GRAPHVIZ_DOT). |
|
provenance
command
Command provenance checks that every Go source file declares where its code comes from, so that only MIT-licensed upstream code is translated.
|
Command provenance checks that every Go source file declares where its code comes from, so that only MIT-licensed upstream code is translated. |
|
refgen
command
Command refgen renders conformance references with Java PlantUML v1.2026.8 in the reference image (tools/reference/Dockerfile).
|
Command refgen renders conformance references with Java PlantUML v1.2026.8 in the reference image (tools/reference/Dockerfile). |