aboutsummaryrefslogtreecommitdiff
path: root/scripts/theme-studio/test_generate.py
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-20 03:14:51 -0400
committerCraig Jennings <c@cjennings.net>2026-06-20 03:14:51 -0400
commit350ccfa05732066baaa577bf05c98f2ac60dc2d3 (patch)
treed04f618e403c10559df22c5805973d30a5164a8a /scripts/theme-studio/test_generate.py
parent7e8f771408b7051066fb91fa9c68e80fa52405f7 (diff)
downloaddotemacs-350ccfa05732066baaa577bf05c98f2ac60dc2d3.tar.gz
dotemacs-350ccfa05732066baaa577bf05c98f2ac60dc2d3.zip
feat(theme-studio): show face docstrings in element hovers
Each table row's category cell now shows the face's Emacs docstring on hover, on top of whatever the cell showed before. The package cell keeps the face name underneath. The syntax and UI cells had no prior tooltip, so they show just the docstring. The label-span hints are left alone. I added face-docs-dump.el, which emits face-docs.json from a live Emacs: a face-name to first-doc-line map for the UI and package tables, and a category to doc map for the syntax table. The category to font-lock-face mapping is read from build-theme.el's own map, so it isn't copied a third time. generate.py inlines both maps. A pure composeHoverTitle helper composes the tooltip, covered by Node, Python, and a new browser gate.
Diffstat (limited to 'scripts/theme-studio/test_generate.py')
-rw-r--r--scripts/theme-studio/test_generate.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/scripts/theme-studio/test_generate.py b/scripts/theme-studio/test_generate.py
index 125f0c9ab..6e9676b4a 100644
--- a/scripts/theme-studio/test_generate.py
+++ b/scripts/theme-studio/test_generate.py
@@ -10,6 +10,7 @@ Run: python3 -m unittest test_generate (from scripts/theme-studio/)
"""
import os
import io
+import json
import tempfile
import runpy
import unittest
@@ -82,13 +83,25 @@ class AssembledPage(unittest.TestCase):
"PALETTE_ACTIONS_J", "BROWSER_GATES_J",
"COLORMATH_J", "SAMPLES_J", "PALETTE_J", "CATS_J",
"UIFACES_J", "UIMAP_J", "APPS_J", "SYNTAX_J", "MAP_J",
- "COLOR_NAMES_J",
+ "COLOR_NAMES_J", "FACE_DOCS_J", "SYNTAX_DOCS_J",
]
def test_every_placeholder_is_substituted(self):
for token in self.PLACEHOLDERS:
self.assertNotIn(token, generate.HTML, f"{token} left unsubstituted")
+ def test_face_docs_maps_embed_a_known_docstring(self):
+ # The face/syntax docstring maps inline so element hovers can show them.
+ # default is always present; its first line is stable across Emacs builds.
+ self.assertIn("Basic default face.", generate.FACE_DOCS["default"])
+ self.assertIn(json.dumps(generate.FACE_DOCS), generate.HTML)
+
+ def test_syntax_docs_resolve_categories_to_face_docstrings(self):
+ # The syntax table is keyed by category (kw, doc, ...); each resolves to
+ # its font-lock face's docstring via build-theme's canonical map.
+ self.assertIn("keyword", generate.SYNTAX_DOCS["kw"].lower())
+ self.assertIn(json.dumps(generate.SYNTAX_DOCS), generate.HTML)
+
def test_page_carries_the_colormath_body_verbatim(self):
# Python-side inline-integrity: the same guarantee the JS test asserts, but
# checked at the point the page is built rather than after a round-trip.