Skip to content

Commit 8d9ca4d

Browse files
committed
Rather than add $id to hardcoded too, be cleverer in discovering.
1 parent 94d7a86 commit 8d9ca4d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

sphinx_json_schema_spec/__init__.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
HARDCODED = {
2222
"$dynamicRef": "https://json-schema.org/draft/2020-12/json-schema-core.html#dynamic-ref", # noqa: E501
2323
"$ref": "https://json-schema.org/draft/2020-12/json-schema-core.html#ref",
24-
"$schema": "https://json-schema.org/draft/2020-12/json-schema-core.html#name-the-schema-keyword", # noqa: E501
2524
"format": "https://json-schema.org/draft/2020-12/json-schema-validation.html#name-implementation-requirements", # noqa: E501
2625
}
2726

@@ -142,7 +141,13 @@ def keyword(name, raw_text, text, lineno, inliner):
142141

143142
# find the header in the validation spec containing matching text
144143
for vocabulary_url, spec in vocabularies.items():
145-
header = spec.get_element_by_id(f"name-{text.lower()}", None)
144+
lower = text.lstrip("$").lower()
145+
header = spec.get_element_by_id(f"name-{lower}", None)
146+
if header is None:
147+
header = spec.get_element_by_id(
148+
f"name-the-{lower}-keyword",
149+
None
150+
)
146151

147152
if header is not None:
148153
uri = urljoin(vocabulary_url, header.find("a").attrib["href"])

0 commit comments

Comments
 (0)