You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#: Relations define the possible parent / child relationships between
117
-
#: node types and optionally override the default properties.
76
+
# Relations define the possible parent / child relationships between
77
+
# node types and optionally override the default properties.
118
78
"relations": {
119
79
"__root__": {
120
80
"function": {
121
-
":count": 10,
122
-
"title": "Function {hier_idx}",
81
+
":count": 3,
82
+
"title": TextRandomizer(("{idx}: Provide $(Noun:plural)",)),
83
+
"details": BlindTextRandomizer(dialect="ipsum"),
123
84
"expanded": True,
124
85
},
125
86
},
126
87
"function": {
127
88
"failure": {
128
89
":count": RangeRandomizer(1, 3),
129
-
"title": "Failure {hier_idx}",
90
+
"title": TextRandomizer("$(Noun:plural) not provided"),
130
91
},
131
92
},
132
93
"failure": {
133
94
"cause": {
134
95
":count": RangeRandomizer(1, 3),
135
-
"title": "Cause {hier_idx}",
96
+
"title": TextRandomizer("$(Noun:plural) not provided"),
136
97
},
137
98
"effect": {
138
99
":count": RangeRandomizer(1, 3),
139
-
"title": "Effect {hier_idx}",
100
+
"title": TextRandomizer("$(Noun:plural) not provided"),
140
101
},
141
102
},
142
103
},
143
104
}
144
-
tree = Tree.build_random_tree(structure_def)
145
-
tree.print()
146
-
assert type(tree) is Tree
105
+
106
+
tree = TypedTree.build_random_tree(structure_def)
107
+
108
+
assert type(tree) is TypedTree
147
109
assert tree.calc_height() == 3
110
+
111
+
tree.print()
112
+
113
+
May produce::
114
+
115
+
TypedTree<'fmea'>
116
+
├── function → GenericNodeData<{'icon': 'gear', 'title': '1: Provide Seniors', 'details': 'Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.', 'expanded': True}>
117
+
│ ├── failure → GenericNodeData<{'icon': 'exclamation', 'title': 'Streets not provided'}>
118
+
│ │ ├── cause → GenericNodeData<{'icon': 'tools', 'title': 'Decisions not provided'}>
│ ╰── failure → GenericNodeData<{'icon': 'exclamation', 'title': 'Entertainments not provided'}>
122
+
│ ├── cause → GenericNodeData<{'icon': 'tools', 'title': 'Programs not provided'}>
123
+
│ ├── effect → GenericNodeData<{'icon': 'lightning', 'title': 'Dirts not provided'}>
124
+
│ ╰── effect → GenericNodeData<{'icon': 'lightning', 'title': 'Dimensions not provided'}>
125
+
├── function → GenericNodeData<{'icon': 'gear', 'title': '2: Provide Shots', 'details': 'Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.', 'expanded': True}>
126
+
│ ├── failure → GenericNodeData<{'icon': 'exclamation', 'title': 'Trainers not provided'}>
127
+
│ │ ├── cause → GenericNodeData<{'icon': 'tools', 'title': 'Girlfriends not provided'}>
128
+
│ │ ├── cause → GenericNodeData<{'icon': 'tools', 'title': 'Noses not provided'}>
│ ╰── failure → GenericNodeData<{'icon': 'exclamation', 'title': 'Punches not provided'}>
132
+
│ ├── cause → GenericNodeData<{'icon': 'tools', 'title': 'Inevitables not provided'}>
133
+
│ ├── cause → GenericNodeData<{'icon': 'tools', 'title': 'Fronts not provided'}>
134
+
│ ╰── effect → GenericNodeData<{'icon': 'lightning', 'title': 'Worths not provided'}>
135
+
╰── function → GenericNodeData<{'icon': 'gear', 'title': '3: Provide Shots', 'details': 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.', 'expanded': True}>
136
+
╰── failure → GenericNodeData<{'icon': 'exclamation', 'title': 'Recovers not provided'}>
137
+
├── cause → GenericNodeData<{'icon': 'tools', 'title': 'Viruses not provided'}>
138
+
├── effect → GenericNodeData<{'icon': 'lightning', 'title': 'Dirts not provided'}>
139
+
╰── effect → GenericNodeData<{'icon': 'lightning', 'title': 'Readings not provided'}>
140
+
141
+
142
+
**A few things to note**
143
+
144
+
- The generated tree contains nodes :class:`~common.GenericNodeData` as ``node.data``
145
+
value..
146
+
147
+
- Every ``node.data`` contains items from the structure definition except for
148
+
the ones starting with a colon, for example ``":count"``. |br|
149
+
The node items are merged with the default properties defined in the `types`
150
+
section.
151
+
152
+
- Randomizers are used to generate random data for each instance.
153
+
They derive from the :class:`~tree_generator.Randomizer` base class.
154
+
155
+
- The :class:`~tree_generator.TextRandomizer` and
156
+
:class:`~tree_generator.BlindTextRandomizer` classes are used to generate
157
+
random text using the `Fabulist <https://fabulist.readthedocs.io/>`_ library.
158
+
159
+
- :meth:`tree.Tree.build_random_tree` creates instances of :class:`~tree.Tree`, while
160
+
:meth:`typed_tree.TypedTree.build_random_tree` creates instances of
161
+
:class:`~typed_tree.TypedTree`.
162
+
163
+
- The generated tree contains instances of the :class:`~common.GenericNodeData`
164
+
class by default, but can be overridden for each node type by adding a
0 commit comments