@redpanda-data/docs-extensions-and-macros 4.12.3 → 4.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extensions/process-context-switcher.js +1 -1
- package/package.json +1 -1
- package/tools/property-extractor/Makefile +2 -1
- package/tools/property-extractor/helpers/capitalize.js +13 -0
- package/tools/property-extractor/helpers/index.js +2 -0
- package/tools/property-extractor/helpers/length.js +11 -0
- package/tools/property-extractor/templates/property.hbs +69 -26
- package/tools/property-extractor/templates/topic-property-mappings.hbs +3 -6
- package/tools/property-extractor/templates/topic-property.hbs +57 -24
- package/tools/property-extractor/topic_property_extractor.py +10 -3
- package/tools/property-extractor/transformers.py +117 -64
- package/tools/property-extractor/COMPUTED_CONSTANTS.md +0 -173
- package/tools/property-extractor/tests/test_known_values.py +0 -617
- package/tools/property-extractor/tests/transformers_test.py +0 -451
|
@@ -1,451 +0,0 @@
|
|
|
1
|
-
import unittest
|
|
2
|
-
from property_bag import PropertyBag
|
|
3
|
-
from file_pair import FilePair
|
|
4
|
-
from transformers import *
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def create_property_info(
|
|
8
|
-
name,
|
|
9
|
-
description,
|
|
10
|
-
declaration=None,
|
|
11
|
-
metadata=None,
|
|
12
|
-
default_value="{}",
|
|
13
|
-
default_value_type="initializer_list",
|
|
14
|
-
):
|
|
15
|
-
info = PropertyBag()
|
|
16
|
-
info["name_in_file"] = name
|
|
17
|
-
info["declaration"] = declaration
|
|
18
|
-
info["params"] = []
|
|
19
|
-
info["params"].append(PropertyBag(value=name, type="string_literal"))
|
|
20
|
-
info["params"].append(PropertyBag(value=description, type="string_literal"))
|
|
21
|
-
info["params"].append(PropertyBag(value=metadata, type="initializer_list"))
|
|
22
|
-
info["params"].append(PropertyBag(value=default_value, type="initializer_list"))
|
|
23
|
-
|
|
24
|
-
return info
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class BasicInfoTransformerTestCase(unittest.TestCase):
|
|
28
|
-
def setUp(self):
|
|
29
|
-
self.transformer = BasicInfoTransformer()
|
|
30
|
-
|
|
31
|
-
def test_accepts_everything(self):
|
|
32
|
-
self.assertTrue(self.transformer.accepts(None, None))
|
|
33
|
-
|
|
34
|
-
def test_adds_name_description_and_defined_in(self):
|
|
35
|
-
property = PropertyBag()
|
|
36
|
-
info = create_property_info("test_property", "test description")
|
|
37
|
-
self.transformer.parse(property, info, FilePair("testfile.h", "testfile.cc"))
|
|
38
|
-
|
|
39
|
-
self.assertEqual("test_property", property["name"])
|
|
40
|
-
self.assertEqual("test description", property["description"])
|
|
41
|
-
self.assertEqual("testfile.cc", property["defined_in"])
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
class IsArrayTransformerTestCase(unittest.TestCase):
|
|
45
|
-
def setUp(self):
|
|
46
|
-
self.transformer = IsArrayTransformer(TypeTransformer())
|
|
47
|
-
|
|
48
|
-
def test_accepts_vector(self):
|
|
49
|
-
self.assertTrue(
|
|
50
|
-
self.transformer.accepts(
|
|
51
|
-
create_property_info(
|
|
52
|
-
"test_property", "test description", "std::vector<int>"
|
|
53
|
-
),
|
|
54
|
-
None,
|
|
55
|
-
)
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
def test_rejects_other_properties(self):
|
|
59
|
-
for t in [
|
|
60
|
-
"int",
|
|
61
|
-
"std::optional",
|
|
62
|
-
"config::endpoint_tls_config",
|
|
63
|
-
"deprecated_property",
|
|
64
|
-
]:
|
|
65
|
-
with self.subTest(t):
|
|
66
|
-
self.assertFalse(
|
|
67
|
-
self.transformer.accepts(
|
|
68
|
-
create_property_info("test_property", "test description", t),
|
|
69
|
-
None,
|
|
70
|
-
)
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
def test_adds_array_field(self):
|
|
74
|
-
property = PropertyBag()
|
|
75
|
-
info = create_property_info(
|
|
76
|
-
"test_property", "test description", "std::vector<int>"
|
|
77
|
-
)
|
|
78
|
-
self.transformer.parse(property, info, FilePair("testfile.h", "testfile.cc"))
|
|
79
|
-
|
|
80
|
-
self.assertEqual("array", property["type"])
|
|
81
|
-
self.assertEqual("integer", property["items"]["type"])
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
class NeedsRestartTransformerTestCase(unittest.TestCase):
|
|
85
|
-
def setUp(self):
|
|
86
|
-
self.transformer = NeedsRestartTransformer()
|
|
87
|
-
|
|
88
|
-
def test_accepts_needs_restart_metadata(self):
|
|
89
|
-
self.assertTrue(
|
|
90
|
-
self.transformer.accepts(
|
|
91
|
-
create_property_info(
|
|
92
|
-
"test_property",
|
|
93
|
-
"test description",
|
|
94
|
-
"bool",
|
|
95
|
-
PropertyBag(needs_restart="needs_restart::no"),
|
|
96
|
-
),
|
|
97
|
-
None,
|
|
98
|
-
)
|
|
99
|
-
)
|
|
100
|
-
self.assertTrue(
|
|
101
|
-
self.transformer.accepts(
|
|
102
|
-
create_property_info(
|
|
103
|
-
"test_property",
|
|
104
|
-
"test description",
|
|
105
|
-
"bool",
|
|
106
|
-
PropertyBag(needs_restart="needs_restart::yes"),
|
|
107
|
-
),
|
|
108
|
-
None,
|
|
109
|
-
)
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
def test_accepts_without_needs_restart(self):
|
|
113
|
-
"""NeedsRestartTransformer now accepts all properties and applies defaults"""
|
|
114
|
-
self.assertTrue(
|
|
115
|
-
self.transformer.accepts(
|
|
116
|
-
create_property_info(
|
|
117
|
-
"test_property", "test description", "bool", PropertyBag()
|
|
118
|
-
),
|
|
119
|
-
None,
|
|
120
|
-
)
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
def test_adds_needs_restart_true(self):
|
|
124
|
-
property = PropertyBag()
|
|
125
|
-
info = create_property_info(
|
|
126
|
-
"test_property",
|
|
127
|
-
"test description",
|
|
128
|
-
"std::vector<int>",
|
|
129
|
-
PropertyBag(needs_restart="needs_restart::yes"),
|
|
130
|
-
)
|
|
131
|
-
self.transformer.parse(property, info, FilePair("testfile.h", "testfile.cc"))
|
|
132
|
-
|
|
133
|
-
self.assertTrue(property["needs_restart"])
|
|
134
|
-
|
|
135
|
-
def test_adds_needs_restart_false(self):
|
|
136
|
-
property = PropertyBag()
|
|
137
|
-
info = create_property_info(
|
|
138
|
-
"test_property",
|
|
139
|
-
"test description",
|
|
140
|
-
"std::vector<int>",
|
|
141
|
-
PropertyBag(needs_restart="needs_restart::no"),
|
|
142
|
-
)
|
|
143
|
-
self.transformer.parse(property, info, FilePair("testfile.h", "testfile.cc"))
|
|
144
|
-
|
|
145
|
-
self.assertFalse(property["needs_restart"])
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
class VisibilityTransformerTestCase(unittest.TestCase):
|
|
149
|
-
def setUp(self):
|
|
150
|
-
self.transformer = VisibilityTransformer()
|
|
151
|
-
|
|
152
|
-
def test_accepts_visibility_metadata(self):
|
|
153
|
-
self.assertTrue(
|
|
154
|
-
self.transformer.accepts(
|
|
155
|
-
create_property_info(
|
|
156
|
-
"test_property",
|
|
157
|
-
"test description",
|
|
158
|
-
"bool",
|
|
159
|
-
PropertyBag(visibility="visibility::user"),
|
|
160
|
-
),
|
|
161
|
-
None,
|
|
162
|
-
)
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
def test_rejects_without_visibility(self):
|
|
166
|
-
self.assertFalse(
|
|
167
|
-
self.transformer.accepts(
|
|
168
|
-
create_property_info(
|
|
169
|
-
"test_property", "test description", "bool", PropertyBag()
|
|
170
|
-
),
|
|
171
|
-
None,
|
|
172
|
-
)
|
|
173
|
-
)
|
|
174
|
-
|
|
175
|
-
def test_adds_visibility(self):
|
|
176
|
-
for p in [
|
|
177
|
-
("user", "visibility::user"),
|
|
178
|
-
("tunable", "visibility::tunable"),
|
|
179
|
-
("deprecated", "visibility::deprecated"),
|
|
180
|
-
]:
|
|
181
|
-
with self.subTest(p[0]):
|
|
182
|
-
property = PropertyBag()
|
|
183
|
-
info = create_property_info(
|
|
184
|
-
"test_property",
|
|
185
|
-
"test description",
|
|
186
|
-
"std::vector<int>",
|
|
187
|
-
PropertyBag(visibility=p[1]),
|
|
188
|
-
)
|
|
189
|
-
self.transformer.parse(
|
|
190
|
-
property, info, FilePair("testfile.h", "testfile.cc")
|
|
191
|
-
)
|
|
192
|
-
|
|
193
|
-
self.assertEqual(p[0], property["visibility"])
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
class TypeTransformerTestCase(unittest.TestCase):
|
|
197
|
-
def setUp(self):
|
|
198
|
-
self.transformer = TypeTransformer()
|
|
199
|
-
|
|
200
|
-
def test_accepts_everything(self):
|
|
201
|
-
self.assertTrue(self.transformer.accepts(None, None))
|
|
202
|
-
|
|
203
|
-
def test_parse_simple_types(self):
|
|
204
|
-
types = [
|
|
205
|
-
("int", "integer"),
|
|
206
|
-
("int32_t", "integer"),
|
|
207
|
-
("int16_t", "integer"),
|
|
208
|
-
("int64_t", "integer"),
|
|
209
|
-
("double", "number"),
|
|
210
|
-
("bool", "boolean"),
|
|
211
|
-
("std::chrono::milliseconds", "integer"),
|
|
212
|
-
("std::chrono::seconds", "integer"),
|
|
213
|
-
("std::filesystem::path", "string"),
|
|
214
|
-
]
|
|
215
|
-
|
|
216
|
-
for t in types:
|
|
217
|
-
with self.subTest(t[0]):
|
|
218
|
-
property = PropertyBag()
|
|
219
|
-
info = create_property_info(
|
|
220
|
-
"test_property",
|
|
221
|
-
"test description",
|
|
222
|
-
"property<" + t[0] + ">" + " test_property;",
|
|
223
|
-
)
|
|
224
|
-
self.transformer.parse(
|
|
225
|
-
property, info, FilePair("testfile.h", "testfile.cc")
|
|
226
|
-
)
|
|
227
|
-
|
|
228
|
-
self.assertEqual(t[1], property["type"])
|
|
229
|
-
|
|
230
|
-
def test_parse_bounded_property(self):
|
|
231
|
-
property = PropertyBag()
|
|
232
|
-
info = create_property_info(
|
|
233
|
-
"test_property",
|
|
234
|
-
"test description",
|
|
235
|
-
"bounded_property<double, numeric_bounds> disk_reservation_percent;",
|
|
236
|
-
)
|
|
237
|
-
self.transformer.parse(property, info, FilePair("testfile.h", "testfile.cc"))
|
|
238
|
-
|
|
239
|
-
self.assertEqual("number", property["type"])
|
|
240
|
-
|
|
241
|
-
def test_parse_deprecated_property(self):
|
|
242
|
-
property = PropertyBag()
|
|
243
|
-
info = create_property_info(
|
|
244
|
-
"test_property", "test description", "deprecated_property test_property;"
|
|
245
|
-
)
|
|
246
|
-
self.transformer.parse(property, info, FilePair("testfile.h", "testfile.cc"))
|
|
247
|
-
|
|
248
|
-
self.assertEqual("deprecated_property", property["type"])
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
class DeprecatedTransformerTestCase(unittest.TestCase):
|
|
252
|
-
def setUp(self):
|
|
253
|
-
self.transformer = DeprecatedTransformer()
|
|
254
|
-
|
|
255
|
-
def test_accepts_deprecated_metadata(self):
|
|
256
|
-
"""DeprecatedTransformer accepts properties with .deprecated in meta"""
|
|
257
|
-
self.assertTrue(
|
|
258
|
-
self.transformer.accepts(
|
|
259
|
-
create_property_info(
|
|
260
|
-
"test_property",
|
|
261
|
-
"test description",
|
|
262
|
-
"bool",
|
|
263
|
-
PropertyBag(deprecated="yes"),
|
|
264
|
-
),
|
|
265
|
-
None,
|
|
266
|
-
)
|
|
267
|
-
)
|
|
268
|
-
|
|
269
|
-
def test_rejects_without_deprecated_metadata(self):
|
|
270
|
-
"""DeprecatedTransformer rejects properties without .deprecated in meta"""
|
|
271
|
-
self.assertFalse(
|
|
272
|
-
self.transformer.accepts(
|
|
273
|
-
create_property_info(
|
|
274
|
-
"test_property",
|
|
275
|
-
"test description",
|
|
276
|
-
"bool",
|
|
277
|
-
PropertyBag(visibility="visibility::deprecated"),
|
|
278
|
-
),
|
|
279
|
-
None,
|
|
280
|
-
)
|
|
281
|
-
)
|
|
282
|
-
self.assertFalse(
|
|
283
|
-
self.transformer.accepts(
|
|
284
|
-
create_property_info(
|
|
285
|
-
"test_property",
|
|
286
|
-
"test description",
|
|
287
|
-
"deprecated_property",
|
|
288
|
-
PropertyBag(),
|
|
289
|
-
),
|
|
290
|
-
None,
|
|
291
|
-
)
|
|
292
|
-
)
|
|
293
|
-
|
|
294
|
-
def test_rejects_without_deprecated_visibility_type(self):
|
|
295
|
-
self.assertFalse(
|
|
296
|
-
self.transformer.accepts(
|
|
297
|
-
create_property_info(
|
|
298
|
-
"test_property", "test description", "bool", PropertyBag()
|
|
299
|
-
),
|
|
300
|
-
None,
|
|
301
|
-
)
|
|
302
|
-
)
|
|
303
|
-
|
|
304
|
-
def test_adds_deprecated_field_from_deprecated_visibility(self):
|
|
305
|
-
property = PropertyBag()
|
|
306
|
-
info = create_property_info(
|
|
307
|
-
"test_property",
|
|
308
|
-
"test description",
|
|
309
|
-
"std::vector<int>",
|
|
310
|
-
PropertyBag(visibility="visibility::deprecated"),
|
|
311
|
-
)
|
|
312
|
-
self.transformer.parse(property, info, FilePair("testfile.h", "testfile.cc"))
|
|
313
|
-
|
|
314
|
-
self.assertTrue(property["is_deprecated"])
|
|
315
|
-
self.assertFalse(property["type"])
|
|
316
|
-
|
|
317
|
-
def test_adds_deprecated_field_from_deprecated_property_type(self):
|
|
318
|
-
property = PropertyBag()
|
|
319
|
-
info = create_property_info(
|
|
320
|
-
"test_property", "test description", "deprecated_property", PropertyBag()
|
|
321
|
-
)
|
|
322
|
-
self.transformer.parse(property, info, FilePair("testfile.h", "testfile.cc"))
|
|
323
|
-
|
|
324
|
-
self.assertTrue(property["is_deprecated"])
|
|
325
|
-
self.assertFalse(property["type"])
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
class IsSecretTransformerTestCase(unittest.TestCase):
|
|
329
|
-
def setUp(self):
|
|
330
|
-
self.transformer = IsSecretTransformer()
|
|
331
|
-
|
|
332
|
-
def test_accepts_with_secret(self):
|
|
333
|
-
self.assertTrue(
|
|
334
|
-
self.transformer.accepts(
|
|
335
|
-
create_property_info(
|
|
336
|
-
"test_property",
|
|
337
|
-
"test description",
|
|
338
|
-
"bool",
|
|
339
|
-
PropertyBag(secret="is_secret::yes"),
|
|
340
|
-
),
|
|
341
|
-
None,
|
|
342
|
-
)
|
|
343
|
-
)
|
|
344
|
-
self.assertTrue(
|
|
345
|
-
self.transformer.accepts(
|
|
346
|
-
create_property_info(
|
|
347
|
-
"test_property",
|
|
348
|
-
"test description",
|
|
349
|
-
"bool",
|
|
350
|
-
PropertyBag(secret="is_secret::no"),
|
|
351
|
-
),
|
|
352
|
-
None,
|
|
353
|
-
)
|
|
354
|
-
)
|
|
355
|
-
|
|
356
|
-
def test_rejects_without_secret(self):
|
|
357
|
-
self.assertFalse(
|
|
358
|
-
self.transformer.accepts(
|
|
359
|
-
create_property_info(
|
|
360
|
-
"test_property", "test description", "bool", PropertyBag()
|
|
361
|
-
),
|
|
362
|
-
None,
|
|
363
|
-
)
|
|
364
|
-
)
|
|
365
|
-
|
|
366
|
-
def test_adds_is_secret_true(self):
|
|
367
|
-
property = PropertyBag()
|
|
368
|
-
info = create_property_info(
|
|
369
|
-
"test_property",
|
|
370
|
-
"test description",
|
|
371
|
-
"std::vector<int>",
|
|
372
|
-
PropertyBag(secret="is_secret::yes"),
|
|
373
|
-
)
|
|
374
|
-
self.transformer.parse(property, info, FilePair("testfile.h", "testfile.cc"))
|
|
375
|
-
self.assertTrue(property["is_secret"])
|
|
376
|
-
|
|
377
|
-
def test_adds_is_secret_false(self):
|
|
378
|
-
property = PropertyBag()
|
|
379
|
-
info = create_property_info(
|
|
380
|
-
"test_property",
|
|
381
|
-
"test description",
|
|
382
|
-
"std::vector<int>",
|
|
383
|
-
PropertyBag(secret="is_secret::no"),
|
|
384
|
-
)
|
|
385
|
-
self.transformer.parse(property, info, FilePair("testfile.h", "testfile.cc"))
|
|
386
|
-
self.assertFalse(property["is_secret"])
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
class FriendlyDefaultTransformerTestCase(unittest.TestCase):
|
|
390
|
-
def setUp(self):
|
|
391
|
-
self.transformer = FriendlyDefaultTransformer()
|
|
392
|
-
|
|
393
|
-
def test_strips_unsigned_integer_suffix(self):
|
|
394
|
-
"""Test that C++ unsigned integer suffixes are stripped from defaults"""
|
|
395
|
-
property = PropertyBag()
|
|
396
|
-
info = create_property_info(
|
|
397
|
-
"test_property",
|
|
398
|
-
"test description",
|
|
399
|
-
"uint32_t",
|
|
400
|
-
PropertyBag(needs_restart="needs_restart::no"),
|
|
401
|
-
default_value="1024u",
|
|
402
|
-
default_value_type="number_literal"
|
|
403
|
-
)
|
|
404
|
-
self.transformer.parse(property, info, FilePair("testfile.h", "testfile.cc"))
|
|
405
|
-
self.assertEqual(1024, property["default"])
|
|
406
|
-
|
|
407
|
-
def test_strips_long_integer_suffix(self):
|
|
408
|
-
"""Test that C++ long integer suffixes are stripped from defaults"""
|
|
409
|
-
property = PropertyBag()
|
|
410
|
-
info = create_property_info(
|
|
411
|
-
"test_property",
|
|
412
|
-
"test description",
|
|
413
|
-
"int64_t",
|
|
414
|
-
PropertyBag(needs_restart="needs_restart::no"),
|
|
415
|
-
default_value="42L",
|
|
416
|
-
default_value_type="number_literal"
|
|
417
|
-
)
|
|
418
|
-
self.transformer.parse(property, info, FilePair("testfile.h", "testfile.cc"))
|
|
419
|
-
self.assertEqual(42, property["default"])
|
|
420
|
-
|
|
421
|
-
def test_strips_unsigned_long_long_suffix(self):
|
|
422
|
-
"""Test that C++ unsigned long long suffixes are stripped from defaults"""
|
|
423
|
-
property = PropertyBag()
|
|
424
|
-
info = create_property_info(
|
|
425
|
-
"test_property",
|
|
426
|
-
"test description",
|
|
427
|
-
"uint64_t",
|
|
428
|
-
PropertyBag(needs_restart="needs_restart::no"),
|
|
429
|
-
default_value="999ULL",
|
|
430
|
-
default_value_type="number_literal"
|
|
431
|
-
)
|
|
432
|
-
self.transformer.parse(property, info, FilePair("testfile.h", "testfile.cc"))
|
|
433
|
-
self.assertEqual(999, property["default"])
|
|
434
|
-
|
|
435
|
-
def test_strips_float_suffix(self):
|
|
436
|
-
"""Test that C++ float suffixes are stripped from defaults"""
|
|
437
|
-
property = PropertyBag()
|
|
438
|
-
info = create_property_info(
|
|
439
|
-
"test_property",
|
|
440
|
-
"test description",
|
|
441
|
-
"float",
|
|
442
|
-
PropertyBag(needs_restart="needs_restart::no"),
|
|
443
|
-
default_value="3.14f",
|
|
444
|
-
default_value_type="number_literal"
|
|
445
|
-
)
|
|
446
|
-
self.transformer.parse(property, info, FilePair("testfile.h", "testfile.cc"))
|
|
447
|
-
self.assertAlmostEqual(3.14, property["default"], places=2)
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
if __name__ == "__main__":
|
|
451
|
-
unittest.main()
|