needsequence

Added in version 0.5.5.

needsequence adds a sequence-chart to your documentation.

Example 1

.. needsequence:: My sequence chart
   :start: USER_A, USER_D
   :link_types: links, triggers
Show the needs used in the above example
User: Mr. A USER_A
style: blue_border
links outgoing: ACT_ISSUE
links incoming: ACT_INFORM
Action: Creates issue ACT_ISSUE
style: yellow_border
links outgoing: USER_B
links incoming: USER_A
User: Ms. B USER_B
style: blue_border
links outgoing: ACT_ANALYSIS, ACT_SOLUTION
links incoming: ACT_ANALYSIS, ACT_ISSUE
Action: Analysis issue ACT_ANALYSIS
style: yellow_border
links outgoing: USER_B
links incoming: USER_B
Action: Provides solution ACT_SOLUTION
style: yellow_border
links outgoing: USER_C
links incoming: USER_B
User: Expert C USER_C
style: blue_border
links outgoing: ACT_INFORM, ACT_REVIEW
links incoming: ACT_REVIEW, ACT_SOLUTION
Action: Reviews solution ACT_REVIEW
style: yellow_border
links outgoing: USER_C
links incoming: USER_C
Action: Informs reporter ACT_INFORM
style: yellow_border
links outgoing: USER_A
links incoming: USER_C
User: Office Dog USER_D
style: blue_border
triggers: ACT_BARKS
triggered by: ACT_BARKS
Action: Barks for support ACT_BARKS
style: yellow_border
triggers: USER_D
triggered by: USER_D

Sequence diagrams supports special needs-combinations, in which one type represents some kind of a participant and another, linked need is representing the message.
Examples for this relationship are: Sender-Receiver communication , Role-Activity processes or Tool-Artifact relations.

needsequence needs at least one start-need, defined by its id in the :start: option.

The first need represents the participant. The next, linked need(s) is representing the message. Needs linked from a message are interpreted as participant again and so on.
So the linking must be really clean to get nice, meaningful sequence diagrams out of it.

The used need-type is unimportant.

@startuml

skinparam defaultTextAlignment center

rectangle "Interpreted as\n**PARTICIPANT 1**\n(start)" as p1 #ccc
rectangle "Interpreted as\n**PARTICIPANT 2**" as p2 #ccc
rectangle "Interpreted as\n**PARTICIPANT 3**" as p3 #ccc


rectangle "Interpreted as\n**MESSAGE 1**" as m1 #ffcc00
rectangle "Interpreted as\n**MESSAGE1 **" as m2 #ffcc00

p1 -> m1 : link
m1 -> p2 : link
p2 -> m2 : link
m2 -> p3 : link
@enduml

Participant-Message flow

The above, linked example gets interpreted for needsequence as follows:

@startuml

participant "Participant 1\n (start)" as p1
participant "Participant 2" as p2
participant "Participant 3" as p3

p1 -> p2: Message 1
p2 -> p3: Message 2

@enduml

Options

Some further options are accepted only for ubCode compatibility, and are otherwise ignored.

start

The :start: option takes a comma separated list of need ids and uses it as the starting point for further examination of sequence data.

First need of :start: gets painted first. The need includes all related messages and other participants.

After the first need, we take the next need id from the :start: option. And if it was not already part of the prior examination, we handle it the same way, otherwise, we ignore it.

filter

You can use the :filter: option to filter participants. We ignore all participants that does not fulfill the filter_string. See Filter string for more information.

Default: None (no active filtering)

You can use this function to filter out a specific participant. As an example, we use the same needsequence from the beginning, but without USER_C / Expert:

Example 2

.. needsequence:: My filtered sequence chart
   :start: USER_A, USER_D
   :link_types: links, triggers
   :filter: "Expert" not in title

max_items

Added in version 8.4.0.

The maximum number of messages to show.

The limit counts messages, that is the arrows of the diagram, and not participants: a message need that is linked to three receivers draws three arrows and so counts three times. We stop the diagram once it has that many messages, and tell the reader how many messages it is hiding. A truncated view says so in the page and emits a needs.max_items warning, so that a build does not have to be read page by page to find it; a project that caps deliberately can silence the warning with suppress_warnings = ["needs.max_items"]. A participant is only drawn if it sends one of the messages that are shown.

:max_items: 0 means no limit, also for a project that sets needs_views_max_items. Without the option, the diagram shows as many messages as that configuration allows.

Example 3

.. needsequence:: My shortened sequence chart
   :start: USER_A, USER_D
   :link_types: links, triggers
   :max_items: 3

@startuml

' Nodes definition 

participant "Mr. A" as USER_A
participant "Ms. B" as USER_B
participant "Expert C" as USER_C

' Connection definition 

USER_A -> USER_B: Creates issue
USER_B -> USER_B: Analysis issue
USER_B -> USER_C: Provides solution

@enduml

My shortened sequence chart

Showing the first 3 of 6 messages; refine the filter or set :max_items: (0 for all).