Skip to content

Commit 6a4f9c7

Browse files
WIP: Add initial version of DD-make call-graph in hidden documentation
1 parent 225e8fc commit 6a4f9c7

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
"sphinx_rtd_theme", # Theme
122122
"recommonmark", # For markdown support, does not support 'full' CommonMark syntax (yet)!
123123
"sphinx_autodoc_typehints", # Auto-parse type hints. Napoleon BEFORE typehints
124+
"sphinxcontrib.mermaid", # Draw graphs using Mermaid.js
124125
]
125126

126127
# Add any paths that contain templates here, relative to this directory.

docs/source/dd_load_callgraph.rst

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
.. mermaid::
2+
3+
flowchart TD
4+
A[shot, run] --> root
5+
R[Reference shot\nReference run] --> root
6+
V[Version in memory e.g. 3.38.1] --> VOX
7+
X[XML path e.g. IDSRoot.xml] --> VOX
8+
VD[Version on disk memory e.g. 3.37.1] --> VOXD
9+
XD[XML path on disk memory e.g. 3.37.1] --> VOXD
10+
VOX{Version or XML\nin memory?} --> root
11+
VOXD{Version or XML\non disk?} --> root
12+
L[lazy] --> root
13+
root[IDSRoot] --> LZ{Lazy?}
14+
LZ -->|True| D[Loop over direct children with a name\nInitialize IDSToplevel with it]
15+
N[version is handled special here!] --> D
16+
LZ-->|False| E[Add name to children, nothing else]
17+
E -->|on getattr| F{attr style?}
18+
F -->|already initialized| G["return using super()"]
19+
F -->|No children| H["return []"]
20+
F -->|key in _children| I["Initialize IDSToplevel with key"]
21+
I --> T
22+
D -->|parent, key/name, ids XML element, backend_version, backend_xml_path| T[IDSToplevel init]
23+
T -->|"call super()"|K[Got parent, name, structure_xml]
24+
subgraph STRUCT["IDSStructure.__init__"]
25+
direction TB
26+
K --> B
27+
subgraph MIXIN["IDSMixin.__init__"]
28+
direction TB
29+
B[Got parent, name, structure_xml] --> J["Set internal vars on self:\n _name, _parent, _coordinates, _last_backend_xml_hash, _backend_name"]
30+
end
31+
J -->|For each XML child| M[Append name to _children]
32+
M --> O{child data_type}
33+
O -->|structure| P[Initialize childs IDSStructure]
34+
P -->|recurse, parent->child| K
35+
O -->|struct_array| Q[Initialize IDSStructArray]
36+
O -->|else| S["get_coordinates (can be {})"]
37+
S --> U["create_leaf_container(child name, child data_type, parent, coordinates, var_type=type)"]
38+
subgraph LEAF["create_leaf_container"]
39+
U --> W{Depending on\ndata_type}
40+
W --> Y[Determine ids_type, ndims from DD_TYPES]
41+
Y --> Z{ndins ==?}
42+
Z -->|ndins==0| AA["IDSPrimitive(name, ids_type, ndims, **kwargs)"]
43+
Z -->|ndins!=0 && ids_type==STR| AB["IDSPrimitive(name, ids_type, ndims, **kwargs)"]
44+
Z -->|ndins!=0 && ids_type!=STR| AC["IDSNumericArray(name, ids_type, ndims, **kwargs)"]
45+
end
46+
subgraph NUMERICARRAY["IDSNumericArray.__init__"]
47+
direction TB
48+
AC --> AD["No special init"]
49+
50+
end
51+
subgraph PRIMITIVE["IDSPrimitive.__init__"]
52+
direction TB
53+
AA --> AE
54+
AD --> AE
55+
AB --> AE["Same call signature, same case?"]
56+
AE -->|"Call super() IDSMixin init"| AF
57+
subgraph CHILDMIXIN["IDSMixin.__init__"]
58+
direction TB
59+
AF[Got parent, name, coordinates] --> AG["Set internal vars on self:\n _name, _parent, _coordinates, _last_backend_xml_hash, _backend_name"]
60+
end
61+
AG --> AH["Set internal vars on self:\n __value, _ids_type, _var_type, _ndims, _backend_type=None, _backend_ndims = None"]
62+
AH --> AI(["A child node has been generated\nPass to parent"])
63+
end
64+
end

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ docs = [
6969
"recommonmark>=0.6",
7070
"sphinx-autosummary-accessors>=0.1.2",
7171
"sphinx-autodoc-typehints>=1.1.1",
72+
"sphinxcontrib.mermaid>=0.8"
7273
]
7374
examples = [
7475
"imas",

0 commit comments

Comments
 (0)