@redpanda-data/docs-extensions-and-macros 5.22.4 → 5.23.0
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/package.json
CHANGED
|
@@ -1117,6 +1117,49 @@ def apply_property_overrides(properties, overrides, overrides_file_path=None):
|
|
|
1117
1117
|
return properties
|
|
1118
1118
|
|
|
1119
1119
|
|
|
1120
|
+
ADMONITION_TYPES = {"note", "tip", "important", "warning", "caution"}
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
def _normalize_admonitions(admonitions):
|
|
1124
|
+
"""Validate an admonitions override and normalize each entry's `type`
|
|
1125
|
+
to the uppercase form AsciiDoc's admonition block syntax expects
|
|
1126
|
+
(`[NOTE]`, not `[note]`). Returns None (logging a warning) if the
|
|
1127
|
+
override isn't shaped as a list of {type, text} entries, so a malformed
|
|
1128
|
+
override doesn't silently render as nothing instead of surfacing the
|
|
1129
|
+
mistake.
|
|
1130
|
+
"""
|
|
1131
|
+
if not isinstance(admonitions, list):
|
|
1132
|
+
logger.warning("admonitions for property must be an array")
|
|
1133
|
+
return None
|
|
1134
|
+
normalized = []
|
|
1135
|
+
for entry in admonitions:
|
|
1136
|
+
if (
|
|
1137
|
+
not isinstance(entry, dict)
|
|
1138
|
+
or not isinstance(entry.get("type"), str)
|
|
1139
|
+
or not isinstance(entry.get("text"), str)
|
|
1140
|
+
):
|
|
1141
|
+
logger.warning(
|
|
1142
|
+
f"admonitions entry must contain string type and text values, got: {entry!r}"
|
|
1143
|
+
)
|
|
1144
|
+
continue
|
|
1145
|
+
entry_type = str(entry["type"]).strip().lower()
|
|
1146
|
+
if entry_type not in ADMONITION_TYPES:
|
|
1147
|
+
logger.warning(
|
|
1148
|
+
f"admonitions entry has unknown type '{entry['type']}', "
|
|
1149
|
+
f"expected one of {sorted(ADMONITION_TYPES)}"
|
|
1150
|
+
)
|
|
1151
|
+
continue
|
|
1152
|
+
normalized_entry = {"type": entry_type.upper(), "text": entry["text"]}
|
|
1153
|
+
if "title" in entry:
|
|
1154
|
+
if not isinstance(entry["title"], str):
|
|
1155
|
+
logger.warning(f"admonitions entry title must be a string, got: {entry!r}")
|
|
1156
|
+
continue
|
|
1157
|
+
if entry["title"]:
|
|
1158
|
+
normalized_entry["title"] = entry["title"]
|
|
1159
|
+
normalized.append(normalized_entry)
|
|
1160
|
+
return normalized
|
|
1161
|
+
|
|
1162
|
+
|
|
1120
1163
|
def _apply_override_to_existing_property(property_dict, override, overrides_file_path):
|
|
1121
1164
|
"""Apply overrides to an existing property."""
|
|
1122
1165
|
# Apply description override
|
|
@@ -1178,6 +1221,16 @@ def _apply_override_to_existing_property(property_dict, override, overrides_file
|
|
|
1178
1221
|
else:
|
|
1179
1222
|
logger.warning(f"accepted_values for property must be an array")
|
|
1180
1223
|
|
|
1224
|
+
# Apply admonitions override - structured NOTE/TIP/IMPORTANT/WARNING/CAUTION
|
|
1225
|
+
# callouts, rendered as real AsciiDoc admonition blocks by property.hbs/
|
|
1226
|
+
# topic-property.hbs. Exists so a callout never has to be hand-written as
|
|
1227
|
+
# markup mixed into the description text -- see minimize-overrides
|
|
1228
|
+
# guidance: an admonition is structured data, not embedded prose markup.
|
|
1229
|
+
if "admonitions" in override:
|
|
1230
|
+
normalized = _normalize_admonitions(override["admonitions"])
|
|
1231
|
+
if normalized is not None:
|
|
1232
|
+
property_dict["admonitions"] = normalized
|
|
1233
|
+
|
|
1181
1234
|
|
|
1182
1235
|
def _create_property_from_override(prop_name, override, overrides_file_path):
|
|
1183
1236
|
"""Create a new property from override specification."""
|
|
@@ -1222,7 +1275,7 @@ def _create_property_from_override(prop_name, override, overrides_file_path):
|
|
|
1222
1275
|
if key not in ["description", "type", "default", "config_scope", "version",
|
|
1223
1276
|
"example", "example_file", "example_yaml", "related_topics",
|
|
1224
1277
|
"see_also", "is_deprecated", "visibility", "exclude_from_docs",
|
|
1225
|
-
"category", "accepted_values", "_comment"]:
|
|
1278
|
+
"category", "accepted_values", "admonitions", "_comment"]:
|
|
1226
1279
|
new_property[key] = value
|
|
1227
1280
|
|
|
1228
1281
|
# Add exclude_from_docs if specified
|
|
@@ -1240,6 +1293,14 @@ def _create_property_from_override(prop_name, override, overrides_file_path):
|
|
|
1240
1293
|
else:
|
|
1241
1294
|
logger.warning(f"accepted_values for property '{prop_name}' must be an array")
|
|
1242
1295
|
|
|
1296
|
+
# Add admonitions if specified - run through the same validation/normalization
|
|
1297
|
+
# as the existing-property path so a malformed entry is dropped with a warning
|
|
1298
|
+
# rather than silently rendering as an unstyled, lowercase-typed block.
|
|
1299
|
+
if "admonitions" in override:
|
|
1300
|
+
normalized = _normalize_admonitions(override["admonitions"])
|
|
1301
|
+
if normalized is not None:
|
|
1302
|
+
new_property["admonitions"] = normalized
|
|
1303
|
+
|
|
1243
1304
|
return new_property
|
|
1244
1305
|
|
|
1245
1306
|
|
|
@@ -27,6 +27,18 @@ endif::[]
|
|
|
27
27
|
|
|
28
28
|
No description available.
|
|
29
29
|
|
|
30
|
+
{{/if}}
|
|
31
|
+
{{#if admonitions}}
|
|
32
|
+
{{#each admonitions}}
|
|
33
|
+
|
|
34
|
+
{{#if title}}
|
|
35
|
+
.{{{title}}}
|
|
36
|
+
{{/if}}
|
|
37
|
+
[{{type}}]
|
|
38
|
+
====
|
|
39
|
+
{{{text}}}
|
|
40
|
+
====
|
|
41
|
+
{{/each}}
|
|
30
42
|
{{/if}}
|
|
31
43
|
{{#if is_enterprise}}
|
|
32
44
|
|