Refine events + sx sub-module imports from background agents
Events: route imports now point to specific sub-modules (entries, tickets, slots) instead of all going through renders.py. Merged layouts into helpers.py. __init__.py now 20 lines. SX Docs: moved dispatchers from helpers.py into essays.py, cleaned up __init__.py to 24 lines. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
"""SX docs defpage setup — registers layouts and page helpers."""
|
||||
"""SX docs defpage setup — registers layouts, page helpers, and loads .sx pages."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
from shared.sx.jinja_bridge import load_sx_dir, watch_sx_dir
|
||||
|
||||
|
||||
def setup_sx_pages() -> None:
|
||||
"""Register sx-specific layouts, page helpers, and load page definitions."""
|
||||
@@ -17,8 +13,9 @@ def setup_sx_pages() -> None:
|
||||
|
||||
def _load_sx_page_files() -> None:
|
||||
"""Load defpage definitions from sx/sxc/pages/*.sx."""
|
||||
import os
|
||||
from shared.sx.pages import load_page_dir
|
||||
from shared.sx.jinja_bridge import load_service_components
|
||||
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")
|
||||
|
||||
@@ -1,9 +1,107 @@
|
||||
"""Individual content builder functions for sx docs pages."""
|
||||
"""All content generator functions and dispatchers for sx docs pages."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .renders import _code, _example_code, _placeholder, _oob_code, _clear_components_btn
|
||||
from .utils import _attr_table_sx, _primitives_section_sx, _headers_table_sx
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Dispatcher functions — route slugs to content builders
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
async def _docs_content_sx(slug: str) -> str:
|
||||
"""Route to the right docs content builder."""
|
||||
import inspect
|
||||
builders = {
|
||||
"introduction": _docs_introduction_sx,
|
||||
"getting-started": _docs_getting_started_sx,
|
||||
"components": _docs_components_sx,
|
||||
"evaluator": _docs_evaluator_sx,
|
||||
"primitives": _docs_primitives_sx,
|
||||
"css": _docs_css_sx,
|
||||
"server-rendering": _docs_server_rendering_sx,
|
||||
}
|
||||
builder = builders.get(slug, _docs_introduction_sx)
|
||||
result = builder()
|
||||
return await result if inspect.isawaitable(result) else result
|
||||
|
||||
|
||||
async def _reference_content_sx(slug: str) -> str:
|
||||
import inspect
|
||||
builders = {
|
||||
"attributes": _reference_attrs_sx,
|
||||
"headers": _reference_headers_sx,
|
||||
"events": _reference_events_sx,
|
||||
"js-api": _reference_js_api_sx,
|
||||
}
|
||||
result = builders.get(slug or "", _reference_attrs_sx)()
|
||||
return await result if inspect.isawaitable(result) else result
|
||||
|
||||
|
||||
def _protocol_content_sx(slug: str) -> str:
|
||||
builders = {
|
||||
"wire-format": _protocol_wire_format_sx,
|
||||
"fragments": _protocol_fragments_sx,
|
||||
"resolver-io": _protocol_resolver_io_sx,
|
||||
"internal-services": _protocol_internal_services_sx,
|
||||
"activitypub": _protocol_activitypub_sx,
|
||||
"future": _protocol_future_sx,
|
||||
}
|
||||
return builders.get(slug, _protocol_wire_format_sx)()
|
||||
|
||||
|
||||
def _examples_content_sx(slug: str) -> str:
|
||||
builders = {
|
||||
"click-to-load": _example_click_to_load_sx,
|
||||
"form-submission": _example_form_submission_sx,
|
||||
"polling": _example_polling_sx,
|
||||
"delete-row": _example_delete_row_sx,
|
||||
"inline-edit": _example_inline_edit_sx,
|
||||
"oob-swaps": _example_oob_swaps_sx,
|
||||
"lazy-loading": _example_lazy_loading_sx,
|
||||
"infinite-scroll": _example_infinite_scroll_sx,
|
||||
"progress-bar": _example_progress_bar_sx,
|
||||
"active-search": _example_active_search_sx,
|
||||
"inline-validation": _example_inline_validation_sx,
|
||||
"value-select": _example_value_select_sx,
|
||||
"reset-on-submit": _example_reset_on_submit_sx,
|
||||
"edit-row": _example_edit_row_sx,
|
||||
"bulk-update": _example_bulk_update_sx,
|
||||
"swap-positions": _example_swap_positions_sx,
|
||||
"select-filter": _example_select_filter_sx,
|
||||
"tabs": _example_tabs_sx,
|
||||
"animations": _example_animations_sx,
|
||||
"dialogs": _example_dialogs_sx,
|
||||
"keyboard-shortcuts": _example_keyboard_shortcuts_sx,
|
||||
"put-patch": _example_put_patch_sx,
|
||||
"json-encoding": _example_json_encoding_sx,
|
||||
"vals-and-headers": _example_vals_and_headers_sx,
|
||||
"loading-states": _example_loading_states_sx,
|
||||
"sync-replace": _example_sync_replace_sx,
|
||||
"retry": _example_retry_sx,
|
||||
}
|
||||
return builders.get(slug, _example_click_to_load_sx)()
|
||||
|
||||
|
||||
def _essay_content_sx(slug: str) -> str:
|
||||
builders = {
|
||||
"sx-sucks": _essay_sx_sucks,
|
||||
"why-sexps": _essay_why_sexps,
|
||||
"htmx-react-hybrid": _essay_htmx_react_hybrid,
|
||||
"on-demand-css": _essay_on_demand_css,
|
||||
"client-reactivity": _essay_client_reactivity,
|
||||
"sx-native": _essay_sx_native,
|
||||
"sx-manifesto": _essay_sx_manifesto,
|
||||
"tail-call-optimization": _essay_tail_call_optimization,
|
||||
"continuations": _essay_continuations,
|
||||
}
|
||||
return builders.get(slug, _essay_sx_sucks)()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Individual content builders
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _docs_introduction_sx() -> str:
|
||||
return (
|
||||
'(~doc-page :title "Introduction"'
|
||||
|
||||
@@ -1,117 +1,14 @@
|
||||
"""Dispatcher functions, public partials, and page helper registration for sx docs."""
|
||||
"""Public partials and page helper registration for sx docs."""
|
||||
from __future__ import annotations
|
||||
|
||||
from .essays import (
|
||||
_docs_introduction_sx, _docs_getting_started_sx, _docs_components_sx,
|
||||
_docs_evaluator_sx, _docs_primitives_sx, _docs_css_sx, _docs_server_rendering_sx,
|
||||
_reference_index_sx, _reference_attr_detail_sx, _reference_attrs_sx,
|
||||
_reference_headers_sx, _reference_events_sx, _reference_js_api_sx,
|
||||
_protocol_wire_format_sx, _protocol_fragments_sx, _protocol_resolver_io_sx,
|
||||
_protocol_internal_services_sx, _protocol_activitypub_sx, _protocol_future_sx,
|
||||
_example_click_to_load_sx, _example_form_submission_sx, _example_polling_sx,
|
||||
_example_delete_row_sx, _example_inline_edit_sx, _example_oob_swaps_sx,
|
||||
_example_lazy_loading_sx, _example_infinite_scroll_sx, _example_progress_bar_sx,
|
||||
_example_active_search_sx, _example_inline_validation_sx, _example_value_select_sx,
|
||||
_example_reset_on_submit_sx, _example_edit_row_sx, _example_bulk_update_sx,
|
||||
_example_swap_positions_sx, _example_select_filter_sx, _example_tabs_sx,
|
||||
_example_animations_sx, _example_dialogs_sx, _example_keyboard_shortcuts_sx,
|
||||
_example_put_patch_sx, _example_json_encoding_sx, _example_vals_and_headers_sx,
|
||||
_example_loading_states_sx, _example_sync_replace_sx, _example_retry_sx,
|
||||
_essay_sx_sucks, _essay_why_sexps, _essay_htmx_react_hybrid,
|
||||
_essay_on_demand_css, _essay_client_reactivity, _essay_sx_native,
|
||||
_essay_sx_manifesto, _essay_tail_call_optimization, _essay_continuations,
|
||||
_docs_content_sx, _reference_content_sx, _protocol_content_sx,
|
||||
_examples_content_sx, _essay_content_sx,
|
||||
_reference_index_sx, _reference_attr_detail_sx,
|
||||
)
|
||||
from .utils import _docs_nav_sx, _reference_nav_sx, _protocols_nav_sx, _examples_nav_sx, _essays_nav_sx
|
||||
from content.highlight import highlight
|
||||
|
||||
async def _docs_content_sx(slug: str) -> str:
|
||||
"""Route to the right docs content builder."""
|
||||
import inspect
|
||||
builders = {
|
||||
"introduction": _docs_introduction_sx,
|
||||
"getting-started": _docs_getting_started_sx,
|
||||
"components": _docs_components_sx,
|
||||
"evaluator": _docs_evaluator_sx,
|
||||
"primitives": _docs_primitives_sx,
|
||||
"css": _docs_css_sx,
|
||||
"server-rendering": _docs_server_rendering_sx,
|
||||
}
|
||||
builder = builders.get(slug, _docs_introduction_sx)
|
||||
result = builder()
|
||||
return await result if inspect.isawaitable(result) else result
|
||||
|
||||
|
||||
async def _reference_content_sx(slug: str) -> str:
|
||||
import inspect
|
||||
builders = {
|
||||
"attributes": _reference_attrs_sx,
|
||||
"headers": _reference_headers_sx,
|
||||
"events": _reference_events_sx,
|
||||
"js-api": _reference_js_api_sx,
|
||||
}
|
||||
result = builders.get(slug or "", _reference_attrs_sx)()
|
||||
return await result if inspect.isawaitable(result) else result
|
||||
|
||||
|
||||
def _protocol_content_sx(slug: str) -> str:
|
||||
builders = {
|
||||
"wire-format": _protocol_wire_format_sx,
|
||||
"fragments": _protocol_fragments_sx,
|
||||
"resolver-io": _protocol_resolver_io_sx,
|
||||
"internal-services": _protocol_internal_services_sx,
|
||||
"activitypub": _protocol_activitypub_sx,
|
||||
"future": _protocol_future_sx,
|
||||
}
|
||||
return builders.get(slug, _protocol_wire_format_sx)()
|
||||
|
||||
|
||||
def _examples_content_sx(slug: str) -> str:
|
||||
builders = {
|
||||
"click-to-load": _example_click_to_load_sx,
|
||||
"form-submission": _example_form_submission_sx,
|
||||
"polling": _example_polling_sx,
|
||||
"delete-row": _example_delete_row_sx,
|
||||
"inline-edit": _example_inline_edit_sx,
|
||||
"oob-swaps": _example_oob_swaps_sx,
|
||||
"lazy-loading": _example_lazy_loading_sx,
|
||||
"infinite-scroll": _example_infinite_scroll_sx,
|
||||
"progress-bar": _example_progress_bar_sx,
|
||||
"active-search": _example_active_search_sx,
|
||||
"inline-validation": _example_inline_validation_sx,
|
||||
"value-select": _example_value_select_sx,
|
||||
"reset-on-submit": _example_reset_on_submit_sx,
|
||||
"edit-row": _example_edit_row_sx,
|
||||
"bulk-update": _example_bulk_update_sx,
|
||||
"swap-positions": _example_swap_positions_sx,
|
||||
"select-filter": _example_select_filter_sx,
|
||||
"tabs": _example_tabs_sx,
|
||||
"animations": _example_animations_sx,
|
||||
"dialogs": _example_dialogs_sx,
|
||||
"keyboard-shortcuts": _example_keyboard_shortcuts_sx,
|
||||
"put-patch": _example_put_patch_sx,
|
||||
"json-encoding": _example_json_encoding_sx,
|
||||
"vals-and-headers": _example_vals_and_headers_sx,
|
||||
"loading-states": _example_loading_states_sx,
|
||||
"sync-replace": _example_sync_replace_sx,
|
||||
"retry": _example_retry_sx,
|
||||
}
|
||||
return builders.get(slug, _example_click_to_load_sx)()
|
||||
|
||||
|
||||
def _essay_content_sx(slug: str) -> str:
|
||||
builders = {
|
||||
"sx-sucks": _essay_sx_sucks,
|
||||
"why-sexps": _essay_why_sexps,
|
||||
"htmx-react-hybrid": _essay_htmx_react_hybrid,
|
||||
"on-demand-css": _essay_on_demand_css,
|
||||
"client-reactivity": _essay_client_reactivity,
|
||||
"sx-native": _essay_sx_native,
|
||||
"sx-manifesto": _essay_sx_manifesto,
|
||||
"tail-call-optimization": _essay_tail_call_optimization,
|
||||
"continuations": _essay_continuations,
|
||||
}
|
||||
return builders.get(slug, _essay_sx_sucks)()
|
||||
|
||||
|
||||
def home_content_sx() -> str:
|
||||
"""Home page content as sx wire format."""
|
||||
|
||||
Reference in New Issue
Block a user