Add docgen scene-gen: auto-generate Manim scenes from narration markdown#25
Open
Add docgen scene-gen: auto-generate Manim scenes from narration markdown#25
Conversation
Implements the core of issue #1 (Option A + Option C hybrid): - New module: scene_gen.py — parses narration markdown to extract visual beats (titles, bullets, text, transitions) and generates Manim scene Python code with proper timing from timing.json - New CLI command: docgen scene-gen [--segment] [--force] [--dry-run] Auto-generates scene files per segment from narration structure - Narration parsing extracts: - Headings → title cards with FadeIn/FadeOut - Bullet lists → sequential text reveals with VGroup.arrange() - Plain text → centered body text - Horizontal rules → visual transitions - Generated code follows all font/layout lessons from issue #3: - Text.set_default(font=...) called before any Text() - Uses arrange(DOWN) and center(), never absolute coordinates - Never uses weight=BOLD - Replaces unsafe unicode with ASCII equivalents - Font sizes ≥ 14pt (titles=36, bullets=18, body=20) - Dark background (#1e1e2e) with WHITE text - Timing integration: reads duration from animations/timing.json to distribute beats evenly across the audio duration - Manual scenes remain supported: generated files are per-segment (scene_01.py, etc.), won't overwrite without --force - Config: adds manim.font property to config.py - 29 new tests covering parsing, timing, code generation, and generator integration (125 total tests passing) Closes #1 Co-authored-by: John Menke <jmjava@gmail.com>
ea090d4 to
a73c69b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses the core design flaw described in issue #1: Manim scene authoring was a fully manual gap in the pipeline. Now
docgen scene-gencan automatically generate renderable Manim scenes from narration markdown, eliminating the???step.Problem
The pipeline was:
narration → tts → timestamps → ??? → manim → composeThe
???required manually writing Python Manim scene classes, reading timing.json to place animations at the right timestamps. This was undocumented, time-consuming (~30+ min per segment), and fragile when TTS durations changed.Solution:
docgen scene-genNew CLI command that parses narration markdown and generates Manim scene code:
The pipeline now becomes:
narration → tts → timestamps → scene-gen → manim → composeHow it works
Narration parsing extracts visual beats from markdown structure:
# Heading→ title card (font_size=36, FadeIn/FadeOut)- Item/1. Item→ bullet list (VGroup.arrange, sequential reveals)---horizontal rules → visual transitionsTiming integration reads
animations/timing.json(fromdocgen timestamps) to distribute beats evenly across the audio duration with buffer between sections.Generated code follows all lessons from issue #3:
Text.set_default(font="Liberation Sans")before any Text()arrange(DOWN),center(),to_edge()— never absolute coordinatesweight=BOLD(Pango font substitution prevention)#1e1e2e) with WHITE textManual scenes remain supported: generated files are per-segment (
scene_01.py) and won't overwrite existing files without--force.New files
src/docgen/scene_gen.pytests/test_scene_gen.pyChanges to existing files
src/docgen/cli.pyscene-gencommandsrc/docgen/config.pymanim_fontpropertyAcceptance criteria from issue #1
docgen initscaffolds projects that produce watchable videos without hand-written Manimscene-gengenerates renderable scenes from narrationscene-genreads timing.json; re-running aftertimestampsupdates timing--forceTesting
pytest tests/ --ignore=tests/e2e)ruff check src/ tests/— all checks passedCloses #1