Skip to content

Commit 02fb10a

Browse files
committed
doc : add state_management animated d2 schematic
1 parent 78fa2bf commit 02fb10a

4 files changed

Lines changed: 351 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ if( Qt6_FOUND )
9696
message( STATUS "Found Qt: ${Qt6_DIR} ${Qt6_VERSION}" )
9797
endif()
9898

99+
find_program( D2 NAMES d2 )
100+
if( D2 )
101+
message( STATUS "Found D2: ${D2}" )
102+
else()
103+
message( STATUS "Not found D2: Some parts of doc disabled" )
104+
endif()
105+
99106
if( CMakeUtils_FOUND )
100107
set( CMAKE_UTILS * )
101108
set( COVERAGE_GLOBAL_ONLY ON )
@@ -105,6 +112,7 @@ endif()
105112
add_subdirectory( "${CMAKE_SOURCE_DIR}/src" )
106113
add_subdirectory( "${CMAKE_SOURCE_DIR}/test" )
107114
add_subdirectory( "${CMAKE_SOURCE_DIR}/icon" )
115+
add_subdirectory( "${CMAKE_SOURCE_DIR}/doc" )
108116

109117
if( CMakeUtils_FOUND )
110118
coverage_global()

doc/CMakeLists.txt

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
add_custom_target( doc )
2+
3+
if( D2 )
4+
5+
set( D2_INDIVIDUAL_STEPS_FILES
6+
"${CMAKE_CURRENT_BINARY_DIR}/state_management/1.svg"
7+
"${CMAKE_CURRENT_BINARY_DIR}/state_management/2.svg"
8+
"${CMAKE_CURRENT_BINARY_DIR}/state_management/3.svg"
9+
"${CMAKE_CURRENT_BINARY_DIR}/state_management/4.svg"
10+
"${CMAKE_CURRENT_BINARY_DIR}/state_management/5.svg"
11+
"${CMAKE_CURRENT_BINARY_DIR}/state_management/6.svg"
12+
"${CMAKE_CURRENT_BINARY_DIR}/state_management/7.svg"
13+
"${CMAKE_CURRENT_BINARY_DIR}/state_management/8.svg"
14+
"${CMAKE_CURRENT_BINARY_DIR}/state_management/9.svg"
15+
"${CMAKE_CURRENT_BINARY_DIR}/state_management/10.svg"
16+
"${CMAKE_CURRENT_BINARY_DIR}/state_management/11.svg"
17+
"${CMAKE_CURRENT_BINARY_DIR}/state_management/12.svg"
18+
"${CMAKE_CURRENT_BINARY_DIR}/state_management/13.svg"
19+
"${CMAKE_CURRENT_BINARY_DIR}/state_management/14.svg"
20+
)
21+
22+
add_custom_command(
23+
OUTPUT ${D2_INDIVIDUAL_STEPS_FILES}
24+
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/state_management/index.svg"
25+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/state_management.d2"
26+
COMMAND ${D2}
27+
"${CMAKE_CURRENT_SOURCE_DIR}/state_management.d2"
28+
"${CMAKE_CURRENT_BINARY_DIR}/state_management.svg"
29+
2> /dev/null
30+
COMMENT
31+
"Generating individual steps state_management/*.svg"
32+
)
33+
34+
add_custom_command(
35+
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/state_management.svg"
36+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/state_management.d2"
37+
COMMAND ${D2}
38+
"${CMAKE_CURRENT_SOURCE_DIR}/state_management.d2"
39+
"${CMAKE_CURRENT_BINARY_DIR}/state_management.svg"
40+
--animate-interval=2000
41+
2> /dev/null
42+
COMMENT
43+
"Generating animated state_management.svg"
44+
)
45+
46+
add_custom_target( d2
47+
DEPENDS
48+
${D2_INDIVIDUAL_STEPS_FILES}
49+
"${CMAKE_CURRENT_BINARY_DIR}/state_management.svg"
50+
)
51+
52+
add_dependencies( doc d2 )
53+
54+
endif()

doc/state_management.d2

Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
classes {
2+
history {
3+
shape: circle
4+
width: 30
5+
height: 30
6+
}
7+
object {
8+
grid-rows: 1
9+
grid-gap: 0
10+
label.near: top-center
11+
}
12+
step1.style { stroke: blue; fill: blue }
13+
step2.style { stroke: blueviolet; fill: blueviolet }
14+
step3.style { stroke: chartreuse; fill: chartreuse }
15+
step4.style { stroke: coral; fill: coral }
16+
step5.style { stroke: cornflowerblue; fill: cornflowerblue }
17+
step6.style { stroke: crimson; fill: crimson }
18+
step7.style { stroke: darkmagenta; fill: darkmagenta }
19+
step8.style { stroke: darkorchid; fill: darkorchid }
20+
step9.style { stroke: darkturquoise; fill: darkturquoise }
21+
step10.style { stroke: darkviolet; fill: darkviolet }
22+
step11.style { stroke: deeppink; fill: deeppink }
23+
step12.style { stroke: deepskyblue; fill: deepskyblue }
24+
step13.style { stroke: dodgerblue; fill: dodgerblue }
25+
step14.style { stroke: gold; fill: gold }
26+
}
27+
28+
History {
29+
style.fill: transparent
30+
near: center-left
31+
}
32+
33+
Memory {
34+
style.fill: transparent
35+
near: center-right
36+
}
37+
38+
steps {
39+
1 {
40+
history {
41+
1 { class: [history; step1] }
42+
}
43+
memory {
44+
g { class: object; label: "global params" }
45+
g.0 { class: step1 }
46+
}
47+
}
48+
2 {
49+
history {
50+
2 { class: [history; step2] }
51+
1 -> 2
52+
}
53+
memory {
54+
p1 { class: object }; p1.0 { class: step2 }
55+
p1e1 { class: object; label: e1 }; p1e1.0 { class: step2 }
56+
p1e2 { class: object; label: e2 }; p1e2.0 { class: step2 }
57+
p1e3 { class: object; label: e3 }; p1e3.0 { class: step2 }
58+
p2 { class: object }; p2.0 { class: step2 }
59+
p2e1 { class: object; label: e1 }; p2e1.0 { class: step2 }
60+
p2e2 { class: object; label: e2 }; p2e2.0 { class: step2 }
61+
p2e3 { class: object; label: e3 }; p2e3.0 { class: step2 }
62+
p1 <- p1e1 { source-arrowhead: { shape: diamond; style.filled: true }; class: step2 }
63+
p1 <- p1e2 { source-arrowhead: { shape: diamond; style.filled: true }; class: step2 }
64+
p1 <- p1e3 { source-arrowhead: { shape: diamond; style.filled: true }; class: step2 }
65+
p2 <- p2e1 { source-arrowhead: { shape: diamond; style.filled: true }; class: step2 }
66+
p2 <- p2e2 { source-arrowhead: { shape: diamond; style.filled: true }; class: step2 }
67+
p2 <- p2e3 { source-arrowhead: { shape: diamond; style.filled: true }; class: step2 }
68+
}
69+
}
70+
3 {
71+
history {
72+
3 { class: [history; step3] }
73+
2 -> 3
74+
}
75+
memory {
76+
cce1 { class: object }; cce1.0 { class: step3 }
77+
cce1 <-> p1e1 { source-arrowhead: { shape: diamond }; target-arrowhead: { shape: none; }; class: step3 }
78+
cce1 <-> p1e2 { source-arrowhead: { shape: diamond }; target-arrowhead: { shape: none; }; class: step3 }
79+
cce1 <-> p2e3 { source-arrowhead: { shape: diamond }; target-arrowhead: { shape: none; }; class: step3 }
80+
}
81+
}
82+
4 {
83+
history {
84+
4 { class: [history; step4] }
85+
3 -> 4
86+
}
87+
memory {
88+
cce2 { class: object }; cce2.0 { class: step4 }
89+
cce2 <-> p2e2 { source-arrowhead: { shape: diamond }; target-arrowhead: { shape: none; }; class: step4 }
90+
cce2 <-> p1e3 { source-arrowhead: { shape: diamond }; target-arrowhead: { shape: none; }; class: step4 }
91+
}
92+
}
93+
5 {
94+
history {
95+
5 { class: [history; step5] }
96+
4 -> 5
97+
}
98+
memory {
99+
mlp1 { class: object }; mlp1.0 { class: step5 }
100+
mlp2 { class: object }; mlp2.0 { class: step5 }
101+
mlp3 { class: object }; mlp3.0 { class: step5 }
102+
mlp1 -- cce1 { class: step5 }
103+
mlp2 -- cce2 { class: step5 }
104+
mlp3 -- p2e1 { class: step5 }
105+
}
106+
}
107+
6 {
108+
history {
109+
6 { class: [history; step6] }
110+
5 -> 6
111+
}
112+
memory {
113+
ctcmlp1 { class: object }; ctcmlp1.0 { class: step6 }
114+
ctcmlp1 -- mlp1 { class: step6 }
115+
ctcmlp1 -- mlp2 { class: step6 }
116+
}
117+
}
118+
7 {
119+
history {
120+
7 { class: [history; step7] }
121+
6 -> 7
122+
}
123+
memory {
124+
mlp4 { class: object }; mlp4.0 { class: step7 }
125+
mlp4 -- ctcmlp1 { class: step7 }
126+
}
127+
}
128+
8 {
129+
history {
130+
8 { class: [history; step8] }
131+
7 -> 8
132+
}
133+
memory {
134+
i1 { class: object }; i1.0 { class: step8 }
135+
i1 -- mlp3 { class: step8 }
136+
i1 -- mlp4 { class: step8 }
137+
}
138+
}
139+
9 {
140+
history {
141+
9 { class: [history; step9] }
142+
8 -> 9
143+
}
144+
memory {
145+
i1.0.style.opacity: 0.3
146+
i1.1 { class: step9 }
147+
m1 { class: object }; m1.0 { class: step9 }
148+
m2 { class: object }; m2.0 { class: step9 }
149+
m3 { class: object }; m3.0 { class: step9 }
150+
m4 { class: object }; m4.0 { class: step9 }
151+
m5 { class: object }; m5.0 { class: step9 }
152+
m6 { class: object }; m6.0 { class: step9 }
153+
m7 { class: object }; m7.0 { class: step9 }
154+
m8 { class: object }; m8.0 { class: step9 }
155+
m9 { class: object }; m9.0 { class: step9 }
156+
m1 -- i1 { class: step9 }
157+
m2 -- i1 { class: step9 }
158+
m3 -- i1 { class: step9 }
159+
m4 -- i1 { class: step9 }
160+
m5 -- i1 { class: step9 }
161+
m6 -- i1 { class: step9 }
162+
m7 -- i1 { class: step9 }
163+
m8 -- i1 { class: step9 }
164+
m9 -- i1 { class: step9 }
165+
}
166+
}
167+
10 {
168+
history {
169+
6.style.opacity: 0.3
170+
7.style.opacity: 0.3
171+
8.style.opacity: 0.3
172+
9.style.opacity: 0.3
173+
10 { class: [history; step10] }
174+
5 -> 10
175+
}
176+
memory {
177+
ctcmlp1.style.opacity: 0.3; ctcmlp1.*.style.opacity: 0.3
178+
mlp4.style.opacity: 0.3; mlp4.*.style.opacity: 0.3
179+
i1.style.opacity: 0.3; i1.*.style.opacity: 0.3
180+
m1.style.opacity: 0.3; m1.*.style.opacity: 0.3
181+
m2.style.opacity: 0.3; m2.*.style.opacity: 0.3
182+
m3.style.opacity: 0.3; m3.*.style.opacity: 0.3
183+
m4.style.opacity: 0.3; m4.*.style.opacity: 0.3
184+
m5.style.opacity: 0.3; m5.*.style.opacity: 0.3
185+
m6.style.opacity: 0.3; m6.*.style.opacity: 0.3
186+
m7.style.opacity: 0.3; m7.*.style.opacity: 0.3
187+
m8.style.opacity: 0.3; m8.*.style.opacity: 0.3
188+
m9.style.opacity: 0.3; m9.*.style.opacity: 0.3
189+
(ctcmlp1 -- mlp1)[0].style.opacity: 0.3
190+
(ctcmlp1 -- mlp2)[0].style.opacity: 0.3
191+
(mlp4 -- ctcmlp1)[0].style.opacity: 0.3
192+
(i1 -- mlp3)[0].style.opacity: 0.3
193+
(i1 -- mlp4)[0].style.opacity: 0.3
194+
(m1 -- i1)[0].style.opacity: 0.3
195+
(m2 -- i1)[0].style.opacity: 0.3
196+
(m3 -- i1)[0].style.opacity: 0.3
197+
(m4 -- i1)[0].style.opacity: 0.3
198+
(m5 -- i1)[0].style.opacity: 0.3
199+
(m6 -- i1)[0].style.opacity: 0.3
200+
(m7 -- i1)[0].style.opacity: 0.3
201+
(m8 -- i1)[0].style.opacity: 0.3
202+
(m9 -- i1)[0].style.opacity: 0.3
203+
g.0.style.opacity: 0.3
204+
g.1 { class: step10 }
205+
}
206+
}
207+
11 {
208+
history {
209+
11 { class: [history; step11] }
210+
10 -> 11
211+
}
212+
memory {
213+
i2 { class: object }; i2.0 { class: step11 }
214+
i2 -- mlp1 { class: step11 }
215+
i2 -- mlp2 { class: step11 }
216+
i3 { class: object }; i3.0 { class: step11 }
217+
i3 -- mlp1 { class: step11 }
218+
i3 -- mlp3 { class: step11 }
219+
}
220+
}
221+
12 {
222+
history {
223+
12 { class: [history; step12] }
224+
11 -> 12
225+
}
226+
memory {
227+
i2.0.style.opacity: 0.3
228+
i2.1 { class: step12 }
229+
m10 { class: object }; m10.0 { class: step12 }
230+
m11 { class: object }; m11.0 { class: step12 }
231+
m12 { class: object }; m12.0 { class: step12 }
232+
m13 { class: object }; m13.0 { class: step12 }
233+
m14 { class: object }; m14.0 { class: step12 }
234+
m10 -- i2 { class: step12 }
235+
m11 -- i2 { class: step12 }
236+
m12 -- i2 { class: step12 }
237+
m13 -- i2 { class: step12 }
238+
m14 -- i2 { class: step12 }
239+
}
240+
}
241+
13 {
242+
history {
243+
13 { class: [history; step13] }
244+
12 -> 13
245+
}
246+
memory {
247+
i3.0.style.opacity: 0.3
248+
i3.1 { class: step13 }
249+
m15 { class: object }; m15.0 { class: step13 }
250+
m16 { class: object }; m16.0 { class: step13 }
251+
m17 { class: object }; m17.0 { class: step13 }
252+
m18 { class: object }; m18.0 { class: step13 }
253+
m19 { class: object }; m19.0 { class: step13 }
254+
m15 -- i3 { class: step13 }
255+
m16 -- i3 { class: step13 }
256+
m17 -- i3 { class: step13 }
257+
m18 -- i3 { class: step13 }
258+
m19 -- i3 { class: step13 }
259+
}
260+
}
261+
14 {
262+
history {
263+
13.style.opacity: 0.3
264+
14 { class: [history; step14] }
265+
12 -> 14
266+
}
267+
memory {
268+
m15.style.opacity: 0.3; m15.*.style.opacity: 0.3
269+
m16.style.opacity: 0.3; m16.*.style.opacity: 0.3
270+
m17.style.opacity: 0.3; m17.*.style.opacity: 0.3
271+
m18.style.opacity: 0.3; m18.*.style.opacity: 0.3
272+
m19.style.opacity: 0.3; m19.*.style.opacity: 0.3
273+
(m15 -- i3)[0].style.opacity: 0.3
274+
(m16 -- i3)[0].style.opacity: 0.3
275+
(m17 -- i3)[0].style.opacity: 0.3
276+
(m18 -- i3)[0].style.opacity: 0.3
277+
(m19 -- i3)[0].style.opacity: 0.3
278+
i3.1.style.opacity: 0.3
279+
i3.2 { class: step14 }
280+
m20 { class: object }; m20.0 { class: step14 }
281+
m21 { class: object }; m21.0 { class: step14 }
282+
m22 { class: object }; m22.0 { class: step14 }
283+
m20 -- i3 { class: step14 }
284+
m21 -- i3 { class: step14 }
285+
m22 -- i3 { class: step14 }
286+
}
287+
}
288+
}

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565

6666
doc = pkgs.mkShell {
6767
packages = [
68+
pkgs.d2
6869
(pkgs.python3.withPackages (python-pkgs: [
6970
python-pkgs.numpy
7071
python-pkgs.matplotlib

0 commit comments

Comments
 (0)