yUML syntax

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

Comments and directives

The following extension 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: class, activity, usecase, state, deployment, package, sequence
    Example: // {type:class}

  • 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:

Class         [Customer]
Directional   [Customer]->[Order]
Bidirectional [Customer]<->[Order]
Aggregation   [Customer]+-[Order] or [Customer]<>-[Order]
Composition   [Customer]++-[Order]
Inheritance   [Customer]^[Cool Customer], [Customer]^[Uncool 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}]
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:

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

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)   and   <d1>not logged in->(Show Login Page)
Parallel           (Action 1)->|a|   and   (Action 2)->|a|
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:

Start	         (start)
End              (end)
Activity         (Find Products)
Flow	         (start)->(Find Products)
Multiple Assoc.  (start)->(Find Products)->(end)
Complex case     (Simulator running)[Pause]->(Simulator paused|do/wait)[Unpause]->(Simulator running)
Note             (state)-(note: a note here)

Deployment diagram

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

Node           [node1]
Association    [node1]-[node2]
Labeled Assoc. [node1]label-[node2]
Note           [node1]-[note: a note here]
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:

Object       [Patron]
Message      [Patron]order food>[Waiter]
Response     [Waiter]serve wine.>[Patron]
Note         [Actor]-[note: a note message]
Asynchronous [Patron]order food>>[Waiter]
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 on the class diagram:

Package        [package1]
Association    [package1]->[package2]
Labeled assoc  [package1]label->[package2]
Note           [package1]-[note: a note here]
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.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值