Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions milestones/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ repositories that install `docgen` and maintain their own demo bundle. The
library no longer ships an in-repo dogfood; consumers are the integration test
of record.

**Active:** **[validation-list-keys.md](validation-list-keys.md)** —
`validation.ocr.error_patterns`, `av_sync.visual_types`, and narration-lint
deny pattern lists must be YAML lists, not scalars.
**Active:** **[manim-unsafe-unicode.md](manim-unsafe-unicode.md)** —
`manim.unsafe_unicode` must be a YAML list at config load, not a scalar.

**Shipped:**
- **[validation-list-keys.md](validation-list-keys.md)** —
`validation.ocr.error_patterns`, `av_sync.visual_types`, and narration-lint
deny pattern lists must be YAML lists (#95).
- **[wizard-exclude-lists.md](wizard-exclude-lists.md)** —
`wizard.exclude_patterns` / `scan_extensions` must be string lists (#94).
- **[timestamps-merge-stems.md](timestamps-merge-stems.md)** — CLI `timestamps`
Expand Down
33 changes: 33 additions & 0 deletions milestones/manim-unsafe-unicode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Milestone: `manim.unsafe_unicode` must be a list at config load

**Status:** Active
**PR:** pending
**Depends on:** `milestones/validation-list-keys.md` (PR #95),
`milestones/config-mapping-keys.md` (PR #83)

## Problem

`manim.unsafe_unicode` as a YAML string already raised `ConfigError` when the
property was **read** (validate / scene-spec-generate). `Config.from_yaml` did
not touch it, so `yaml-generate`, `tts`, and other commands could load a bad
file. A string would also have been iterated as characters inside unicode lint
if anything called the property after a bypass.

## Goal

Evaluate `manim_unsafe_unicode` during `Config.from_yaml` (same as
`manim.scenes`). Use `string_list_block` so items must be YAML strings.

## Done when

- [x] `manim.unsafe_unicode` if present must be a YAML list of strings.
- [x] Missing / null still uses the built-in Pango fallback character list.
- [x] Empty list still disables the unicode lint (`[]`).
- [x] Test for a string value at `Config.from_yaml`.
- [x] `ruff check src/ tests/`
- [x] `pytest tests/`
- [x] `docgen benchmark` (no clock change)

## Out of scope

- The default character list itself is unchanged.
4 changes: 2 additions & 2 deletions milestones/validation-list-keys.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Milestone: validation list keys must not be scalars

**Status:** Active
**PR:** pending
**Status:** Shipped
**PR:** #95
**Depends on:** `milestones/wizard-exclude-lists.md` (PR #94),
`milestones/config-mapping-keys.md` (PR #83)

Expand Down
17 changes: 8 additions & 9 deletions src/docgen/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def __post_init__(self) -> None:
# List-valued keys: a string must not be iterated as characters.
_ = self.segments_all
_ = self.manim_scenes
_ = self.manim_unsafe_unicode
concat = self._block("concat")
src = self._source_label()
for name, segs in concat.items():
Expand Down Expand Up @@ -538,15 +539,13 @@ def manim_unsafe_unicode(self) -> list[str]:
"\u2260", "\u2264", "\u2265", "\u2014", "\u2013",
"\u2018", "\u2019", "\u201c", "\u201d", "\u2022",
"\u2026"]
val = self._block("manim").get("unsafe_unicode", default)
if val is None:
return list(default)
if not isinstance(val, list):
raise ConfigError(
f"{self._source_label()}: manim.unsafe_unicode must be a YAML list, "
f"not {type(val).__name__}"
)
return [str(x) for x in val]
return string_list_block(
self._block("manim"),
"unsafe_unicode",
fallback=default,
label="manim.unsafe_unicode",
source=self._source_label(),
)

# -- Compose ----------------------------------------------------------------

Expand Down
7 changes: 7 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,10 @@ def test_from_yaml_string_post_tts_deny_patterns_raises(tmp_path: Path) -> None:
ConfigError, match="validation.narration_lint.post_tts_deny_patterns must be a YAML list"
):
Config.from_yaml(p)


def test_from_yaml_string_manim_unsafe_unicode_raises(tmp_path: Path) -> None:
p = tmp_path / "docgen.yaml"
p.write_text("manim:\n unsafe_unicode: \"\\u2192\"\n", encoding="utf-8")
with pytest.raises(ConfigError, match="manim.unsafe_unicode must be a YAML list"):
Config.from_yaml(p)