Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Evaluator: data-first higher-order forms — ho-swap-args auto-detects (map coll fn) vs (map fn coll), both work. Threading + HO: (-> data (map fn)) dispatches through CEK HO machinery via quoted-value splice. 17 new tests in test-cek-advanced.sx. Fix plan pages: add mother-language, isolated-evaluator, rust-wasm-host to page-functions.sx plan() — were in defpage but missing from URL router. Aser error handling: pages.py now catches EvalError separately, renders visible error banner instead of silently sending empty content. All except blocks include traceback in logs. Scope primitives: register collect!/collected/clear-collected!/emitted/ emit!/context in shared/sx/primitives.py so hand-written _aser can resolve them (fixes ~cssx/flush expansion failure). New test file: shared/sx/tests/test_aser_errors.py — 19 pytest tests for error propagation through all aser control flow forms. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
34 lines
1.5 KiB
Python
34 lines
1.5 KiB
Python
"""SX docs defpage setup — registers layouts, page helpers, and loads .sx pages."""
|
|
from __future__ import annotations
|
|
|
|
|
|
def setup_sx_pages() -> None:
|
|
"""Register sx-specific layouts, page helpers, and load page definitions."""
|
|
from .layouts import _register_sx_layouts
|
|
from .helpers import _register_sx_helpers
|
|
_register_sx_layouts()
|
|
_register_sx_helpers()
|
|
_load_sx_page_files()
|
|
|
|
|
|
def _load_sx_page_files() -> None:
|
|
"""Load defpage definitions from sx/sxc/pages/*.sx."""
|
|
import os
|
|
from shared.sx.pages import load_page_dir, get_page_helpers
|
|
from shared.sx.jinja_bridge import load_sx_dir, watch_sx_dir, load_service_components
|
|
_sxc_dir = os.path.dirname(os.path.dirname(__file__)) # sx/sxc/
|
|
service_root = os.path.dirname(_sxc_dir) # sx/
|
|
load_service_components(service_root, service_name="sx")
|
|
load_sx_dir(_sxc_dir)
|
|
watch_sx_dir(_sxc_dir)
|
|
# Register page helpers as primitives so the CEK machine can find them
|
|
# during nested async component expansion (e.g. highlight inside ~docs/code
|
|
# inside a plan component inside ~layouts/doc). Without this, the env_merge
|
|
# chain loses page helpers because component closures don't capture them.
|
|
from shared.sx.ref.sx_ref import PRIMITIVES
|
|
helpers = get_page_helpers("sx")
|
|
for name, fn in helpers.items():
|
|
PRIMITIVES[name] = fn
|
|
import logging; logging.getLogger("sx.pages").info("Injected %d page helpers as primitives: %s", len(helpers), list(helpers.keys())[:5])
|
|
load_page_dir(os.path.dirname(__file__), "sx")
|