Skip to content

Commit 346536f

Browse files
authored
Add deps-new, sci (#12)
1 parent 429a5e8 commit 346536f

File tree

42 files changed

+2661
-4354
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2661
-4354
lines changed

.clj-kondo/babashka/fs/config.edn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{:lint-as {babashka.fs/with-temp-dir clojure.core/let}}

.clj-kondo/babashka/sci/config.edn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{:hooks {:macroexpand {sci.core/copy-ns sci.core/copy-ns}}}

.clj-kondo/babashka/sci/sci/core.clj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(ns sci.core)
2+
3+
(defmacro copy-ns
4+
([ns-sym sci-ns]
5+
`(copy-ns ~ns-sym ~sci-ns nil))
6+
([ns-sym sci-ns opts]
7+
`[(quote ~ns-sym)
8+
~sci-ns
9+
(quote ~opts)]))
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{:config-in-call {nextjournal.clerk.viewer/->viewer-fn {:linters {:unresolved-symbol {:exclude [clj->js]}
2+
:unresolved-namespace {:exclude [nextjournal.clerk.render
3+
nextjournal.clerk.render.code
4+
nextjournal.clerk.render.hooks
5+
js]}}}
6+
nextjournal.clerk.viewer/->viewer-eval {:linters {:unresolved-symbol {:exclude [clj->js]}
7+
:unresolved-namespace {:exclude [nextjournal.clerk.render
8+
nextjournal.clerk.render.code
9+
nextjournal.clerk.render.hooks
10+
js]}}}}
11+
:hooks {:analyze-call {nextjournal.clerk.viewer/->viewer-fn nextjournal.clerk.viewer/->viewer-fn
12+
nextjournal.clerk.viewer/->viewer-eval nextjournal.clerk.viewer/->viewer-fn}}
13+
:lint-as {nextjournal.clerk/defcached clojure.core/def}}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(ns nextjournal.clerk.viewer
2+
(:require [clj-kondo.hooks-api :as api]
3+
[clojure.string :as str]))
4+
5+
(defn ->viewer-fn [{:keys [node]}]
6+
(let [[name-node quoted-node] (:children node)
7+
quoted-tag (api/tag quoted-node)]
8+
(when (= :quote quoted-tag)
9+
(let [quoted-node {:tag :syntax-quote
10+
:children (:children quoted-node)}
11+
fn-node (first (:children quoted-node))]
12+
{:node fn-node}))))
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{:lint-as
2+
{mentat.clerk-utils/->clerk clojure.test/do
3+
mentat.clerk-utils/->clerk-only clojure.test/do}
4+
:config-in-call
5+
{mentat.clerk-utils.show/show-sci
6+
{:linters
7+
{:unresolved-symbol {:level :off}
8+
:unresolved-namespace {:level :off}}}
9+
mentat.clerk-utils.show/show-cljs
10+
{:linters
11+
{:unresolved-symbol {:level :off}
12+
:unresolved-namespace {:level :off}}}}}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{:lint-as
2+
{rewrite-clj.zip/subedit-> clojure.core/->
3+
rewrite-clj.zip/subedit->> clojure.core/->>
4+
rewrite-clj.zip/edit-> clojure.core/->
5+
rewrite-clj.zip/edit->> clojure.core/->>}}

.github/workflows/gh-pages.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,17 @@ jobs:
1010
steps:
1111
- uses: actions/cache@v3
1212
with:
13-
path: |
14-
.cpcache
15-
.shadow-cljs
16-
~/.m2
17-
key: "1"
13+
path: ~/.m2
14+
key: ${{ runner.os }}-m2-${{ hashFiles('**/deps.edn') }}
15+
restore-keys: ${{ runner.os }}-m2
1816

19-
- uses: actions/checkout@v3
17+
- name: Checkout
18+
uses: actions/checkout@v3
2019

2120
- name: Install clojure tools
2221
uses: DeLaGuardo/setup-clojure@4.0
2322
with:
24-
# Install just one or all simultaneously
25-
cli: 1.10.3.1087 # Clojure CLI based on tools.deps
26-
# (optional) To avoid rate limit errors please provide github token
23+
cli: latest
2724
github-token: ${{ secrets.GITHUB_TOKEN }}
2825

2926
- name: Install babashka
@@ -32,11 +29,10 @@ jobs:
3229
version: '0.8.156'
3330

3431
- name: Build static site
35-
run: bb publish-gh-pages
32+
run: bb build-static
3633

3734
- name: Deploy
3835
uses: peaceiris/actions-gh-pages@v3
39-
if: ${{ github.ref == 'refs/heads/main' }}
4036
with:
4137
github_token: ${{ secrets.GITHUB_TOKEN }}
42-
publish_dir: ./public
38+
publish_dir: ./public/build

.github/workflows/kondo.yml

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,10 @@ jobs:
1212
- name: Checkout
1313
uses: actions/checkout@v2
1414

15-
- uses: DeLaGuardo/setup-clojure@master
15+
- name: Install babashka
16+
uses: just-sultanov/setup-babashka@v2
1617
with:
17-
cli: latest
18-
19-
- name: Set up JDK 17
20-
uses: actions/setup-java@v2
21-
with:
22-
distribution: 'zulu'
23-
java-version: '17'
24-
25-
- name: Install clj-kondo
26-
run: sudo ./bin/install-clj-kondo
27-
28-
- name: Cache Maven packages
29-
uses: actions/cache@v2
30-
with:
31-
path: ~/.m2
32-
key: ${{ runner.os }}-m2-${{ hashFiles('**/deps.edn') }}
33-
restore-keys: ${{ runner.os }}-m2
34-
35-
- name: Install dependencies
36-
run: clojure -P -M:dev:lint
18+
version: '0.8.156'
3719

3820
- name: Cache kondo directory
3921
uses: actions/cache@v2
@@ -43,5 +25,4 @@ jobs:
4325
restore-keys: ${{ runner.os }}-kondo
4426

4527
- name: Run clj-kondo
46-
run: |
47-
clj-kondo --lint src:dev --config '{:output {:pattern "::{{level}} file={{filename}},line={{row}},col={{col}}::{{message}}"}}'
28+
run: bb lint --config '{:output {:pattern "::{{level}} file={{filename}},line={{row}},col={{col}}::{{message}}"}}'

CHANGELOG.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,41 @@
22

33
## [unreleased]
44

5+
## [0.2.0]
6+
7+
The interactive docs page is now published to https://mathlive.mentat.org.
8+
9+
- #12:
10+
11+
- Adds a `deps-new` template that sets up a basic Clerk project with
12+
`MathLive.cljs` installed as a dependency. [The template lives
13+
here](https://github.com/mentat-collective/MathLive.cljs/tree/main/resources/mathlive/clerk).
14+
15+
- Adds a `provided` dependency on SCI to `pom.xml`, so that cljdoc builds
16+
succeed.
17+
18+
- Adds `mathlive.sci` with SCI namespace objects for all namespaces, plus a
19+
`namespaces` map and a `config` for easy installation into SCI. The
20+
namespaces follows the patterns set by the
21+
https://github.com/babashka/sci.configs repo.
22+
23+
- `mathlive.sci/install!` allows the user to install `MathLive.cljs` into
24+
SCI's shared context with one mutating call.
25+
26+
- Migrates the project over to `clerk-utils` and all of its new custom build
27+
stuff. This let me simplify development, update the README and DEVELOPING
28+
pages and kill my shadow-cljs.edn file. `user.clj` gets quite a bit simpler
29+
too.
30+
31+
- Adds notes to the interactive docs guide about using the library with SCI
32+
and with Clerk
33+
34+
- Upgrades to Clerk version `fad499407d979916d21b33cc7e46e73f7a485e37` for the
35+
template and project docs notebook
36+
537
## 0.1.0
638

7-
- Added final `Mathfield component`
39+
- Added final `Mathfield` component
840

941
- Published fleshed-out documentation notebook at https://mentat-collective.github.io/mathlive.cljs
1042

DEVELOPING.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
## Dev Dependencies
22

3-
`clj`, `shadow-cljs`, `node` and `babashka`.
3+
- [node.js](https://nodejs.org/en/)
4+
- The [clojure command line tool](https://clojure.org/guides/install_clojure)
5+
- [Babashka](https://github.com/babashka/babashka#installation)
46

57
## Github Pages, Docs Notebook
68

7-
The project's [Github Pages
8-
site](https://mentat-collective.github.io/mathlive.cljs) hosts an interactive
9-
[Clerk](https://github.com/nextjournal/clerk) notebook demonstrating the
10-
library's use.
9+
The project's [Github Pages site](https://mathlive.mentat.org) hosts an
10+
interactive [Clerk](https://github.com/nextjournal/clerk) notebook demonstrating
11+
the library's use.
1112

1213
### Local Notebook Dev
1314

14-
To start a shadow-cljs process watcher for the JS required to run the Clerk
15-
notebook, run
15+
Start a Clojure process however you like, and run `(user/serve!)` to run the
16+
Clerk server. This command should open up `localhost:7777`.
1617

17-
```
18-
bb dev-notebook
19-
```
18+
Alternatively, run
2019

21-
Then start a Clojure process however you like, and run `(user/start!)` to run
22-
the Clerk server. This command should open up `localhost:7777`.
20+
```sh
21+
bb clerk-watch
22+
```
2323

24-
### Github Pages Static Build
24+
### Static Build
2525

26-
To test the Pages build locally:
26+
To test the static build locally:
2727

2828
```
2929
bb publish-local
3030
```
3131

32-
This will generate the static site in `public`, start a development http server
33-
and open up a browser window (http://127.0.0.1:8080/) with the production build
34-
of the documentation notebook.
32+
This will generate the static site in `public/build`, start a development http
33+
server and open up a browser window (http://127.0.0.1:8080/) with the production
34+
build of the documentation notebook.
3535

36-
### Pages Build
36+
### GitHub Pages
3737

3838
To build and release to Github Pages:
3939

4040
```
4141
bb release-gh-pages
4242
```
4343

44-
This will ship the site to https://mentat-collective.github.io/mathlive.cljs/.
44+
This will ship the site to https://mathlive.mentat.org.
4545

4646
## Publishing to Clojars
4747

@@ -67,9 +67,7 @@ The new release will appear on Clojars.
6767

6868
## Linting
6969

70-
Code is linted with `clj-kondo`. [Install
71-
`clj-kondo`](https://github.com/clj-kondo/clj-kondo/blob/master/doc/install.md)
72-
then run
70+
Code is linted with [`clj-kondo`](https://github.com/clj-kondo/clj-kondo):
7371

7472
```
7573
bb lint

README.md

Lines changed: 57 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1-
# mathlive.cljs
1+
# MathLive.cljs
22

3-
A [ClojureScript][CLJS] + [Reagent][REAGENT] wrapper over the [MathLive][MATHLIVE] equation editor.
3+
A [ClojureScript][cljs-url] + [Reagent][reagent-url] wrapper over the [MathLive][mathlive-url] equation editor.
44

5-
[![Build Status](https://github.com/mentat-collective/mathlive.cljs/actions/workflows/kondo.yml/badge.svg?branch=main)](https://github.com/mentat-collective/mathlive.cljs/actions/workflows/kondo.yml)
6-
[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/mentat-collective/mathlive.cljs/blob/main/LICENSE)
7-
[![cljdoc badge](https://cljdoc.org/badge/org.mentat/mathlive.cljs)](https://cljdoc.org/d/org.mentat/mathlive.cljs/CURRENT)
8-
[![Clojars Project](https://img.shields.io/clojars/v/org.mentat/mathlive.cljs.svg)](https://clojars.org/org.mentat/mathlive.cljs)
5+
[![Build Status][build-status]][build-status-url]
6+
[![License][license]][license-url]
7+
[![cljdoc badge][cljdoc]][cljdoc-url]
8+
[![Clojars Project][clojars]][clojars-url]
9+
[![Discord Shield][discord]][discord-url]
910

1011
## Quickstart
1112

12-
Install `mathlive.cljs` into your Clojurescript project using the instructions
13+
Install `MathLive.cljs` into your Clojurescript project using the instructions
1314
at its Clojars page:
1415

15-
[![Clojars
16-
Project](https://img.shields.io/clojars/v/org.mentat/mathlive.cljs.svg)](https://clojars.org/org.mentat/mathlive.cljs)
16+
[![Clojars Project][clojars]][clojars-url]
17+
18+
Or grab the most recent code using a Git dependency:
19+
20+
```clj
21+
;; deps
22+
{io.github.mentat-collective/mathlive.cljs
23+
{:git/sha "$GIT_SHA"}}
24+
```
1725

1826
Require `mathlive.core` in your namespace:
1927

@@ -23,9 +31,11 @@ Require `mathlive.core` in your namespace:
2331
[reagent.core :as r]))
2432
```
2533

26-
The main entrypoint to the library is the `mathlive.core/Mathfield` component.
27-
This component acts like a Reagent `[:textarea ,,,]` and takes similar props,
28-
but allows for interactive mathematical input and conversion to LaTeX.
34+
The main entrypoint to the library is the
35+
[`mathlive.core/Mathfield`](https://cljdoc.org/d/org.mentat/mathlive.cljs/CURRENT/api/mathlive.core#Mathfield)
36+
component. This component acts like a Reagent `[:textarea ,,,]` and takes
37+
similar props, but allows for interactive mathematical input and conversion to
38+
LaTeX.
2939

3040
Here's an example component:
3141

@@ -43,35 +53,35 @@ Here's an example component:
4353
![2022-12-01 16 56 20](https://user-images.githubusercontent.com/69635/205183928-e0fb6227-c45c-4db7-982d-c8e8a3cb3ee8.gif)
4454

4555
See the project's [interactive documentation
46-
notebook](https://github.com/mentat-collective/mathlive.cljs) for more examples.
47-
The [MathLive guides](https://cortexjs.io/mathlive/guides/interacting/) are
48-
great resources as well.
56+
notebook](https://mathlive.mentat.org) for more examples. The [MathLive
57+
guides](https://cortexjs.io/mathlive/guides/interacting/) are great resources as
58+
well.
59+
60+
## Clerk Support
61+
62+
If you want to use `MathLive.cljs` with [Clerk][clerk-url], check out the
63+
[`mathlive/clerk` template][mathlive-clerk-template-url]. This
64+
[`deps-new`][deps-new-url] template will generate a Clerk project for you, fully
65+
configured to use `MathLive.cljs` in your Clerk notebooks.
4966

5067
## Interactive Documentation via Clerk
5168

52-
The project's [interactive
53-
documentation](https://mentat-collective.github.io/mathlive.cljs) was generated
54-
using Nextjournal's [Clerk](https://github.com/nextjournal/clerk). If you'd like
55-
to edit or play with the documentation, you'll need to install
69+
The project's [interactive documentation](https://mathlive.mentat.org) was
70+
generated using Nextjournal's [Clerk](https://github.com/nextjournal/clerk). If
71+
you'd like to edit or play with the documentation, you'll need to install
5672

5773
- [node.js](https://nodejs.org/en/)
5874
- The [clojure command line tool](https://clojure.org/guides/install_clojure)
5975
- [Babashka](https://github.com/babashka/babashka#installation)
6076

61-
Once this is done, run this command in one terminal window to build and serve the custom JS required by the notebook:
77+
Once this is done, run this command:
6278

63-
```
64-
bb dev-notebook
65-
```
66-
67-
In another terminal window, run
68-
69-
```
70-
bb start-clerk
79+
```sh
80+
bb clerk-watch
7181
```
7282

73-
This should open a browser window to `http://localhost:7777` with the contents
74-
of the documentation notebook. Any edits you make to `dev/mathlive/notebook.clj`
83+
This will open a browser window to `http://localhost:7777` with the contents of
84+
the documentation notebook. Any edits you make to `dev/mathlive/notebook.clj`
7585
will be picked up and displayed in the browser on save.
7686

7787
## Thanks and Support
@@ -91,6 +101,20 @@ Copyright © 2022 Sam Ritchie.
91101

92102
Distributed under the [MIT License](LICENSE). See [LICENSE](LICENSE).
93103

94-
[CLJS]: https://clojurescript.org/
95-
[MATHLIVE]: https://github.com/arnog/mathlive
96-
[REAGENT]: https://reagent-project.github.io/
104+
[build-status-url]: https://github.com/mentat-collective/mathlive.cljs/actions/workflows/kondo.yml
105+
[build-status]: https://github.com/mentat-collective/mathlive.cljs/actions/workflows/kondo.yml/badge.svg?branch=main
106+
[cljdoc-url]: https://cljdoc.org/d/org.mentat/mathlive.cljs/CURRENT
107+
[cljdoc]: https://cljdoc.org/badge/org.mentat/mathlive.cljs
108+
[clojars-url]: https://clojars.org/org.mentat/mathlive.cljs
109+
[clojars]: https://img.shields.io/clojars/v/org.mentat/mathlive.cljs.svg
110+
[discord-url]: https://discord.gg/hsRBqGEeQ4
111+
[discord]: https://img.shields.io/discord/731131562002743336?style=flat&colorA=000000&colorB=000000&label=&logo=discord
112+
[license-url]: LICENSE
113+
[license]: https://img.shields.io/badge/license-MIT-brightgreen.svg
114+
[github-url]: https://github.com/mentat-collective/mathlive.cljs
115+
[reagent-url]: https://reagent-project.github.io/
116+
[mathlive-url]: https://mathlive.dev
117+
[deps-new-url]: https://github.com/seancorfield/deps-new
118+
[mathlive-clerk-template-url]: https://github.com/mentat-collective/MathLive.cljs/tree/main/resources/mathlive/clerk
119+
[clerk-url]: https://clerk.vision
120+
[cljs-url]: https://clojurescript.org/

0 commit comments

Comments
 (0)