Skip to content

Commit 9493809

Browse files
author
Maxim Muratov
committed
добавлены примеры для кликабельных линков и пользовательского DSL
1 parent 5cea95b commit 9493809

6 files changed

Lines changed: 223 additions & 0 deletions

File tree

src/customdsl/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Пример кастомного DSL
2+
3+
**Цель примера:** Представить пример кастомного DSL для отображения контекстных диаграмм
4+
5+
Пользовательский DSL должен имплементировать следующий интерфейс
6+
7+
**отображение региона**
8+
!unquoted procedure $Region($alias, $label, $type)
9+
!endprocedure
10+
11+
**отображение заголовка**
12+
!unquoted procedure $Header($Title="Header", !endprocedure
13+
!endprocedure
14+
15+
**начало отображения элемента**
16+
!unquoted procedure $Entity($entity, $ACName, $id, $ACType)
17+
!endprocedure
18+
19+
**конец отображения элемента**
20+
!unquoted procedure $EntityEnd($entity)
21+
!endprocedure
22+
23+
**отображения аспекта элемента**
24+
!unquoted procedure $EntityAspect($entity, $prop)
25+
!endprocedure
26+
27+
**отображение расширения элемента**
28+
!unquoted procedure $EntityExpand($entity, $ID)
29+
!endprocedure
30+
31+
**для включения пользовательского DSL в контексте, необходимо задекларировать шаблон в контексте**

src/customdsl/dochub.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
components:
2+
systems.a:
3+
entity: system
4+
title: Система 1
5+
links:
6+
- id: systems.b
7+
description: Это ссылка П1
8+
direction: -->
9+
title: П1
10+
systems.b:
11+
entity: system
12+
title: Система 2
13+
links:
14+
- id: systems.a
15+
description: Это ссылка П2
16+
direction: -->
17+
title: П2
18+
contexts:
19+
example:
20+
title: Пример пользовательского DSL
21+
location: Пример пользовательского DSL для контекста
22+
extra-links: true
23+
uml:
24+
$dsl: dsl.puml
25+
components:
26+
- systems.*

src/customdsl/dsl.puml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
2+
3+
allow_mixing
4+
5+
'Общее позиционирование
6+
skinparam {
7+
wrapWidth 200
8+
maxMessageSize 200
9+
'hide stereotype
10+
defaultfontname arial
11+
roundCorner 10
12+
linetype ortho
13+
'linetype polyline
14+
'nodesep 100
15+
'ranksep 100
16+
shadowing false
17+
'padding 0
18+
hyperlinkColor black
19+
hyperlinkUnderline false
20+
}
21+
'left to right direction
22+
hide circle
23+
24+
25+
'Стиль стрелки
26+
skinparam arrow {
27+
color black
28+
thickness 1
29+
}
30+
31+
skinparam note {
32+
bordercolor #4e4948
33+
backgroundcolor pink
34+
}
35+
36+
!unquoted procedure $Region($alias, $label, $type)
37+
!if ($type)
38+
Boundary($alias , "$label", $type)
39+
!else
40+
Boundary($alias , "$label")
41+
!endif
42+
!endprocedure
43+
44+
!unquoted procedure $Header($Title="Header", $Authors="Name", $Version="0.1", $Date="01.01.1999")
45+
header
46+
!if ($Authors)
47+
Authors: $Authors
48+
!endif
49+
!if ($Version)
50+
Version: $Version
51+
!endif
52+
!if ($Date)
53+
Date: $Date
54+
!endif
55+
56+
endheader
57+
58+
hide empty members
59+
60+
title $Title
61+
!endprocedure
62+
63+
!unquoted procedure $Entity($entity, $ACName, $id, $ACType)
64+
!if ($entity == "database")
65+
!if ($ACType == "Внешняя")
66+
SystemDb_Ext($id, $ACName)
67+
!else
68+
SystemDb($id, $ACName)
69+
!endif
70+
!elseif ($entity == "actor" || $entity == "person")
71+
!if ($ACType == "Внешняя")
72+
Person_Ext($id, $ACName)
73+
!else
74+
Person($id, $ACName)
75+
!endif
76+
!else
77+
!if ($ACType == "Внешняя")
78+
System_Ext($id, $ACName)
79+
!else
80+
System($id, $ACName)
81+
!endif
82+
!endif
83+
!endprocedure
84+
85+
!unquoted procedure $EntityEnd($entity)
86+
!endprocedure
87+
88+
!unquoted procedure $EntityAspect($entity, $prop)
89+
!endprocedure
90+
91+
!unquoted procedure $EntityExpand($entity, $ID)
92+
!endprocedure

src/links/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Пример детального описания линков на контекстной диаграмме
2+
3+
**Цель примера:** Представить пример контекстной диаграммы
4+

src/links/dochub.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
components:
2+
systems.a:
3+
entity: system
4+
title: Система 1
5+
links:
6+
- id: systems.b
7+
description: Это ссылка П1
8+
direction: -->
9+
title: П1
10+
systems.b:
11+
entity: system
12+
title: Система 2
13+
links:
14+
- id: systems.a
15+
description: Это ссылка П2
16+
direction: -->
17+
title: П2
18+
datasets:
19+
arch.context:
20+
source: >
21+
(
22+
$components := $.components;
23+
$components:= $mergedeep($components.$spread().{
24+
"src_id": $keys()[0],
25+
"src": $.*
26+
}.(
27+
$exists(src.links) ? (
28+
{ src_id: $merge([src,
29+
{
30+
"links": $append([],
31+
src.links.(
32+
$exists($.title) ? (
33+
$merge([$,
34+
{
35+
"title": "[[/docs/arch.tech.flows.single?flow=" & $.title & " " & $.title & "]]"
36+
}
37+
]);
38+
) : (
39+
$
40+
)
41+
)
42+
)
43+
}
44+
])}
45+
):(
46+
{ src_id : src }
47+
)
48+
));
49+
$merge([$, {"components": $mergedeep([$components, $links])}]);
50+
)
51+
contexts:
52+
example:
53+
title: Пример ссылок
54+
location: Пример ссылок
55+
extra-links: true
56+
source: arch.context
57+
components:
58+
- systems.*
59+
docs:
60+
arch.tech.flows.single:
61+
type: markdown
62+
template: single.md
63+
source: >
64+
(
65+
$.components.*.links[title=$params.flow]
66+
)

src/links/single.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**Описание**:
2+
{{#description}}
3+
{{.}}
4+
{{/description}}

0 commit comments

Comments
 (0)