Skip to content

Commit da18c3e

Browse files
Consolidate dark/light tape files into single canonical tapes with --mode flag
Each TUI now has one tape file in demos/. The run_vhs.py script accepts --mode dark|light to inject the appropriate VHS theme and TEXTUAL_THEME env var at build time, eliminating duplicate tape maintenance. Release workflow trimmed to dark-mode videos for stack, sll, and dll only. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 267eaba commit da18c3e

19 files changed

Lines changed: 229 additions & 794 deletions

‎.github/workflows/release.yml‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,13 @@ jobs:
3838
sudo apt-get update -q && sudo apt-get install -y vhs ttyd
3939
4040
- name: Generate demo videos
41-
run: make demo-all
41+
run: make demo-stack-dark demo-sll-dark demo-dll-dark
4242

4343
- name: Create GitHub release
4444
uses: softprops/action-gh-release@v2
4545
with:
4646
generate_release_notes: true
4747
files: |
4848
demos/stack-dark.mp4
49-
demos/stack-light.mp4
50-
demos/queue-dark.mp4
51-
demos/queue-light.mp4
52-
demos/deque-dark.mp4
53-
demos/deque-light.mp4
54-
demos/list-dark.mp4
55-
demos/list-light.mp4
5649
demos/sll-dark.mp4
57-
demos/sll-light.mp4
5850
demos/dll-dark.mp4
59-
demos/dll-light.mp4

‎CLAUDE.md‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Commands
6+
7+
```bash
8+
make install # create .venv and install dependencies
9+
make test # full test suite
10+
make test-<name> # single module, e.g. make test-stack or make test-stack-app
11+
make run-<name> # import a non-TUI demo module (verifies clean import)
12+
make run-<name>-app # launch a TUI interactively
13+
make demo-<name> # produce dark + light mp4s for one TUI (requires vhs, ffmpeg, imagemagick)
14+
make demo-all # produce all demo videos
15+
```
16+
17+
Valid short `<name>` aliases: `bst`, `deque`, `dict`, `dll`, `graph`, `heap`, `list`, `networkx`, `queue`, `set`, `sll`, `stack`, `trie`. App variants: `stack-app`, `queue-app`, `deque-app`, `list-app`, `sll-app`, `dll-app`.
18+
19+
Single test without make: `.venv/bin/pytest tests/test_stack_demo.py -v`
20+
21+
Font override for demo videos: `VHS_FONT_FAMILY="SF Mono" make demo-stack`
22+
23+
## Architecture
24+
25+
### Data structure modules (`data_structures/`)
26+
27+
One module per topic, named `<topic>_demo.py` or `<topic>.py`. Modules contain only class definitions — no `__main__` block — so `make run-<name>` just verifies a clean import. The exception is TUI apps under `data_structures/tui/`, which are runnable as `python -m data_structures.tui.<app>`.
28+
29+
### TUI layer (`data_structures/tui/`)
30+
31+
Two patterns exist side by side:
32+
33+
- **`stack_app.py`** — standalone, self-contained. Defines its own model, panel widget, and command dispatcher. Does not inherit from the shared base.
34+
- **All other TUI apps** — inherit from `BaseLinearStructureTUI` in `common.py`. The base provides the Textual widget layout, shared command dispatcher (`/random`, `/clear`, `/save`, `/load`, `/undo`, `/redo`, `/show`, `/type`, scroll, `/help`), undo/redo snapshots, and type-constraint enforcement. Subclasses override `STRUCTURE_NAME`, `START_LABEL`/`END_LABEL`, `get_items()`, `append_values()`, `clear_structure()`, `replace_items()`, `handle_structure_command()`, `help_lines()`, and `placeholder_text()`.
35+
36+
`/help` output convention: structure-specific commands first under `--- <Name> ---`, then common commands under `--- Common ---`. Command verbs use `[cyan]...[/cyan]` Rich markup; argument placeholders stay outside the markup span.
37+
38+
All TUIs support `/search VALUE`. Linked-list TUIs additionally expose positional and node-id–based insert/remove commands.
39+
40+
### Demo video pipeline (`scripts/run_vhs.py`)
41+
42+
Two-stage process:
43+
1. `vhs` renders the raw terminal interaction from a `.tape` file in `demos/`.
44+
2. `run_vhs.py` post-processes the raw video: selects a platform-appropriate font (macOS → `Menlo`, Linux → `DejaVu Sans Mono`), overrides the output path, trims the slow launch, adds an opening title card and ending card (via ImageMagick), and burns lower-right captions from `# CAPTION:` comments in the tape.
45+
46+
Caption pipeline: `parse_commands()` → `scale_commands()` → `build_command_caption_cues()` → `burn_captions_into_video()`.
47+
48+
The timing constants near the top of `run_vhs.py` (`INTRO_SECONDS`, `OUTRO_SECONDS`, `LAUNCH_TRIM_SECONDS`) are the main levers for video pacing. `INTERTITLE_SECONDS` and `LIVE_HOLD_SECONDS` are legacy knobs not currently active.
49+
50+
Each TUI has a single canonical tape file: `demos/<name>.tape`. The `--mode dark|light` flag on `run_vhs.py` injects the appropriate theme and appends `-dark` or `-light` to the output filename. Dark theme: `TokyoNight`. Light theme: `Catppuccin Latte`.
51+
52+
### Tests (`tests/`)
53+
54+
One `test_<module>.py` per source module. `conftest.py` adds a `temporary_recursion_limit` fixture and a post-collection summary of test counts per file. `pytest.ini` sets `pythonpath = .` so `data_structures` and `scripts` are importable without installation.

‎Makefile‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,50 +87,50 @@ test-trie: test-trie_demo
8787

8888
# Demo videos (requires vhs: https://github.com/charmbracelet/vhs)
8989
demo-stack-dark:
90-
$(PYTHON) scripts/run_vhs.py demos/stack-dark.tape
90+
$(PYTHON) scripts/run_vhs.py demos/stack.tape --mode dark
9191

9292
demo-stack-light:
93-
$(PYTHON) scripts/run_vhs.py demos/stack-light.tape
93+
$(PYTHON) scripts/run_vhs.py demos/stack.tape --mode light
9494

9595
demo-stack: demo-stack-dark demo-stack-light
9696

9797
demo-queue-dark:
98-
$(PYTHON) scripts/run_vhs.py demos/queue-dark.tape
98+
$(PYTHON) scripts/run_vhs.py demos/queue.tape --mode dark
9999

100100
demo-queue-light:
101-
$(PYTHON) scripts/run_vhs.py demos/queue-light.tape
101+
$(PYTHON) scripts/run_vhs.py demos/queue.tape --mode light
102102

103103
demo-queue: demo-queue-dark demo-queue-light
104104

105105
demo-deque-dark:
106-
$(PYTHON) scripts/run_vhs.py demos/deque-dark.tape
106+
$(PYTHON) scripts/run_vhs.py demos/deque.tape --mode dark
107107

108108
demo-deque-light:
109-
$(PYTHON) scripts/run_vhs.py demos/deque-light.tape
109+
$(PYTHON) scripts/run_vhs.py demos/deque.tape --mode light
110110

111111
demo-deque: demo-deque-dark demo-deque-light
112112

113113
demo-list-dark:
114-
$(PYTHON) scripts/run_vhs.py demos/list-dark.tape
114+
$(PYTHON) scripts/run_vhs.py demos/list.tape --mode dark
115115

116116
demo-list-light:
117-
$(PYTHON) scripts/run_vhs.py demos/list-light.tape
117+
$(PYTHON) scripts/run_vhs.py demos/list.tape --mode light
118118

119119
demo-list: demo-list-dark demo-list-light
120120

121121
demo-sll-dark:
122-
$(PYTHON) scripts/run_vhs.py demos/sll-dark.tape
122+
$(PYTHON) scripts/run_vhs.py demos/sll.tape --mode dark
123123

124124
demo-sll-light:
125-
$(PYTHON) scripts/run_vhs.py demos/sll-light.tape
125+
$(PYTHON) scripts/run_vhs.py demos/sll.tape --mode light
126126

127127
demo-sll: demo-sll-dark demo-sll-light
128128

129129
demo-dll-dark:
130-
$(PYTHON) scripts/run_vhs.py demos/dll-dark.tape
130+
$(PYTHON) scripts/run_vhs.py demos/dll.tape --mode dark
131131

132132
demo-dll-light:
133-
$(PYTHON) scripts/run_vhs.py demos/dll-light.tape
133+
$(PYTHON) scripts/run_vhs.py demos/dll.tape --mode light
134134

135135
demo-dll: demo-dll-dark demo-dll-light
136136

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ For walkthroughs of the interactive apps, see:
5555

5656
## Producing Demo Videos
5757

58-
Demo tapes live in `demos/`. Each TUI has a dark-theme tape and a light-theme tape. Generating the videos requires [vhs](https://github.com/charmbracelet/vhs).
58+
Demo tapes live in `demos/`. Each TUI has a single canonical tape file; `--mode dark|light` selects the theme at build time. Generating the videos requires [vhs](https://github.com/charmbracelet/vhs).
5959

6060
The demo build wrapper auto-selects a monospace font by platform:
6161
- macOS: `Menlo`
@@ -84,7 +84,7 @@ Produce all videos at once:
8484
make demo-all
8585
```
8686

87-
Individual tape variants are also available, for example `make demo-stack-dark` or `make demo-dll-light`. Generated `.mp4` files are written to `demos/`.
87+
Individual theme variants are also available, for example `make demo-stack-dark` or `make demo-dll-light`. Generated `.mp4` files are written to `demos/`.
8888

8989
For maintenance details about timing, caption placement, and caption wording, see:
9090
- `docs/DemoVideoMaintenance.md`

‎demos/deque-light.tape‎

Lines changed: 0 additions & 115 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Deque — interactive demo (dark theme)
2-
# Run from project root: vhs demos/deque-dark.tape
1+
# Deque — interactive demo
2+
# Run from project root: vhs demos/deque.tape
33

4-
Output demos/deque-dark.mp4
4+
Output demos/deque.mp4
55

66
Set Theme "TokyoNight"
77
Set FontSize 16

0 commit comments

Comments
 (0)