I want to create a class diagram of an Enum in PlantUML with the literals keyword centered above the third compartment according to the following quote (also referenced in this answer):
A list of EnumerationLiterals may be placed, one to a line, in a compartment named “literals” below the operations compartment. The attributes and operations compartments may be suppressed, and typically are suppressed and empty.
Using the following PlantUML how can I get the literals text to be center alligned?
@startuml
package MyPackage {
enum MyEnum {
attrib1: str
attrib2: int
--
func1()
func2()
--
literals
ONE_LITERAL
TWO_LITERAL
}
}
@enduml
The easiest way to go is described in plantuml's documentation, in the section "Advanced class body", using a -- separator with title. Your example would look like:
@startuml
package MyPackage {
enum MyEnum {
attrib1: str
attrib2: int
--
func1()
func2()
-- literals --
ONE_LITERAL
TWO_LITERAL
}
}
@enduml
and result in: