|
2 | 2 | :clay {:title "Macroexpand 2025 Noj: Clay Workshop" |
3 | 3 | :quarto {:author :timothypratley |
4 | 4 | :description "What is Clay, why use it, and how to use it." |
5 | | - :draft true |
6 | 5 | :type :post |
7 | 6 | :date "2025-10-16" |
8 | 7 | :category :clay |
9 | 8 | :tags [:clay :workflow]}}} |
10 | 9 | (ns scicloj.clay.workshop.macroexpand2025 |
11 | 10 | (:require [scicloj.tableplot.v1.plotly :as tp] |
12 | | - [tablecloth.api :as tc])) |
| 11 | + [tablecloth.api :as tc] |
| 12 | + [scicloj.kindly.v4.kind :as kind])) |
13 | 13 |
|
14 | 14 | (ns scicloj.clay.workshop.macroexpand2025) |
15 | 15 |
|
16 | | -;; The purpose of this workshop is to get up and running with Clay. |
17 | | -;; So please ask for help if you are stuck or have any questions. |
| 16 | +;; Welcome to the [Macroexpand Clay Workshop](https://scicloj.github.io/macroexpand-2025/macroexpand_noj.html)! |
| 17 | + |
| 18 | +;; The main goal of this workshop is to get you up and running with Clay. |
| 19 | +;; I'll present an overview of Clay, and then we'll spend time together getting setup and trying it. |
| 20 | +;; Please ask for help if you are stuck or have any questions. |
18 | 21 |
|
19 | 22 | ;; ## What is Clay? |
20 | 23 |
|
21 | 24 | ;; Clay is a tool that turns a Clojure namespace into a Document. |
22 | | -;; This document was made from the `scicloj.clay.workshop.macroexpand2025` namespace. |
23 | 25 |
|
24 | 26 | ;; Clay renders code, results, comments, markdown and visualizations. |
25 | 27 |
|
26 | 28 | ;;  |
27 | 29 |
|
| 30 | +;; > Useful for documentation, data exploration, visualization, and blogging. |
| 31 | + |
| 32 | +;; > Bundled with Noj; the SciCloj collection of data science libraries. |
| 33 | + |
| 34 | +;; ## What does Clay produce? |
| 35 | + |
| 36 | +;; HTML or Markdown of comments, code, and values. |
| 37 | +;; This HTML document was made from `src/scicloj/clay/workshop/macroexpand2025.clj`. |
| 38 | + |
28 | 39 | ;; ### Code and results |
29 | 40 |
|
30 | 41 | ;; Expressions are evaluated and the result shown in the document. |
|
55 | 66 |
|
56 | 67 | ;;  |
57 | 68 |
|
58 | | -;; See [Markdown reference](https://quarto.org/docs/authoring/markdown-basics.html). |
| 69 | +;; CommonMark (Quarto). |
| 70 | +;; Quarto has features like footnotes^[Quarto is a well established, widely used publishing solution]. |
| 71 | +;; See [Markdown reference](https://quarto.org/docs/authoring/markdown-basics.html) for the full feature set. |
59 | 72 |
|
60 | 73 | ;; ### Visualizations |
61 | 74 |
|
|
101 | 114 | [:circle {:r 40 :cx 50 :cy 50 :fill "lightblue"}] |
102 | 115 | [:circle {:r 20 :cx 50 :cy 50 :fill "lightgreen"}]] |
103 | 116 |
|
| 117 | +;; Anything you can do in a web page can be expressed as hiccup, such as including JavaScript in the page. |
| 118 | + |
| 119 | +^:kind/hiccup |
| 120 | +[:script {:src "https://cdn.jsdelivr.net/npm/scittle-kitchen/dist/scittle.js"}] |
| 121 | + |
| 122 | +;; `^:kind/hiccup` is Clojure syntax for attaching metadata. |
| 123 | +;; Kindly is a standard for annotation, and helpers for attaching metadata annotations. |
| 124 | + |
| 125 | +(kind/hiccup |
| 126 | + [:svg {:width "100%"} |
| 127 | + [:circle {:r 40 :cx 50 :cy 50 :fill "lightblue"}] |
| 128 | + [:circle {:r 20 :cx 50 :cy 50 :fill "lightgreen"}]]) |
| 129 | + |
| 130 | +;; Metadata on values for visualization tools like Clay to know what to do with the value. |
| 131 | + |
104 | 132 | ;; ## So - Notebooks? |
105 | 133 |
|
106 | 134 | ;; Yes, Clay interleaves code, results, narrative and visualizations. |
|
109 | 137 |
|
110 | 138 | ;; But, there is no execution model or environment. |
111 | 139 |
|
112 | | -;; > It's your Clojure code, the way you usually write it. |
| 140 | +;; > You write plain Clojure code, you can run it without Clay. |
| 141 | + |
| 142 | +;; Clay is not a dependency of your code. |
| 143 | + |
| 144 | +;; > Write with your normal workflow, sometimes using Clay to visualize as you go. |
113 | 145 |
|
114 | | -;; Clay is not _required_ by your code. |
115 | 146 | ;; Clay takes code as input and makes a document. |
116 | 147 |
|
117 | | -;; > Produces **HTML**, PDF, presentations and Markdown. |
| 148 | +;; > Produces **HTML** or Markdown which may be further processed into PDF, slides, or websites. |
118 | 149 |
|
119 | 150 | ;; ## Why make documents from code? |
120 | 151 |
|
|
125 | 156 | ;; | Sharing ideas is important | Foundation of human progress. Fuels technology, communities, and civilization. | |
126 | 157 | ;; | Code crystallizes thinking | Concrete, logical, reproducible, explorable, and extensible. | |
127 | 158 | ;; | Edit code not documents | Thinking and coding is the hard part. | |
128 | | -;; | Publishing matters | Share your idea in a widely accessible format. | |
| 159 | +;; | Publishing matters | Share your idea in a widely accessible formats. | |
129 | 160 |
|
130 | 161 | ;; ## Why use Clay? |
131 | 162 |
|
|
138 | 169 | ;; | Publishing | Notebook | Markdown | |
139 | 170 | ;; : Clay is _simple_ |
140 | 171 |
|
| 172 | +;; People really enjoy the workflow and results. |
| 173 | + |
| 174 | +;; > "Best notebook experience I've had" |
| 175 | + |
141 | 176 | ;; ## How to Clay |
142 | 177 |
|
143 | 178 | ;; To use Clay is to send it some code. |
|
168 | 203 | ;; by searching for "Clay". |
169 | 204 | ;; I highly recommend creating a custom keybinding that works with your configuration. |
170 | 205 |
|
| 206 | +;; A browser window will be shown when you call Clay. |
| 207 | +;;  |
| 208 | + |
| 209 | +;; ### Anyone stuck? |
| 210 | + |
171 | 211 | ;; If you are having difficulty getting started, |
172 | 212 | ;; you might find it easier to clone an existing project: |
173 | 213 |
|
|
178 | 218 |
|
179 | 219 | ;; ### Live reload |
180 | 220 |
|
181 | | -;; Clay can watch for file changes and re-render document. |
| 221 | +;; Clay can watch for file changes and re-render the document. |
182 | 222 | ;; Use the "Clay watch" REPL command to toggle live reload mode. |
183 | 223 |
|
184 | 224 | ;; Create or edit a source file and it will be shown in the browser. |
|
197 | 237 |
|
198 | 238 | ;; ## Ideas for explorations |
199 | 239 |
|
200 | | -;; The purpose of this Workshop is to encourage you to create your own namespace and use clay to render it. |
| 240 | +;; Take some time to create your own namespace and use Clay to render it. |
201 | 241 | ;; Here are some tiny ideas you might write about. |
202 | 242 |
|
203 | 243 | ;; ### What is macroexpand? |
@@ -229,9 +269,17 @@ freq |
229 | 269 |
|
230 | 270 | (-> scatter-ds |
231 | 271 | (tp/base {:=title "Sample Scatter Plot"}) |
232 | | - (tp/layer-point {:=x :x |
233 | | - :=y :y})) |
| 272 | + (tp/layer-point {:=x :x |
| 273 | + :=y :y})) |
234 | 274 |
|
235 | 275 | ;; ## Question time |
236 | 276 |
|
237 | | -;; Stuck? Need help? Please speak up! |
| 277 | +;; Please speak up! |
| 278 | +;; Stuck? |
| 279 | +;; Need help? |
| 280 | +;; Want to see a feature demonstrated? |
| 281 | +;; Questions about configuration, Quarto, Markdown, formats, narrowing? |
| 282 | +;; Feature suggestions? |
| 283 | +;; Share your experiences? |
| 284 | + |
| 285 | +;; Remaining questions can be asked in the [#clay-dev channel](https://clojurians.zulipchat.com/#narrow/channel/422115-clay-dev). |
0 commit comments