Emacs, scripting and anything text oriented.

PlantUML

Collection of PlantUML snippets that I find useful.
Kaushal Modi

Class with tree-structure in body #

class Foo {
**Bar(Model)**
|_ prop
|_ **Bom(Model)**
  |_ prop2
  |_ prop3
    |_ prop3.1
|_ prop4
--
}
class-body-tree.png

Source

Class Composition #

Diagram to represent a class containing children classes.

class h-entry << (H,white) >> {
  Post Entry
  ==
  ""<div class="h-entry">..</div>""
}

class p-name << (P,orchid) >> {
  Title of the post
  ==
  ""<h1 class="p-name">..</h1>""
}

class u-url << (U,#7EC0EE) >> {
  Permalink of the post
  ==
  ""<a href=".." class="u-url">..</a>""
}

class u-syndication << (U,#7EC0EE) >> {
  Link where the post is syndicated
  ==
  ""<a href=".." class="u-syndication" rel="syndication">..</a>""
}

class dt-published << (D,green) >> {
  Publish date of the post
  ..
  Go Date/time format: "2006-01-02T15:04:05-0700"
  ==
  ""<time datetime=".." class="dt-published">..</time>""
}

class p-summary << (P,orchid) >> {
  Summary/description of the post
  ==
  ""<div class="p-summary">..</div>""
}

class u-author << (U,#7EC0EE) >> {
  Post author
  ==
  ""<a href="HOMEPAGE" class="u-author">..</a>""
}

class e-content << (E,red) >> {
  Post content
  ==
  ""<div class="e-content">..</div>""
}

class p-category << (P,orchid) >> {
  Tag, category, series name
  ==
  ""<a href="TAGPAGE" class="p-category">TAG</a>""
}

"p-name" -up-* "h-entry"
"u-url" -up-* "h-entry"
"u-syndication" -left-* "h-entry"
"h-entry" *-right- "p-summary"
"h-entry" *-right- "u-author"
"h-entry" *-down- "dt-published"
"h-entry" *-down- "e-content"
"h-entry" *-down- "p-category"
class-composition.png

Reference #

Nested boxes #

I’d like to document the nested HTML tags for my web page, and represent them as a diagram with nested blocks.

While searching for an existing representation like that online, I came across this.

Is there a way to draw something like the nested blocks in the center of that figure using PlantUML?

rectangle "<html>, <body>, etc." as a  {
  rectangle "<div>..." as b #antiquewhite {
    rectangle "<video>...\n\n\n" as c
  }
}
nested-boxes.png

Source

Forcing vertical ordering of rectangles #

Trying to nest rectangles within rectangles will give this:

rectangle a {
  rectangle b
  rectangle c
  rectangle d
}
vertically-ordered-rectangles-not-working.svg

To force the vertical order and alignment of rectangles, use hidden arrows (b -[hidden]-> c).

Note that this is a hack, and must not be abused.

rectangle a {
  rectangle b
  rectangle c
  rectangle d
  b -[hidden]-> c
  c -[hidden]-> d
}
vertically-ordered-rectangles.svg

Source


Versions used: plantuml beta 2018/04/09
     plantuml

If you have written a response to this, enter your response post's URL below.

Or, you can send a "comment" webmention (it's OK if you don't know what that means). When asked about your website on an IndieAuth login screen, simply type https://commentpara.de.

Markdown Support**bold**, _italics_, ~~strikethrough~~, [descr](link), `monospace`, ```LANG\nline1\nline2\n``` (Yep, multi-line code blocks too, with syntax highlighting!), auto-hyperlinking.

Webmentions #