-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare.py
357 lines (288 loc) · 8.93 KB
/
prepare.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
"""Auto script to create files for the project."""
import os
import pathlib
import yaml
cores = [
"push_notification",
"window_size",
"broadcast_channel",
"mouse",
"resize_observer",
"active_element",
"clipboard",
"event_listener",
"preferred_contrast",
"notification",
"image",
"element_bounding",
"permission",
"useragent",
"mutation_observer",
"drop_zone",
"dom_visible",
"text_direction",
"favicon",
"window_focus",
"media_query",
"window_scroll",
"fps",
"wake_lock",
"fullscreen",
"preferred_dark",
"intersection_observer",
"file_dialog",
"async_state",
"object_url",
"preferred_reduced_motion",
"geolocation",
"breakpoints",
"preferred_languages",
"element_size",
"websocket",
"memory",
"raf_fn",
"network",
"worker",
"eye_dropper",
"supported",
]
integrations = ["qr_code", "change_case", "jwt", "fcm", "async_validator"]
shareds = [
"adjust_with_unit",
"try_on_destroy",
"throttle_fn",
"unstore",
"interval_fn",
"debounce_fn",
"date_format",
"watchable",
"toggleable",
"to_writable",
"to_string",
"timeout",
"tryit",
"timeout_fn",
"sleep",
"to_number",
"create_singleton_promise",
"to_readable",
"counter",
"type",
"args_flat",
"last_changed",
"slug",
"try_get_current_component",
"create_event_hook",
"make_destructurable",
"interval",
"len",
"utils",
"range",
"template",
]
shareds_curry = ["chain", "partial", "compose"]
shareds_dicts = [
"shake",
"picker",
"listify",
"enhance",
"pops",
"map_values",
"map",
"invert",
"contains",
]
shareds_lists = [
"last",
"count",
"list",
"merge",
"flat",
"cluster",
"group",
"enhance",
"fork",
"unique",
"intersects",
"select",
"sort",
"sift",
"first",
]
shareds_math = [
"random",
"average",
"sum",
"create_projection",
"create_generic_pojection",
"min",
"max",
"projection",
"precision",
"clamp",
]
core_path = pathlib.Path(__file__).parent.absolute().joinpath("docs", "core")
integrations_path = (
pathlib.Path(__file__).parent.absolute().joinpath("docs", "integrations")
)
shareds_path = pathlib.Path(__file__).parent.absolute().joinpath("docs", "shared")
shareds_curry_path = (
pathlib.Path(__file__).parent.absolute().joinpath("docs", "shared", "curry")
)
shareds_dicts_path = (
pathlib.Path(__file__).parent.absolute().joinpath("docs", "shared", "dicts")
)
shareds_lists_path = (
pathlib.Path(__file__).parent.absolute().joinpath("docs", "shared", "lists")
)
shareds_math_path = (
pathlib.Path(__file__).parent.absolute().joinpath("docs", "shared", "math")
)
for core in cores:
if f"{core}.md" not in os.listdir(core_path):
with open(core_path.joinpath(f"{core}.md"), "w") as f:
f.write(f'# {core.replace("_", " ").title()}')
for integration in integrations:
if f"{integration}.md" not in os.listdir(integrations_path):
with open(integrations_path.joinpath(f"{integration}.md"), "w") as f:
f.write(f'# {integration.replace("_", " ").title()}')
for shared in shareds:
if f"{shared}.md" not in os.listdir(shareds_path):
with open(shareds_path.joinpath(f"{shared}.md"), "w") as f:
f.write(f'# {shared.replace("_", " ").title()}')
for shared_curry in shareds_curry:
if f"{shared_curry}.md" not in os.listdir(shareds_curry_path):
with open(shareds_curry_path.joinpath(f"{shared_curry}.md"), "w") as f:
f.write(f'# {shared_curry.replace("_", " ").title()}')
for shared_dicts in shareds_dicts:
if f"{shared_dicts}.md" not in os.listdir(shareds_dicts_path):
with open(shareds_dicts_path.joinpath(f"{shared_dicts}.md"), "w") as f:
f.write(f'# {shared_dicts.replace("_", " ").title()}')
for shared_lists in shareds_lists:
if f"{shared_lists}.md" not in os.listdir(shareds_lists_path):
with open(shareds_lists_path.joinpath(f"{shared_lists}.md"), "w") as f:
f.write(f'# {shared_lists.replace("_", " ").title()}')
for shared_math in shareds_math:
if f"{shared_math}.md" not in os.listdir(shareds_math_path):
with open(shareds_math_path.joinpath(f"{shared_math}.md"), "w") as f:
f.write(f'# {shared_math.replace("_", " ").title()}')
mkdocs = {}
with open("./mkdocs.yml", "r") as f:
mkdocs = yaml.load(f, Loader=yaml.FullLoader)
nav: list = mkdocs["nav"]
for n in nav:
if n.get("Integrations"):
_integrations: list[dict] = n["Integrations"]
values = [
value.split(".")[1].split("/")[-1]
for elem in _integrations
for value in elem.values()
]
for integration in integrations:
if integration not in values:
_integrations.append(
{
integration.replace(
"_", " "
).title(): f"./integrations/{integration}.md"
}
)
_integrations.sort(key=lambda x: list(x.keys())[0])
if n.get("Core"):
_core: list[dict] = n["Core"]
values = [
value.split(".")[1].split("/")[-1]
for elem in _core
for value in elem.values()
]
for core in cores:
if core not in values:
_core.append({core.replace("_", " ").title(): f"./core/{core}.md"})
_core.sort(key=lambda x: list(x.keys())[0])
if n.get("Shared"):
_shared: list[dict] = n["Shared"]
_shared_list: list[dict] = _shared.pop(
_shared.index([x for x in _shared if x.get("Lists")][0])
).get("Lists")
_shared_dict: list[dict] = _shared.pop(
_shared.index([x for x in _shared if x.get("Dicts")][0])
).get("Dicts")
_shared_math: list[dict] = _shared.pop(
_shared.index([x for x in _shared if x.get("Math")][0])
).get("Math")
_shared_curry: list[dict] = _shared.pop(
_shared.index([x for x in _shared if x.get("Curry")][0])
).get("Curry")
values = [
value.split(".")[1].split("/")[-1]
for elem in _shared
for value in elem.values()
]
lists_values = [
value.split(".")[1].split("/")[-1]
for elem in _shared_list
for value in elem.values()
]
dicts_values = [
value.split(".")[1].split("/")[-1]
for elem in _shared_dict
for value in elem.values()
]
math_values = [
value.split(".")[1].split("/")[-1]
for elem in _shared_math
for value in elem.values()
]
curry_values = [
value.split(".")[1].split("/")[-1]
for elem in _shared_curry
for value in elem.values()
]
for shareds_list in shareds_lists:
if shareds_list not in lists_values:
_shared_list.append(
{
shareds_list.replace(
"_", " "
).title(): f"./shared/lists/{shareds_list}.md"
}
)
for shareds_dict in shareds_dicts:
if shareds_dict not in dicts_values:
_shared_dict.append(
{
shareds_dict.replace(
"_", " "
).title(): f"./shared/dicts/{shareds_dict}.md"
}
)
for shareds_math in shareds_math:
if shareds_math not in math_values:
_shared_math.append(
{
shareds_math.replace(
"_", " "
).title(): f"./shared/math/{shareds_math}.md"
}
)
for curry in shareds_curry:
if curry not in curry_values:
_shared_curry.append(
{curry.replace("_", " ").title(): f"./shared/curry/{curry}.md"}
)
_shared_list.sort(key=lambda x: list(x.keys())[0])
_shared_dict.sort(key=lambda x: list(x.keys())[0])
_shared_math.sort(key=lambda x: list(x.keys())[0])
_shared_curry.sort(key=lambda x: list(x.keys())[0])
_shared.append({"Lists": _shared_list})
_shared.append({"Dicts": _shared_dict})
_shared.append({"Math": _shared_math})
_shared.append({"Curry": _shared_curry})
for shared in shareds:
if shared not in values:
_shared.append(
{shared.replace("_", " ").title(): f"./shared/{shared}.md"}
)
_shared.sort(key=lambda x: list(x.keys())[0])
with open("./mkdocs.yml", "w") as f:
yaml.dump(mkdocs, f, sort_keys=False)