Move spec metadata from Python to SX, add orchestration to spec viewer

Spec file registry (slugs, filenames, titles, descriptions) now lives in
nav-data.sx as SX data definitions. Python helper reduced to pure file I/O
(read-spec-file). Architecture page updated with engine/orchestration split
and dependency graph.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 13:34:58 +00:00
parent d696735f95
commit af77fc32c7
4 changed files with 69 additions and 79 deletions

View File

@@ -268,14 +268,26 @@
:sub-nav (~section-nav :items specs-nav-items
:current (find-current specs-nav-items slug))
:selected (or (find-current specs-nav-items slug) ""))
:data (spec-data slug)
:content (if spec-not-found
(~spec-not-found :slug slug)
(case slug
"core" (~spec-overview-content :spec-files spec-files)
"adapters" (~spec-overview-content :spec-files spec-files)
:else (~spec-detail-content
:spec-title spec-title
:spec-desc spec-desc
:spec-filename spec-filename
:spec-source spec-source))))
:content (case slug
"core" (~spec-overview-content
:spec-title "Core Language"
:spec-files (map (fn (item)
(dict :title (get item "title") :desc (get item "desc")
:filename (get item "filename") :href (str "/specs/" (get item "slug"))
:source (read-spec-file (get item "filename"))))
core-spec-items))
"adapters" (~spec-overview-content
:spec-title "Adapters & Engine"
:spec-files (map (fn (item)
(dict :title (get item "title") :desc (get item "desc")
:filename (get item "filename") :href (str "/specs/" (get item "slug"))
:source (read-spec-file (get item "filename"))))
adapter-spec-items))
:else (let ((spec (find-spec slug)))
(if spec
(~spec-detail-content
:spec-title (get spec "title")
:spec-desc (get spec "desc")
:spec-filename (get spec "filename")
:spec-source (read-spec-file (get spec "filename")))
(~spec-not-found :slug slug)))))

View File

@@ -16,7 +16,7 @@ def _register_sx_helpers() -> None:
"primitives-data": _primitives_data,
"reference-data": _reference_data,
"attr-detail-data": _attr_detail_data,
"spec-data": _spec_data,
"read-spec-file": _read_spec_file,
})
@@ -104,72 +104,13 @@ def _reference_data(slug: str) -> dict:
}
_CORE_SPECS = {
"parser": ("parser.sx", "Parser", "Tokenization and parsing of SX source text into AST."),
"evaluator": ("eval.sx", "Evaluator", "Tree-walking evaluation of SX expressions."),
"primitives": ("primitives.sx", "Primitives", "All built-in pure functions and their signatures."),
"renderer": ("render.sx", "Renderer", "Shared rendering registries and utilities used by all adapters."),
}
_ADAPTER_SPECS = {
"adapter-dom": ("adapter-dom.sx", "DOM Adapter", "Renders SX expressions to live DOM nodes. Browser-only."),
"adapter-html": ("adapter-html.sx", "HTML Adapter", "Renders SX expressions to HTML strings. Server-side."),
"adapter-sx": ("adapter-sx.sx", "SX Wire Adapter", "Serializes SX for client-side rendering. Component calls stay unexpanded."),
"engine": ("engine.sx", "SxEngine", "Fetch/swap/history engine for browser-side SX. Like HTMX but native to SX."),
}
_ALL_SPECS = {**_CORE_SPECS, **_ADAPTER_SPECS}
def _spec_data(slug: str) -> dict:
"""Return spec file source and metadata for display."""
def _read_spec_file(filename: str) -> str:
"""Read a spec .sx file from the ref directory. Pure I/O — metadata lives in .sx."""
import os
ref_dir = os.path.join(os.path.dirname(__file__), "..", "..", "shared", "sx", "ref")
if not os.path.isdir(ref_dir):
ref_dir = "/app/shared/sx/ref"
base = {"spec-not-found": None, "spec-title": None, "spec-desc": None,
"spec-filename": None, "spec-source": None, "spec-files": None}
if slug == "core":
specs = []
for key in ("parser", "evaluator", "primitives", "renderer"):
filename, title, desc = _CORE_SPECS[key]
filepath = os.path.join(ref_dir, filename)
source = _read_spec(filepath)
specs.append({
"title": title, "desc": desc, "filename": filename,
"source": source, "href": f"/specs/{key}",
})
return {**base, "spec-title": "Core Language", "spec-files": specs}
if slug == "adapters":
specs = []
for key in ("adapter-dom", "adapter-html", "adapter-sx", "engine"):
filename, title, desc = _ADAPTER_SPECS[key]
filepath = os.path.join(ref_dir, filename)
source = _read_spec(filepath)
specs.append({
"title": title, "desc": desc, "filename": filename,
"source": source, "href": f"/specs/{key}",
})
return {**base, "spec-title": "Adapters & Engine", "spec-files": specs}
info = _ALL_SPECS.get(slug)
if not info:
return {**base, "spec-not-found": True}
filename, title, desc = info
filepath = os.path.join(ref_dir, filename)
source = _read_spec(filepath)
return {**base,
"spec-title": title, "spec-desc": desc,
"spec-filename": filename, "spec-source": source}
def _read_spec(filepath: str) -> str:
"""Read a spec file, returning empty string if missing."""
try:
with open(filepath, encoding="utf-8") as f:
return f.read()