Skip to content

Instantly share code, notes, and snippets.

@mighty-sparrow
Last active August 12, 2020 01:44
Show Gist options
  • Select an option

  • Save mighty-sparrow/d458e630396c25834d91e61c55f11724 to your computer and use it in GitHub Desktop.

Select an option

Save mighty-sparrow/d458e630396c25834d91e61c55f11724 to your computer and use it in GitHub Desktop.
My Example PlantUML

Overview

This is my take on a fine example created by @jerieljan. To see their explanation, check out How I Do PlantUML.

Usage

Take a look at the comments of the Example.puml file. Based on those comments and the explanation from the aformentioned Gist, you should be able to put a small example together.

@startuml
' Assign colors from a STYLE_THEME.
' Options are: [ DEFAULT | LIGHT | DARK | MIDNIGHT ]
!define STYLE_THEME MIDNIGHT
'!define STYLE_THEME LIGHT
'!define STYLE_THEME DEFAULT
'!define STYLE_THEME DARK
' Color Definition
' - Choose the individual color you want by applying them here.
' - You can define these values in prior to your "!import"
' statements. Otherwise, a default value is used.
' - If these values are defined, they override the "STYLE_THEME" settings.
' - Options are [ STYLE_ACCENT, STYLE_BGC, STYLE_FGC, STYLE_LINE ]
!define STYLE_ACCENT #00ff00
!define STYLE_BGC #9900FF
!define STYLE_FGC #FFCC00
!define STYLE_LINE #00ff00
' Load preset styles.
!define BASEPATH ../../_puml-includes
!include BASEPATH/stylesheet_conditional.iuml
!include BASEPATH/functions.iuml
!define TEST_TITLE %get_variable_value("TEST_CONCAT")
' You can still override individual styles, if need be.
skinparam {
DPI 100
SequenceGroupBodyBackgroundColor #Turquoise
NoteBorderColor #999
NoteBackgroundColor #Gray
}
' Using a custom function defined in "functions.iuml"
tmNoteOver("A,B","<color:#fff>here is some stuff")
'Actor Definitions
participant A as "Actor A"
' Enable Auto-numbering
autonumber 1 "0:"
title Sequence Diagram
group Some Group
A -> B: Perform Action
B --> A: (Response)
end group
note over A,B
Hello there.
end note
@enduml
@startuml
!procedure myNoteOver($overWhat, $contents="Default Contents")
note over $overWhat #Magenta
$contents
end note
!endprocedure
@enduml
# Style Presets
@startuml
' Preset Styles by Jeriel Jan
' Preset: Monochrome
!define STYLE_DEFAULT_ACCENT #999
!define STYLE_DEFAULT_BGC #EEE
!define STYLE_DEFAULT_FGC #000
!define STYLE_DEFAULT_LINE #333
' Preset: Material Light Blue (200)
!define STYLE_LIGHT_ACCENT #81D4FA
!define STYLE_LIGHT_BGC #FFF
!define STYLE_LIGHT_FGC #000
!define STYLE_LIGHT_LINE #CCC
' Preset: Material Light Blue (800)
!define STYLE_DARK_ACCENT #0277BD
!define STYLE_DARK_BGC #FFF
!define STYLE_DARK_FGC #000
!define STYLE_DARK_LINE #333
' Preset: Material Light Blue (800)
!define STYLE_MIDNIGHT_ACCENT #0277BD
!define STYLE_MIDNIGHT_BGC #000
!define STYLE_MIDNIGHT_FGC #FFF
!define STYLE_MIDNIGHT_LINE #336699
' Assign a THEME from your PUML file instead of individual styles.
' Options are: [ DEFAULT | LIGHT | DARK | MIDNIGHT ]
!ifdef STYLE_THEME
!if %not(%variable_exists("STYLE_ACCENT"))
%set_variable_value("ACCENT","STYLE_" + %get_variable_value("STYLE_THEME") + "_ACCENT")
!define STYLE_ACCENT %get_variable_value(ACCENT)
!endif
!if %not(%variable_exists("STYLE_BGC"))
%set_variable_value("BGC","STYLE_" + %get_variable_value("STYLE_THEME") + "_BGC")
!define STYLE_BGC %get_variable_value(BGC)
!endif
!if %not(%variable_exists("STYLE_FGC"))
%set_variable_value("FGC","STYLE_" + %get_variable_value("STYLE_THEME") + "_FGC")
!define STYLE_FGC %get_variable_value(FGC)
!endif
!if %not(%variable_exists("STYLE_LINE"))
%set_variable_value("LINE","STYLE_" + %get_variable_value("STYLE_THEME") + "_LINE")
!define STYLE_LINE %get_variable_value(LINE)
!endif
!endif
skinparam {
' This field left intentionally blank.
}
@enduml
# Project Stylesheet
@startuml
' Load preset styles.
!define STYLEPATH .
!include STYLEPATH/style-presets.iuml
' Color Definition
' - Choose the style you want by applying them here.
' - You can define these values in prior to your "!import"
' statements. Otherwise, a default value is used.
!if %not(%variable_exists("STYLE_ACCENT"))
!define STYLE_ACCENT STYLE_DEFAULT_ACCENT
!endif
!if %not(%variable_exists("STYLE_BGC"))
!define STYLE_BGC STYLE_DEFAULT_BGC
!endif
!if %not(%variable_exists("STYLE_FGC"))
!define STYLE_FGC STYLE_DEFAULT_FGC
!endif
!if %not(%variable_exists("STYLE_LINE"))
!define STYLE_LINE STYLE_DEFAULT_LINE
!endif
' RECOMMENDED STYLE
' -=- DO NOT EDIT THIS SECTION. -=-
' See Custom Style section below to override items here.
skinparam {
' Global Options
DPI 200
Shadowing false
DefaultFontName Roboto Condensed
DefaultMonospacedFontName Inconsolata
DefaultFontColor STYLE_FGC
' Styles - Borders
ArrowColor STYLE_LINE
ActivityBorderColor STYLE_ACCENT
ActivityDiamondBorderColor STYLE_ACCENT
ActorBorderColor STYLE_ACCENT
AgentBorderColor STYLE_ACCENT
ArtifactBorderColor STYLE_ACCENT
BoundaryBorderColor STYLE_ACCENT
ClassBorderColor STYLE_ACCENT
CloudBorderColor STYLE_ACCENT
CollectionsBorderColor STYLE_ACCENT
ComponentBorderColor STYLE_ACCENT
ControlBorderColor STYLE_ACCENT
DatabaseBorderColor STYLE_ACCENT
EntityBorderColor STYLE_ACCENT
FileBorderColor STYLE_ACCENT
FolderBorderColor STYLE_ACCENT
FrameBorderColor STYLE_ACCENT
InterfaceBorderColor STYLE_ACCENT
LegendBorderColor STYLE_ACCENT
NoteBorderColor STYLE_ACCENT
ObjectBorderColor STYLE_ACCENT
PackageBorderColor STYLE_ACCENT
ParticipantBorderColor STYLE_ACCENT
PartitionBorderColor STYLE_ACCENT
QueueBorderColor STYLE_ACCENT
RectangleBorderColor STYLE_ACCENT
SequenceBoxBorderColor STYLE_ACCENT
SequenceDividerBorderColor STYLE_ACCENT
SequenceGroupBorderColor STYLE_ACCENT
SequenceLifeLineBorderColor STYLE_ACCENT
SequenceReferenceBorderColor STYLE_ACCENT
StackBorderColor STYLE_ACCENT
StateBorderColor STYLE_ACCENT
StorageBorderColor STYLE_ACCENT
SwimlaneBorderColor STYLE_ACCENT
UsecaseBorderColor STYLE_ACCENT
' Styles - Backgrounds
ActivityBackgroundColor STYLE_BGC
ActivityDiamondBackgroundColor STYLE_BGC
ActorBackgroundColor STYLE_BGC
AgentBackgroundColor STYLE_BGC
ArtifactBackgroundColor STYLE_BGC
BackgroundColor STYLE_BGC
BoundaryBackgroundColor STYLE_BGC
ClassBackgroundColor STYLE_BGC
ClassHeaderBackgroundColor STYLE_BGC
CloudBackgroundColor STYLE_BGC
CollectionsBackgroundColor STYLE_BGC
ComponentBackgroundColor STYLE_BGC
ControlBackgroundColor STYLE_BGC
DatabaseBackgroundColor STYLE_BGC
EntityBackgroundColor STYLE_BGC
FileBackgroundColor STYLE_BGC
FolderBackgroundColor STYLE_BGC
FrameBackgroundColor STYLE_BGC
IconPackageBackgroundColor STYLE_BGC
IconPrivateBackgroundColor STYLE_BGC
IconProtectedBackgroundColor STYLE_BGC
IconPublicBackgroundColor STYLE_BGC
InterfaceBackgroundColor STYLE_BGC
LegendBackgroundColor STYLE_BGC
NodeBackgroundColor STYLE_BGC
NoteBackgroundColor STYLE_BGC
ObjectBackgroundColor STYLE_BGC
PackageBackgroundColor STYLE_BGC
ParticipantBackgroundColor STYLE_BGC
PartitionBackgroundColor STYLE_BGC
QueueBackgroundColor STYLE_BGC
RectangleBackgroundColor STYLE_BGC
SequenceBoxBackgroundColor STYLE_BGC
SequenceDividerBackgroundColor STYLE_BGC
SequenceGroupBackgroundColor STYLE_BGC
SequenceGroupBodyBackgroundColor STYLE_BGC
SequenceLifeLineBackgroundColor STYLE_BGC
SequenceReferenceBackgroundColor STYLE_BGC
SequenceReferenceHeaderBackgroundColor STYLE_BGC
StackBackgroundColor STYLE_BGC
StateBackgroundColor STYLE_BGC
StereotypeABackgroundColor STYLE_BGC
StereotypeCBackgroundColor STYLE_BGC
StereotypeEBackgroundColor STYLE_BGC
StereotypeIBackgroundColor STYLE_BGC
StereotypeNBackgroundColor STYLE_BGC
StorageBackgroundColor STYLE_BGC
TitleBackgroundColor STYLE_BGC
UsecaseBackgroundColor STYLE_BGC
' -=- END OF RECOMMENDED STYLE -=-
' Other Settings
' These settings are included in the language specs, but
' it's not recommended to be applied.
'TitleBorderColor STYLE_ACCENT
'DiagramBorderColor STYLE_ACCENT
' CUSTOM STYLE
' All items below can be safely commented out.
' This will override the options listed above.
roundcorner 8
'Monochrome true
NoteFontName Roboto Condensed
NoteFontStyle Italic
}
@enduml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment