Skip to content

Commit 43c17d5

Browse files
committed
add self-contained antora documentation
1 parent 0cf3220 commit 43c17d5

File tree

8 files changed

+731
-61
lines changed

8 files changed

+731
-61
lines changed

README.md renamed to README.adoc

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,83 @@
1-
# `expressions`
1+
= `expressions`
22

3-
> Clojure to Datastar expression transpiler
3+
____
4+
Clojure to Datastar expression transpiler
5+
____
46

5-
`expressions` is a proof-of-concept for writing [🚀 datastar][dt] expressions using Clojure without manual string concatenation.
7+
`expressions` is a proof-of-concept for writing https://data-star.dev[🚀
8+
datastar] expressions using Clojure without manual string concatenation.
69

710
Instead of:
811

9-
```clojure
12+
[source,clojure]
13+
----
1014
[:button {:data-on-click (str "$person-id" (:id person) " @post('/update-person')")}]`
11-
```
12-
15+
----
1316

1417
Write this:
1518

16-
```clojure
19+
[source,clojure]
20+
----
1721
[:button {:data-on-click (->expr
1822
(set! $person-id ~(:id person))
1923
(@post "/update-person"))}]
20-
```
24+
----
2125

22-
It is powered by [squint](https://github.com/squint-cljs/squint), thanks [@borkdude][bork].
26+
It is powered by https://github.com/squint-cljs/squint[squint], thanks
27+
https://github.com/borkdude[@borkdude].
2328

24-
## Goal & Non-Goals
29+
== Goal & Non-Goals
2530

26-
Since Clojure does not have string interpolation, writing even simple [Datastar
27-
(d\*) expressions][dt-expr] can involve a lot of `str` or `format` gymnastics.
31+
Since Clojure does not have string interpolation, writing even simple
32+
https://data-star.dev/guide/datastar_expressions[Datastar (d++*++)
33+
expressions] can involve a lot of `str` or `format` gymnastics.
2834

29-
The goal of `expressions` is to add a little bit of syntax sugar when writing
30-
d\* expressions so that they can be read and manipulated as s-expressions.
35+
The goal of `expressions` is to add a little bit of syntax sugar when
36+
writing d++*++ expressions so that they can be read and manipulated as
37+
s-expressions.
3138

32-
D\* expressions are not exactly javascript, though they are interpreted by the
33-
js runtime. D\* expressions also do not have a grammar or really any formal
34-
definition of any kind. Delaney's official position is that the simplest
35-
and obvious expressions a human would write should work.
39+
D++*++ expressions are not exactly javascript, though they are
40+
interpreted by the js runtime. D++*++ expressions also do not have a
41+
grammar or really any formal definition of any kind. Delaney’s official
42+
position is that the simplest and obvious expressions a human would
43+
write should work.
3644

37-
`expressions` follows that by trying to provide coverage for 99% of simple and
38-
obvious expressions.
45+
`expressions` follows that by trying to provide coverage for 99% of
46+
simple and obvious expressions.
3947

40-
⚠️ You can totally write expressions that result in broken javascript, that is not
41-
necessarily a bug.
48+
⚠️ You can totally write expressions that result in broken javascript,
49+
that is not necessarily a bug.
4250

43-
## Install
51+
== Install
4452

45-
```clojure
53+
[source,clojure]
54+
----
4655
datastar/expressions {:git/url "https://github.com/outskirtslabs/datastar-expressions/"
4756
:git/sha "53efc7093be1ba33b331b4a27884be8925d8bdce"}
48-
```
57+
----
4958

50-
## Status
59+
== Status
5160

52-
`expressions` is experimental and breaking changes will occur as it is actively being developed. Please share your feedback so we can squash bugs and arrive at a stable release.
61+
`expressions` is experimental and breaking changes will occur as it is
62+
actively being developed. Please share your feedback so we can squash
63+
bugs and arrive at a stable release.
5364

54-
## REPL Exploration
65+
== REPL Exploration
5566

56-
To see what this is all about, you can clone this repo and play with the demos:
67+
To see what this is all about, you can clone this repo and play with the
68+
demos:
5769

58-
```
70+
....
5971
clojure -M:dev ;; (bring your own repl server)
60-
```
61-
62-
Check out [`dev/user.clj`](./dev/user.clj) and [`dev/demo.clj`](./dev/demo.clj)
72+
....
6373

74+
Check out link:./dev/user.clj[`dev/user.clj`] and
75+
link:./dev/demo.clj[`dev/demo.clj`]
6476

65-
## Example Usage
77+
== Example Usage
6678

67-
```clojure
79+
[source,clojure]
80+
----
6881
(ns user
6982
(:require [starfederation.datastar.clojure.expressions :refer [->expr]]))
7083
@@ -230,11 +243,12 @@ Check out [`dev/user.clj`](./dev/user.clj) and [`dev/demo.clj`](./dev/demo.clj)
230243
(->expr (when false
231244
(set! $foo true)))
232245
;; => "((!!(false)) ? (($foo = true)) : (null))"
233-
```
246+
----
234247

235-
## Known Limitations
248+
== Known Limitations
236249

237-
``` clojure
250+
[source,clojure]
251+
----
238252
;; a generated symbol (el-id below) cannot be used in a template string
239253
(->expr (let [el-id evt.srcElement.id]
240254
(when el-id
@@ -246,18 +260,10 @@ Check out [`dev/user.clj`](./dev/user.clj) and [`dev/demo.clj`](./dev/demo.clj)
246260
true (set! $ui._mainMenuOpen false)
247261
false (set! $ui._mainMenuOpen true)))
248262
;; => "(() => { const pred__288831 = squint_core._EQ_; const expr__288842 = $ui._mainMenuOpen; if (!!(pred__288831(true, expr__288842))) { return $ui._mainMenuOpen = false} else { if (!!(pred__288831(false, expr__288842))) { return $ui._mainMenuOpen = true} else { throw new java.lang.IllegalArgumentException(squint_core.str(\"No matching clause: \", expr__288842))}}; })()"
249-
```
250-
251-
## License: MIT License
252-
253-
Copyright © 2025 Casey Link <casey@outskirtslabs.com>
254-
255-
Distributed under the [MIT](https://spdx.org/licenses/MIT.html).
256-
263+
----
257264

258-
[bork]: https://github.com/borkdude
259-
[dt]: https://data-star.dev
260-
[dt-dev]: https://github.com/starfederation/datastar/tree/develop
261-
[dt-expr]: https://data-star.dev/guide/datastar_expressions
265+
== License: MIT License
262266

267+
Copyright © 2025 Casey Link casey@outskirtslabs.com
263268

269+
Distributed under the https://spdx.org/licenses/MIT.html[MIT].

bb.edn

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
{:paths []
1+
{:deps {outskirtslabs/bb-tasks
2+
{:git/url "https://github.com/outskirtslabs/bb-tasks"
3+
:git/sha "8f38522bce745400f38456eab254977f94656651"}}
4+
:pods {clj-kondo/clj-kondo {:version "2026.01.19"}}
5+
:paths []
26
:tasks {:requires ([clojure.string :as str]
3-
[babashka.tasks :refer [shell]])
7+
[babashka.tasks :refer [shell]]
8+
[ol.bb-tasks.gen-docs :as gen-docs])
49
test (apply clojure "-M:kaocha" *command-line-args*)
510
fmt (shell "cljfmt -v fix dev src test")
611
fmt.check (shell "cljfmt -v check dev src test")
@@ -12,12 +17,5 @@
1217
(str " --lint " (first *command-line-args*))
1318
" --lint .")))
1419
ci {:depends [test fmt.check lint]}
15-
update-readme (let [sha (-> (shell {:out :string} "git rev-parse HEAD") :out str/trim)
16-
readme (slurp "README.md")
17-
updated (str/replace readme
18-
(re-pattern ":git/sha \"[a-f0-9]{40}\"")
19-
(str ":git/sha \"" sha "\""))]
20-
(spit "README.md" updated)
21-
(shell "git add README.md")
22-
(shell "git commit -m \"Update gitlib hash in readme\"")
23-
(println "Updated README.md with git sha:" sha))}}
20+
gen-docs {:doc "Generate all Antora documentation"
21+
:task (gen-docs/generate!)}}}

doc/antora.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
name: datastar-expressions
3+
title: Datastar Expressions
4+
version: next
5+
prerelease: true
6+
nav:
7+
- modules/ROOT/nav.adoc

doc/modules/ROOT/nav.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* xref:index.adoc[Home]
2+
3+
include::partial$api-nav.adoc[]

0 commit comments

Comments
 (0)