Skip to content

Commit

Permalink
Merge pull request #7 from eNeRGy164/more-examples-and-functions
Browse files Browse the repository at this point in the history
More examples and functions
  • Loading branch information
eNeRGy164 authored Sep 5, 2023
2 parents cc748a5 + 7b6b4c2 commit 80e0b82
Show file tree
Hide file tree
Showing 33 changed files with 2,235 additions and 676 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.x
dotnet-version: |
6.x
7.x
- name: Install dependencies
run: dotnet restore
Expand Down
40 changes: 23 additions & 17 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Following the PlantUML source code.
| caption \<CAPTION> | no | |
| legend [\<ALIGN>] | no | |
| endlegend | no | |
| skinparam \<NAME> \<VALUE> | yes | `SkinParam` |
| skinparam \<PREFIX> { | no | |
| left to right direction | yes | `Direction` |
| top to bottom direction | yes | `Direction` |

## Activity Diagrams

Expand Down Expand Up @@ -102,8 +106,10 @@ Following the PlantUML source code.
| end box | yes | `BoxEnd` |
| delay [\<LABEL>] | yes | `Delay` |
| divider [\<LABEL>] | yes | `Divider` |
| hide footbox | no | |
| show footbox | no | |
| hide footbox | yes | `HideFootBox` |
| show footbox | yes | `ShowFootBox` |
| hide unlinked | yes | `HideUnlinked` |
| show unlinked | yes | `ShowUnlinked` |
| opt [\<COLOR>] [\<COMMENT>] | no | |
| end | yes | `GroupEnd` |
| alt [\<COLOR>] [\<COMMENT>] | partial | `AltStart` |
Expand All @@ -127,21 +133,21 @@ Following the PlantUML source code.
| ignore newpage | no | |
| newpage [\<TITLE>] | yes | `NewPage` |
| create [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Create` |
| participant \<NAME> [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Participant` |
| actor \<NAME> [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Actor` |
| create actor \<NAME> [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `CreateActor` |
| boundary \<NAME> [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Boundary` |
| create boundary \<NAME> [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `CreateBoundary` |
| collections \<NAME> [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Collections` |
| create collections \<NAME> [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `CreateCollections` |
| control \<NAME> [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Control` |
| create control \<NAME> [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `CreateControl` |
| entity \<NAME> [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Entity` |
| create entity \<NAME> [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `CreateEntity` |
| database \<NAME> [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Database` |
| create database \<NAME> [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `CreateDatabase` |
| queue \<NAME> [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Queue` |
| create queue \<NAME> [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `CreateQueue` |
| participant \<NAME> [\<STEREO>] [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Participant` |
| actor \<NAME> [\<STEREO>] [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Actor` |
| create actor \<NAME> [\<STEREO>] [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `CreateActor` |
| boundary \<NAME> [\<STEREO>] [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Boundary` |
| create boundary \<NAME> [\<STEREO>] [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `CreateBoundary` |
| collections \<NAME> [\<STEREO>] [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Collections` |
| create collections \<NAME> [\<STEREO>] [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `CreateCollections` |
| control \<NAME> [\<STEREO>] [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Control` |
| create control \<NAME> [\<STEREO>] [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `CreateControl` |
| entity \<NAME> [\<STEREO>] [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Entity` |
| create entity \<NAME> [\<STEREO>] [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `CreateEntity` |
| database \<NAME> [\<STEREO>] [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Database` |
| create database \<NAME> [\<STEREO>] [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `CreateDatabase` |
| queue \<NAME> [\<STEREO>] [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `Queue` |
| create queue \<NAME> [\<STEREO>] [order \<ORDER>] [\<URL>] [\<COLOR>] | partial | `CreateQueue` |
| ref[\<COLOR>] over \<NAME>[,\<NAME>] : [\<URL>] [\<TEXT>] | partial | `Ref` |
| ref[\<COLOR>] over \<NAME>[,\<NAME>] | partial | `StartRef` |
| end ref | yes | `EndRef` |
Expand Down
9 changes: 9 additions & 0 deletions src/PlantUml.Builder/Constant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,24 @@ public static class Words
public const string Alt = "alt";
public const string As = "as";
public const string Auto = "auto";
public const string Bottom = "bottom";
public const string Box = "box";
public const string Create = "create";
public const string Deactivate = "deactivate";
public const string Destroy = "destroy";
public const string Direction = "direction";
public const string Else = "else";
public const string Empty = "empty";
public const string End = "end";
public const string Extends = "extends";
public const string Footbox = "footbox";
public const string Footer = "footer";
public const string Group = "group";
public const string Header = "header";
public const string Hide = "hide";
public const string Implements = "implements";
public const string Increase = "inc";
public const string Left = "left";
public const string Loop = "loop";
public const string Map = "map";
public const string Mixing = "mixing";
Expand All @@ -95,13 +99,18 @@ public static class Words
public const string Ref = "ref";
public const string Resume = "resume";
public const string Return = "return";
public const string Right = "right";
public const string Separator = "separator";
public const string Set = "set";
public const string Show = "show";
public const string SkinParam = "skinparam";
public const string Start = "start";
public const string Static = "static";
public const string Stop = "stop";
public const string Title = "title";
public const string To = "to";
public const string Top = "top";
public const string Unlinked = "unlinked";
public const string Uml = "uml";
}

Expand Down
19 changes: 19 additions & 0 deletions src/PlantUml.Builder/DiagramDirection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace PlantUml.Builder
{
/// <summary>
/// Represents different directions of the UML diagram.
/// </summary>
public enum DiagramDirection
: byte
{
/// <summary>
/// Represents a left to right direction.
/// </summary>
LeftToRight = 0,

/// <summary>
/// Represents a top to bottom direction.
/// </summary>
TopToBottom,
}
}
13 changes: 7 additions & 6 deletions src/PlantUml.Builder/SequenceDiagrams/ParticipantName.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
using System.Text.RegularExpressions;
using static System.Text.RegularExpressions.RegexOptions;

namespace PlantUml.Builder.SequenceDiagrams;

public class ParticipantName
{
private static readonly Regex nameAlias = new("^(?:[\"]?(?<Name>[^\"]+)(?:[\"][\\s]*|[\\s]+)as[\\s]+(?<Alias>[^\"\\s]+)|(?<Alias>[^\"\\s]+)[\\s]+as(?:[\\s]*[\"]|[\\s]+)(?<Name>[^\"]+)[\"]?|[\"]?(?<Name>[^\"]+)[\"]?)$", RegexOptions.Singleline | RegexOptions.Compiled);
private const string ValidNameChars = "0123456789_@.";
private static readonly Regex nameAlias = new("^(?:[\"]?(?<Name>[^\"]+)(?:[\"][\\s]*|[\\s]+)as[\\s]+(?<Alias>[^\"\\s]+)|(?<Alias>[^\"\\s]+)[\\s]+as(?:[\\s]*[\"]|[\\s]+)(?<Name>[^\"]+)[\"]?|[\"]?(?<Name>[^\"]+)[\"]?)$", Singleline | Compiled);
private static readonly HashSet<char> validNameChars = new("0123456789_@.".ToCharArray());

public string Name { get; private set; }

public string Alias { get; private set; } = string.Empty;

internal static readonly ParticipantName Outside = new(string.Empty + ArrowParts.LeftExternal + ArrowParts.RightExternal);

public ParticipantName(string name)
: this(name, default)
{
Expand Down Expand Up @@ -80,9 +79,11 @@ private static string FormatLongName(string name)

private static bool MustBeQuoted(string name)
{
foreach (var c in name)
for (int i = 0; i < name.Length; i++)
{
if (char.IsLetter(c) || ValidNameChars.IndexOf(c) > -1)
char c = name[i];

if (char.IsLetter(c) || validNameChars.Contains(c))
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ public static partial class StringBuilderExtensions
/// <param name="displayName">Optional display name of the actor.</param>
/// <param name="color">Optional color of the actor.</param>
/// <param name="order">Optional order of the actor.</param>
/// <param name="stereotype">Optional stereotype of the actor.</param>
/// <param name="customSpot">Optional custom spot of the stereotype.</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="stringBuilder"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">Thrown when <paramref name="name"/> is <see langword="null"/>, empty of only white space.</exception>
public static void Actor(this StringBuilder stringBuilder, string name, string displayName = null, Color color = null, int? order = null)
public static void Actor(this StringBuilder stringBuilder, string name, string displayName = null, Color color = null, int? order = null, string stereotype = default, CustomSpot customSpot = default)
{
stringBuilder.ParticipantBase(ParticipantType.Actor, new ParticipantName(name, displayName), color, order);
stringBuilder.ParticipantBase(ParticipantType.Actor, new ParticipantName(name, displayName), color, order, stereotype, customSpot);
}

/// <summary>
Expand All @@ -23,10 +25,12 @@ public static void Actor(this StringBuilder stringBuilder, string name, string d
/// <param name="displayName">Optional display name of the actor.</param>
/// <param name="color">Optional color of the actor.</param>
/// <param name="order">Optional order of the actor.</param>
/// <param name="stereotype">Optional stereotype of the actor.</param>
/// <param name="customSpot">Optional custom spot of the stereotype.</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="stringBuilder"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">Thrown when <paramref name="name"/> is <see langword="null"/>, empty of only white space.</exception>
public static void CreateActor(this StringBuilder stringBuilder, string name, string displayName = null, Color color = null, int? order = null)
public static void CreateActor(this StringBuilder stringBuilder, string name, string displayName = null, Color color = null, int? order = null, string stereotype = default, CustomSpot customSpot = default)
{
stringBuilder.CreateParticipantBase(new ParticipantName(name, displayName), ParticipantType.Actor, color, order);
stringBuilder.CreateParticipantBase(new ParticipantName(name, displayName), ParticipantType.Actor, color, order, stereotype, customSpot);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ public static partial class StringBuilderExtensions
/// <param name="displayName">Optional display name of the boundary.</param>
/// <param name="color">Optional color of the boundary.</param>
/// <param name="order">Optional order of the boundary.</param>
/// <param name="stereotype">Optional stereotype of the boundary.</param>
/// <param name="customSpot">Optional custom spot of the stereotype.</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="stringBuilder"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">Thrown when <paramref name="name"/> is <see langword="null"/>, empty of only white space.</exception>
public static void Boundary(this StringBuilder stringBuilder, string name, string displayName = null, Color color = null, int? order = null)
public static void Boundary(this StringBuilder stringBuilder, string name, string displayName = null, Color color = null, int? order = null, string stereotype = default, CustomSpot customSpot = default)
{
stringBuilder.ParticipantBase(ParticipantType.Boundary, new ParticipantName(name, displayName), color, order);
stringBuilder.ParticipantBase(ParticipantType.Boundary, new ParticipantName(name, displayName), color, order, stereotype, customSpot);
}

/// <summary>
Expand All @@ -23,10 +25,12 @@ public static void Boundary(this StringBuilder stringBuilder, string name, strin
/// <param name="displayName">Optional display name of the boundary.</param>
/// <param name="color">Optional color of the boundary.</param>
/// <param name="order">Optional order of the boundary.</param>
/// <param name="stereotype">Optional stereotype of the boundary.</param>
/// <param name="customSpot">Optional custom spot of the stereotype.</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="stringBuilder"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">Thrown when <paramref name="name"/> is <see langword="null"/>, empty of only white space.</exception>
public static void CreateBoundary(this StringBuilder stringBuilder, string name, string displayName = null, Color color = null, int? order = null)
public static void CreateBoundary(this StringBuilder stringBuilder, string name, string displayName = null, Color color = null, int? order = null, string stereotype = default, CustomSpot customSpot = default)
{
stringBuilder.CreateParticipantBase(new ParticipantName(name, displayName), ParticipantType.Boundary, color, order);
stringBuilder.CreateParticipantBase(new ParticipantName(name, displayName), ParticipantType.Boundary, color, order, stereotype, customSpot);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ public static partial class StringBuilderExtensions
/// <param name="displayName">Optional display name of the collections.</param>
/// <param name="color">Optional color of the collections.</param>
/// <param name="order">Optional order of the collections.</param>
/// <param name="stereotype">Optional stereotype of the collections.</param>
/// <param name="customSpot">Optional custom spot of the stereotype.</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="stringBuilder"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">Thrown when <paramref name="name"/> is <see langword="null"/>, empty of only white space.</exception>
public static void Collections(this StringBuilder stringBuilder, string name, string displayName = null, Color color = null, int? order = null)
public static void Collections(this StringBuilder stringBuilder, string name, string displayName = null, Color color = null, int? order = null, string stereotype = default, CustomSpot customSpot = default)
{
stringBuilder.ParticipantBase(ParticipantType.Collections, new ParticipantName(name, displayName), color, order);
stringBuilder.ParticipantBase(ParticipantType.Collections, new ParticipantName(name, displayName), color, order, stereotype, customSpot);
}

/// <summary>
Expand All @@ -23,10 +25,12 @@ public static void Collections(this StringBuilder stringBuilder, string name, st
/// <param name="displayName">Optional display name of the collections.</param>
/// <param name="color">Optional color of the collections.</param>
/// <param name="order">Optional order of the collections.</param>
/// <param name="stereotype">Optional stereotype of the collections.</param>
/// <param name="customSpot">Optional custom spot of the stereotype.</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="stringBuilder"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">Thrown when <paramref name="name"/> is <see langword="null"/>, empty of only white space.</exception>
public static void CreateCollections(this StringBuilder stringBuilder, string name, string displayName = null, Color color = null, int? order = null)
public static void CreateCollections(this StringBuilder stringBuilder, string name, string displayName = null, Color color = null, int? order = null, string stereotype = default, CustomSpot customSpot = default)
{
stringBuilder.CreateParticipantBase(new ParticipantName(name, displayName), ParticipantType.Collections, color, order);
stringBuilder.CreateParticipantBase(new ParticipantName(name, displayName), ParticipantType.Collections, color, order, stereotype, customSpot);
}
}
Loading

0 comments on commit 80e0b82

Please sign in to comment.