mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-12 22:14:05 +00:00
docs(settings): render field constraints as code spans in the reference
The docs site failed to build: a bare "<= 1" in the prose of the
generated page is parsed by MDX as the start of a JSX tag ("Unexpected
character '=' before name"). Constraints are rendered as code spans now,
where MDX leaves them alone, and a test rejects any bare <, { or } outside
a code span so a future description cannot reintroduce the failure.
Verified with a local next build of the docs site.
This commit is contained in:
1 parent
41135fc894
commit
a47a2c34ec
3 files changed
+51
-41
No files matched your search
@@ -139,6 +139,15 @@ class TestReference:
|
||||
for name in Settings.model_fields:
|
||||
assert page.count(f"### `{name}`") == 1, name
|
||||
|
||||
def test_reference_prose_has_no_bare_angle_brackets_or_braces(self):
|
||||
"""MDX parses ``<`` and ``{`` in prose as JSX; only code spans may carry them raw."""
|
||||
for lineno, line in enumerate(render_reference().splitlines(), 1):
|
||||
if line.startswith(("{/*", "---")):
|
||||
continue
|
||||
prose = "".join(line.split("`")[::2]) # drop the inside of every code span
|
||||
prose = prose.replace("\\{", "").replace("\\}", "") # escaped braces are fine
|
||||
assert "<" not in prose and "{" not in prose and "}" not in prose, f"line {lineno}: {line}"
|
||||
|
||||
def test_checked_in_reference_is_current(self):
|
||||
path: Path = reference_path()
|
||||
if not path.exists():
|
||||
|
||||
Reference in new issue
Block a user