Restructure Specs section into Architecture, Core, and Adapters pages

- Add Architecture intro page explaining the spec's two-layer design
  (core language + selectable adapters) with dependency graph
- Split specs into Core (parser, eval, primitives, render) and
  Adapters (DOM, HTML, SX wire, SxEngine) overview pages
- Add individual detail pages for all adapter and engine specs
- Update nav with Architecture landing, Core, Adapters, and all
  individual spec file links

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 11:55:59 +00:00
parent 7c99002345
commit 3197022299
5 changed files with 203 additions and 25 deletions

View File

@@ -253,11 +253,10 @@
:layout (:sx-section
:section "Specs"
:sub-label "Specs"
:sub-href "/specs/core"
:sub-nav (~section-nav :items specs-nav-items :current "Core")
:selected "Core")
:data (spec-data "core")
:content (~spec-core-content :spec-files spec-files))
:sub-href "/specs/"
:sub-nav (~section-nav :items specs-nav-items :current "Architecture")
:selected "Architecture")
:content (~spec-architecture-content))
(defpage specs-page
:path "/specs/<slug>"
@@ -265,7 +264,7 @@
:layout (:sx-section
:section "Specs"
:sub-label "Specs"
:sub-href "/specs/core"
:sub-href "/specs/"
:sub-nav (~section-nav :items specs-nav-items
:current (find-current specs-nav-items slug))
:selected (or (find-current specs-nav-items slug) ""))
@@ -273,7 +272,8 @@
:content (if spec-not-found
(~spec-not-found :slug slug)
(case slug
"core" (~spec-core-content :spec-files spec-files)
"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

View File

@@ -104,21 +104,28 @@ def _reference_data(slug: str) -> dict:
}
_SPEC_FILES = {
_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", "Rendering evaluated expressions to DOM, HTML, or SX wire format."),
"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 highlighted version for display."""
"""Return spec file source and metadata for display."""
import os
from content.highlight import highlight as _highlight
ref_dir = os.path.join(os.path.dirname(__file__), "..", "..", "shared", "sx", "ref")
# Normalise — inside container shared is at /app/shared
if not os.path.isdir(ref_dir):
ref_dir = "/app/shared/sx/ref"
@@ -128,19 +135,28 @@ def _spec_data(slug: str) -> dict:
if slug == "core":
specs = []
for key in ("parser", "evaluator", "primitives", "renderer"):
filename, title, desc = _SPEC_FILES[key]
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}",
"title": title, "desc": desc, "filename": filename,
"source": source, "href": f"/specs/{key}",
})
return {**base, "spec-title": "SX Core Specification", "spec-files": specs}
return {**base, "spec-title": "Core Language", "spec-files": specs}
info = _SPEC_FILES.get(slug)
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}