Move sx docs page helpers from Python to pure SX composition (Phase 6)
Nav data, section nav, example content, reference table builders, and all slug dispatch now live in .sx files. Python helpers reduced to data-only returns (highlight, primitives-data, reference-data, attr-detail-data). Deleted essays.py and utils.py entirely. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
;; SX docs app — declarative page definitions
|
||||
;; These replace the GET route handlers in routes.py
|
||||
;; All content dispatched via case + direct component references.
|
||||
;; Navigation built from SX data (nav-data.sx), no Python intermediaries.
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; Home page
|
||||
@@ -9,7 +10,7 @@
|
||||
:path "/"
|
||||
:auth :public
|
||||
:layout :sx
|
||||
:content (home-content))
|
||||
:content (~sx-home-content))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; Docs section
|
||||
@@ -22,9 +23,9 @@
|
||||
:section "Docs"
|
||||
:sub-label "Docs"
|
||||
:sub-href "/docs/introduction"
|
||||
:sub-nav (docs-nav "Introduction")
|
||||
:sub-nav (~section-nav :items docs-nav-items :current "Introduction")
|
||||
:selected "Introduction")
|
||||
:content (docs-content "introduction"))
|
||||
:content (~docs-introduction-content))
|
||||
|
||||
(defpage docs-page
|
||||
:path "/docs/<slug>"
|
||||
@@ -33,9 +34,19 @@
|
||||
:section "Docs"
|
||||
:sub-label "Docs"
|
||||
:sub-href "/docs/introduction"
|
||||
:sub-nav (docs-nav (find-current DOCS_NAV slug))
|
||||
:selected (or (find-current DOCS_NAV slug) ""))
|
||||
:content (docs-content slug))
|
||||
:sub-nav (~section-nav :items docs-nav-items
|
||||
:current (find-current docs-nav-items slug))
|
||||
:selected (or (find-current docs-nav-items slug) ""))
|
||||
:content (case slug
|
||||
"introduction" (~docs-introduction-content)
|
||||
"getting-started" (~docs-getting-started-content)
|
||||
"components" (~docs-components-content)
|
||||
"evaluator" (~docs-evaluator-content)
|
||||
"primitives" (~docs-primitives-content
|
||||
:prims (~doc-primitives-tables :primitives (primitives-data)))
|
||||
"css" (~docs-css-content)
|
||||
"server-rendering" (~docs-server-rendering-content)
|
||||
:else (~docs-introduction-content)))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; Reference section
|
||||
@@ -48,9 +59,9 @@
|
||||
:section "Reference"
|
||||
:sub-label "Reference"
|
||||
:sub-href "/reference/"
|
||||
:sub-nav (reference-nav "")
|
||||
:sub-nav (~section-nav :items reference-nav-items :current "")
|
||||
:selected "")
|
||||
:content (reference-index-content))
|
||||
:content (~reference-index-content))
|
||||
|
||||
(defpage reference-page
|
||||
:path "/reference/<slug>"
|
||||
@@ -59,9 +70,30 @@
|
||||
:section "Reference"
|
||||
:sub-label "Reference"
|
||||
:sub-href "/reference/"
|
||||
:sub-nav (reference-nav (find-current REFERENCE_NAV slug))
|
||||
:selected (or (find-current REFERENCE_NAV slug) ""))
|
||||
:content (reference-content slug))
|
||||
:sub-nav (~section-nav :items reference-nav-items
|
||||
:current (find-current reference-nav-items slug))
|
||||
:selected (or (find-current reference-nav-items slug) ""))
|
||||
:data (reference-data slug)
|
||||
:content (case slug
|
||||
"attributes" (~reference-attrs-content
|
||||
:req-table (~doc-attr-table-from-data :title "Request Attributes" :attrs req-attrs)
|
||||
:beh-table (~doc-attr-table-from-data :title "Behavior Attributes" :attrs beh-attrs)
|
||||
:uniq-table (~doc-attr-table-from-data :title "Unique to sx" :attrs uniq-attrs))
|
||||
"headers" (~reference-headers-content
|
||||
:req-table (~doc-headers-table-from-data :title "Request Headers" :headers req-headers)
|
||||
:resp-table (~doc-headers-table-from-data :title "Response Headers" :headers resp-headers))
|
||||
"events" (~reference-events-content
|
||||
:table (~doc-two-col-table-from-data
|
||||
:intro "sx fires custom DOM events at various points in the request lifecycle."
|
||||
:col1 "Event" :col2 "Description" :items events-list))
|
||||
"js-api" (~reference-js-api-content
|
||||
:table (~doc-two-col-table-from-data
|
||||
:intro "The client-side sx.js library exposes a public API for programmatic use."
|
||||
:col1 "Method" :col2 "Description" :items js-api-list))
|
||||
:else (~reference-attrs-content
|
||||
:req-table (~doc-attr-table-from-data :title "Request Attributes" :attrs req-attrs)
|
||||
:beh-table (~doc-attr-table-from-data :title "Behavior Attributes" :attrs beh-attrs)
|
||||
:uniq-table (~doc-attr-table-from-data :title "Unique to sx" :attrs uniq-attrs))))
|
||||
|
||||
(defpage reference-attr-detail
|
||||
:path "/reference/attributes/<slug>"
|
||||
@@ -70,9 +102,18 @@
|
||||
:section "Reference"
|
||||
:sub-label "Reference"
|
||||
:sub-href "/reference/"
|
||||
:sub-nav (reference-nav "Attributes")
|
||||
:sub-nav (~section-nav :items reference-nav-items :current "Attributes")
|
||||
:selected "Attributes")
|
||||
:content (reference-attr-detail slug))
|
||||
:data (attr-detail-data slug)
|
||||
:content (if attr-not-found
|
||||
(~reference-attr-not-found :slug slug)
|
||||
(~reference-attr-detail-content
|
||||
:title attr-title
|
||||
:description attr-description
|
||||
:demo attr-demo
|
||||
:example-code attr-example
|
||||
:handler-code attr-handler
|
||||
:wire-placeholder-id attr-wire-id)))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; Protocols section
|
||||
@@ -85,9 +126,9 @@
|
||||
:section "Protocols"
|
||||
:sub-label "Protocols"
|
||||
:sub-href "/protocols/wire-format"
|
||||
:sub-nav (protocols-nav "Wire Format")
|
||||
:sub-nav (~section-nav :items protocols-nav-items :current "Wire Format")
|
||||
:selected "Wire Format")
|
||||
:content (protocol-content "wire-format"))
|
||||
:content (~protocol-wire-format-content))
|
||||
|
||||
(defpage protocol-page
|
||||
:path "/protocols/<slug>"
|
||||
@@ -96,9 +137,17 @@
|
||||
:section "Protocols"
|
||||
:sub-label "Protocols"
|
||||
:sub-href "/protocols/wire-format"
|
||||
:sub-nav (protocols-nav (find-current PROTOCOLS_NAV slug))
|
||||
:selected (or (find-current PROTOCOLS_NAV slug) ""))
|
||||
:content (protocol-content slug))
|
||||
:sub-nav (~section-nav :items protocols-nav-items
|
||||
:current (find-current protocols-nav-items slug))
|
||||
:selected (or (find-current protocols-nav-items slug) ""))
|
||||
:content (case slug
|
||||
"wire-format" (~protocol-wire-format-content)
|
||||
"fragments" (~protocol-fragments-content)
|
||||
"resolver-io" (~protocol-resolver-io-content)
|
||||
"internal-services" (~protocol-internal-services-content)
|
||||
"activitypub" (~protocol-activitypub-content)
|
||||
"future" (~protocol-future-content)
|
||||
:else (~protocol-wire-format-content)))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; Examples section
|
||||
@@ -111,9 +160,9 @@
|
||||
:section "Examples"
|
||||
:sub-label "Examples"
|
||||
:sub-href "/examples/click-to-load"
|
||||
:sub-nav (examples-nav "Click to Load")
|
||||
:sub-nav (~section-nav :items examples-nav-items :current "Click to Load")
|
||||
:selected "Click to Load")
|
||||
:content (examples-content "click-to-load"))
|
||||
:content (~example-click-to-load))
|
||||
|
||||
(defpage examples-page
|
||||
:path "/examples/<slug>"
|
||||
@@ -122,9 +171,38 @@
|
||||
:section "Examples"
|
||||
:sub-label "Examples"
|
||||
:sub-href "/examples/click-to-load"
|
||||
:sub-nav (examples-nav (find-current EXAMPLES_NAV slug))
|
||||
:selected (or (find-current EXAMPLES_NAV slug) ""))
|
||||
:content (examples-content slug))
|
||||
:sub-nav (~section-nav :items examples-nav-items
|
||||
:current (find-current examples-nav-items slug))
|
||||
:selected (or (find-current examples-nav-items slug) ""))
|
||||
:content (case slug
|
||||
"click-to-load" (~example-click-to-load)
|
||||
"form-submission" (~example-form-submission)
|
||||
"polling" (~example-polling)
|
||||
"delete-row" (~example-delete-row)
|
||||
"inline-edit" (~example-inline-edit)
|
||||
"oob-swaps" (~example-oob-swaps)
|
||||
"lazy-loading" (~example-lazy-loading)
|
||||
"infinite-scroll" (~example-infinite-scroll)
|
||||
"progress-bar" (~example-progress-bar)
|
||||
"active-search" (~example-active-search)
|
||||
"inline-validation" (~example-inline-validation)
|
||||
"value-select" (~example-value-select)
|
||||
"reset-on-submit" (~example-reset-on-submit)
|
||||
"edit-row" (~example-edit-row)
|
||||
"bulk-update" (~example-bulk-update)
|
||||
"swap-positions" (~example-swap-positions)
|
||||
"select-filter" (~example-select-filter)
|
||||
"tabs" (~example-tabs)
|
||||
"animations" (~example-animations)
|
||||
"dialogs" (~example-dialogs)
|
||||
"keyboard-shortcuts" (~example-keyboard-shortcuts)
|
||||
"put-patch" (~example-put-patch)
|
||||
"json-encoding" (~example-json-encoding)
|
||||
"vals-and-headers" (~example-vals-and-headers)
|
||||
"loading-states" (~example-loading-states)
|
||||
"sync-replace" (~example-sync-replace)
|
||||
"retry" (~example-retry)
|
||||
:else (~example-click-to-load)))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; Essays section
|
||||
@@ -137,9 +215,9 @@
|
||||
:section "Essays"
|
||||
:sub-label "Essays"
|
||||
:sub-href "/essays/sx-sucks"
|
||||
:sub-nav (essays-nav "sx sucks")
|
||||
:sub-nav (~section-nav :items essays-nav-items :current "sx sucks")
|
||||
:selected "sx sucks")
|
||||
:content (essay-content "sx-sucks"))
|
||||
:content (~essay-sx-sucks))
|
||||
|
||||
(defpage essay-page
|
||||
:path "/essays/<slug>"
|
||||
@@ -148,6 +226,17 @@
|
||||
:section "Essays"
|
||||
:sub-label "Essays"
|
||||
:sub-href "/essays/sx-sucks"
|
||||
:sub-nav (essays-nav (find-current ESSAYS_NAV slug))
|
||||
:selected (or (find-current ESSAYS_NAV slug) ""))
|
||||
:content (essay-content slug))
|
||||
:sub-nav (~section-nav :items essays-nav-items
|
||||
:current (find-current essays-nav-items slug))
|
||||
:selected (or (find-current essays-nav-items slug) ""))
|
||||
:content (case slug
|
||||
"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)
|
||||
:else (~essay-sx-sucks)))
|
||||
|
||||
Reference in New Issue
Block a user