From b0ca38bc98f240e208edd08009856ab6de62c227 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 11 Jul 2026 23:52:49 -0500 Subject: refactor(gallery): rename generated tokens.el to gallery-tokens.el The generated file declares (provide 'gallery-tokens), but `require` resolves a feature by filename, so as tokens.el it could never load from a load-path. The name now matches the feature. gen_tokens.py, the renderer's load, and the README follow. --- docs/prototypes/README.org | 4 ++-- docs/prototypes/gallery-tokens.el | 41 +++++++++++++++++++++++++++++++++++++++ docs/prototypes/gallery-widget.el | 6 +++--- docs/prototypes/gen_tokens.py | 8 ++++++-- docs/prototypes/tokens.el | 41 --------------------------------------- 5 files changed, 52 insertions(+), 48 deletions(-) create mode 100644 docs/prototypes/gallery-tokens.el delete mode 100644 docs/prototypes/tokens.el (limited to 'docs/prototypes') diff --git a/docs/prototypes/README.org b/docs/prototypes/README.org index 3f2e3be..674a45d 100644 --- a/docs/prototypes/README.org +++ b/docs/prototypes/README.org @@ -28,10 +28,10 @@ family, glows, pulse rate). [[file:gen_tokens.py][gen_tokens.py]] regenerates al - the =:root= block inside the gallery HTML (web CSS custom properties) - [[file:tokens-waybar.css][tokens-waybar.css]] — GTK =@define-color= declarations for the waybar panels -- [[file:tokens.el][tokens.el]] — an elisp alist for svg.el renderers +- [[file:gallery-tokens.el][gallery-tokens.el]] — an elisp alist for svg.el renderers [[file:gallery-widget.el][gallery-widget.el]] is the Emacs renderer (proof widget: the needle gauge, -gallery card 10) — it reads tokens.el and emits the widget as SVG via +gallery card 10) — it reads gallery-tokens.el and emits the widget as SVG via svg.el, so the same look renders inside Emacs. Tests: =tests/gallery-tokens/= (generator, unittest) and =tests/gallery-widgets/= (renderer, ERT), both in =make test-unit=. diff --git a/docs/prototypes/gallery-tokens.el b/docs/prototypes/gallery-tokens.el new file mode 100644 index 0000000..1fb6e52 --- /dev/null +++ b/docs/prototypes/gallery-tokens.el @@ -0,0 +1,41 @@ +;;; gallery-tokens.el --- generated from tokens.json -*- lexical-binding: t; -*- +;;; Commentary: +;; Generated by gen_tokens.py — do not edit by hand; edit tokens.json. +;;; Code: +(defconst gallery-tokens + '((ground . "#151311") + (panel . "#100f0f") + (well . "#0a0c0d") + (raise . "#1a1917") + (silver . "#bfc4d0") + (cream . "#f3e7c5") + (steel . "#969385") + (dim . "#7c838a") + (slate . "#424f5e") + (slate-hi . "#54677d") + (wash . "#2c2f32") + (pass . "#74932f") + (fail . "#cb6b4d") + (phos . "#7fe0a0") + (phos-dim . "#1c3626") + (vfd . "#63e6c8") + (sevgrn . "#57d357") + (sevred . "#e2543f") + (sevoff . "#1a1613") + (jewel-r . "#ff5b45") + (jewel-a . "#ffb43a") + (jewel-g . "#6fce33") + (gold . "#e2a038") + (gold-hi . "#ffbe54") + (amber-grad-top . "#f2c76a") + (amber-grad-mid . "#d29638") + (amber-grad-bot . "#8f671f") + (amber-edge . "#7d5c16") + (amber-warn . "#f0b552") + (glow-hi . "#ffbe54") + (glow-lo . "#e2a038") + (mono . "\"BerkeleyMono Nerd Font\",\"Berkeley Mono\",monospace") + (pulse-rate . "1s")) + "Design tokens for the panel widget gallery.") +(provide 'gallery-tokens) +;;; gallery-tokens.el ends here diff --git a/docs/prototypes/gallery-widget.el b/docs/prototypes/gallery-widget.el index 61cd78a..1c96f45 100644 --- a/docs/prototypes/gallery-widget.el +++ b/docs/prototypes/gallery-widget.el @@ -3,8 +3,8 @@ ;;; Commentary: ;; Proof-of-concept Emacs target for the panel widget gallery. The web ;; gallery (panel-widget-gallery.html) is the visual spec; tokens.json is -;; the shared source of truth, and gen_tokens.py emits tokens.el (the -;; `gallery-tokens' alist this file reads). Same tokens, same geometry, +;; the shared source of truth, and gen_tokens.py emits gallery-tokens.el +;; (the `gallery-tokens' alist this file reads). Same tokens, same geometry, ;; different renderer — that's the reuse model: shared values and shared ;; SVG shapes, per-target code. ;; @@ -25,7 +25,7 @@ (require 'svg) (require 'dom) -(load (expand-file-name "tokens.el" +(load (expand-file-name "gallery-tokens.el" (file-name-directory (or load-file-name buffer-file-name))) nil t) diff --git a/docs/prototypes/gen_tokens.py b/docs/prototypes/gen_tokens.py index f966451..9f011e9 100644 --- a/docs/prototypes/gen_tokens.py +++ b/docs/prototypes/gen_tokens.py @@ -29,7 +29,7 @@ Usage: The web CSS is written into panel-widget-gallery.html between the `/* @tokens:start */` and `/* @tokens:end */` markers; the waybar and elisp -targets are written to tokens-waybar.css and tokens.el beside it. +targets are written to tokens-waybar.css and gallery-tokens.el beside it. """ import json @@ -39,6 +39,10 @@ HERE = os.path.dirname(os.path.abspath(__file__)) TOKENS_START = "/* @tokens:start */" TOKENS_END = "/* @tokens:end */" +# The elisp target's filename must match its (provide 'gallery-tokens) so +# `require` resolves it from a load-path. +DEFAULT_ELISP_NAME = "gallery-tokens.el" + # sections whose values are plain colors (searched by resolve_color, and the # ones that become @define-color / alist color entries) COLOR_SECTIONS = ("palette", "amber") @@ -152,7 +156,7 @@ def main(tokens_path=None, html_path=None, waybar_path=None, elisp_path=None): tokens_path = tokens_path or os.path.join(HERE, "tokens.json") html_path = html_path or os.path.join(HERE, "panel-widget-gallery.html") waybar_path = waybar_path or os.path.join(HERE, "tokens-waybar.css") - elisp_path = elisp_path or os.path.join(HERE, "tokens.el") + elisp_path = elisp_path or os.path.join(HERE, DEFAULT_ELISP_NAME) with open(tokens_path) as f: tokens = json.load(f) diff --git a/docs/prototypes/tokens.el b/docs/prototypes/tokens.el deleted file mode 100644 index 1fb6e52..0000000 --- a/docs/prototypes/tokens.el +++ /dev/null @@ -1,41 +0,0 @@ -;;; gallery-tokens.el --- generated from tokens.json -*- lexical-binding: t; -*- -;;; Commentary: -;; Generated by gen_tokens.py — do not edit by hand; edit tokens.json. -;;; Code: -(defconst gallery-tokens - '((ground . "#151311") - (panel . "#100f0f") - (well . "#0a0c0d") - (raise . "#1a1917") - (silver . "#bfc4d0") - (cream . "#f3e7c5") - (steel . "#969385") - (dim . "#7c838a") - (slate . "#424f5e") - (slate-hi . "#54677d") - (wash . "#2c2f32") - (pass . "#74932f") - (fail . "#cb6b4d") - (phos . "#7fe0a0") - (phos-dim . "#1c3626") - (vfd . "#63e6c8") - (sevgrn . "#57d357") - (sevred . "#e2543f") - (sevoff . "#1a1613") - (jewel-r . "#ff5b45") - (jewel-a . "#ffb43a") - (jewel-g . "#6fce33") - (gold . "#e2a038") - (gold-hi . "#ffbe54") - (amber-grad-top . "#f2c76a") - (amber-grad-mid . "#d29638") - (amber-grad-bot . "#8f671f") - (amber-edge . "#7d5c16") - (amber-warn . "#f0b552") - (glow-hi . "#ffbe54") - (glow-lo . "#e2a038") - (mono . "\"BerkeleyMono Nerd Font\",\"Berkeley Mono\",monospace") - (pulse-rate . "1s")) - "Design tokens for the panel widget gallery.") -(provide 'gallery-tokens) -;;; gallery-tokens.el ends here -- cgit v1.2.3