Skip to content
Jaime Olivares edited this page Jun 20, 2022 · 14 revisions

yUML syntax

The yUML syntax is based on the samples provided in yuml.me. There is no formal documentation, so this page pretends to centralize the information gathered, plus some proposed extensions for new diagram types.

Comments and directives

The following syntax supports comments and directives out of the original yUML syntax. They are similar to other languages' inline comments, starting with a double slash.

Directives are required for modifying the rendering behavior and shall be placed at the beginning of the file, before any yUML statement. The type directive is the unique mandatory one.

This is the list of valid directives:

  • type: Mandatory, specifies the diagram type.
    Valid values:

  • direction: Optional, specifies the drawing direction for certain diagram types.
    Valid values: leftToRight, rightToLeft, topDown
    Default: topDown
    Example: // {direction:leftToRight}

  • generate: Optional, indicates if a .svg file shall be generated on each save. The image file is saved in the same folder as the .yuml file.
    Valid values: true, false
    Default: false
    Example: // {generate:true}

Class diagram

The following constructions were taken from the yuml.me page for class diagrams:

Item Example
Class [Customer]
Directional [Customer]->[Order]
Bidirectional [Customer]<->[Order]
Aggregation [Customer]+-[Order] or [Customer]<>-[Order]
Composition [Customer]++-[Order]
Inheritance [Customer]^[Cool Customer]
Dependencies [Customer]uses-.->[PaymentStrategy]
Cardinality [Customer]<1-1..2>[Address]
Labels [Person]customer-billingAddress[Address]
Notes [Address]-[note: Value Object]
Full Class [Customer|Forename;Surname;Email|Save()]
Color splash [Customer{bg:orange}]<>1->\*[Order{bg:green}]

Example

// {type:class}
// {direction:topDown}
// {generate:true}

[note: You can stick notes on diagrams too!{bg:cornsilk}]
[Customer]<>1-orders 0..*>[Order]
[Order]++*-*>[LineItem]
[Order]-1>[DeliveryMethod]
[Order]*-*>[Product|EAN_Code;Description;ListPrice|promo_price()]
[Category]<->[Product]
[DeliveryMethod]^[National]
[DeliveryMethod]^[International]

class diagram example

Notes:

  • The note: indicator defines note elements that can be associated to other elements with a simple hyphen.
  • The {bg: xxx} modifier determines the background color of the element. The color codes are specified in a section below.

Association classes

A non-standard syntax has been added for supporting association classes. For any class-association-class construct (typically many-to-many), just append another class in the same expression as:

[Invoice]<*-*>[Products][Invoice Item]

Use-case diagram

The following constructions were taken from the yuml.me page for use-case diagrams:

Item Example
Use Case (Login)
Actor [Customer]
<<Extend>> (Login)<(Forgot Password)
<<Include>> (Register)>(Confirm Email)
Actor Inheritance [Admin]^[User]
Note [Admin]-(note: Most privilidged user)

Example

// {type:usecase}
// {direction:leftToRight}
// {generate:true}

(note: figure 1.2{bg:beige})
[User]-(Login)
[Site Maintainer]-(Add User)
(Add User)<(Add Company)
[Site Maintainer]-(Upload Docs)
(Upload Docs)<(Manage Folders)
[User]-(Upload Docs)
[User]-(Full Text Search Docs)
(Full Text Search Docs)>(Preview Doc)
(Full Text Search Docs)>(Download Docs)
[User]-(Browse Docs)
(Browse Docs)>(Preview Doc)
(Download Docs)
[Site Maintainer]-(Post New Event to the Web Site)
[User]-(View Events)

use-case diagram

Notes:

  • Unlike the class diagram syntax, the notes shall be surrounded by parenthesis rather than brackets.

Activity diagram

The following constructions were taken from the yuml.me page for activity diagrams:

Item Example
Start (start)
End (end)
Activity (Find Products)
Flow (start)->(Find Products)
Multiple Assoc. (start)->(Find Products)->(end)
Decisions (start)-><d1>
Decisions w/Label (start)-><d1>[logged in]->(Show Dashboard)
<d1>[not logged in]-> (Show Login Page)
Parallel (Action 1)->|a| <br>
and (Action 2)->|a|
Object node (Action)->[Object]

Example

// {type:activity}
// {generate:true}

(start)-><a>[kettle empty]->(Fill Kettle)->|b|
<a>[kettle full]->|b|->(Boil Kettle)->|c|
|b|->(Add Tea Bag)->(Add Milk)->|c|->(Pour Water)
(Pour Water)->(end)

activity diagram

Notes:

  • start and end are special labels (case-sensitive).
  • In contrast to the previous diagrams, this diagram syntax accepts concatenation of more than two elements.
  • The labels for decision diamonds and parallel bars are not shown.

State diagram

This syntax is not officially defined in yuml.me, and is inspired on the activity diagram:

Item Example
Start (start)
End (end)
Activity (Find Products)
Flow (start)->(Find Products)
Multiple Assoc. (start)->(Find Products)->(end)
Complex case (Simulator running)[Pause]->(Simulator paused)[Unpause]->(Simulator running)
Note (state)-(note: a note here)
// {type:state}
// {generate:true}

(start)[Start]->(Simulator running)
(Simulator running)[Pause]->(Simulator paused)
(Simulator running)[Stop]->(end)
(Log retrieval)[Continue]->(Simulator running)
(Simulator paused)[Unpause]->(Simulator running)
(Simulator paused)[Data requested]->(Log retrieval)
(Log retrieval)->(end)

state diagram

Deployment diagram

This syntax is not officially defined in yuml.me, and is inspired on the class diagram:

Item Example
Node [node1]
Association [node1]-[node2]
Labeled Assoc. [node1]label-[node2]
Note [node1]-[note: a note here]
// {type:deployment}
// {generate:true}

[Presentation Server]-[Policy Server]
[Policy Server]-[Document Server]
[Product Server]-[Document Server]
[Document Server]ASP.Net-[Workstation]
[Policy Server]-[Database Server]
[Product Server]-[Database Server]
[Policy Server]-[note: To be clustered to meet throughput needs{bg:cornsilk}]
[Policy Server]-[Directory Server]
[Policy Server]-[Underwriting & Rating Server]

deployment diagram

Notes:

  • The deployment diagram currently doesn't allow nesting nodes or components

Sequence diagram

This syntax is not officially defined in yuml.me, and is inspired on the class diagram:

Item Example
Object [Patron]
Message [Patron]order food>[Waiter]
Response [Waiter]serve wine.>[Patron]
Note [Actor]-[note: a note message]
Asynchronous [Patron]order food>>[Waiter]

Example


// {type:sequence}
// {generate:true}

[:Computer]sendUnsentEmail>[:Server]
[:Computer]newEmail>[:Server]
[:Server]reponse.>[:Computer]
[:Computer]downloadEmail>[:Server]
[:Computer]deleteOldEmail>[:Server]

sequence diagram

Notes

The following syntax is not yet implemented but will soon:


Open activation box at source [Source](message>[Dest]
Open activation box at dest [Source]message>([Dest]
Close activation at dest [Source]message>)[Dest]
Close activation at source [Source])message>[Dest]
Cancel activation box [Source])X

Package diagram

This syntax is not officially defined in yuml.me, and is inspired by the class diagram:

Item Example
Package [package1]
Association [package1]->[package2]
Labeled assoc [package1]label->[package2]
Note [package1]-[note: a note here]
// {type:package}
// {generate:true}

[Elegibility & Benefits]->[Elegibility Search]
[Remittances] -> [Remittance Search]
[Notifications] -> [Notification Search]
[Check Claim Status] -> [Claim Search]
[Submit a Claim Online] -> [Patient Search]
[Physician/Provider Directory]
[Remittance Search] -> [Search]
[Notification Search] -> [Search]
[Claim Search] -> [Search]
[Patient Search] -> [Search]
[Eligibility Search] -> [Search]

package diagram

Notes:

  • The package diagram currently doesn't allow nesting packages or classes

Color codes

Colors can be specified as hex values with the form #RRGGBB or with names. The names correspond to the X11 color coding.

The complete list of color names can be found at Wikipedia

Future diagrams

For other diagram types implemented subsequently, the syntax will be determined in the following order:

  • Look if there is a new definition in yuml.me.
  • Look for other contributors implementing their own yUML tools.
  • Derive a proposal from previous diagram syntaxes.

External links