diff --git a/README.md b/README.md index 30a64e4..ff24e6e 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ The static-site generator behind jlt-commons project documentation. A project writes markdown; this turns it into a site that GitHub Pages serves. -It is a small babashka program, and `build`/`clean` also run under `jolt` -(jolt reads `bb.edn` tasks directly). `test` and `serve` still need `bb`: -jolt doesn't bundle `clojure.test` or `http-kit`. External dependencies +It is a small babashka program, and `build`, `clean` and `test` also run +under `jolt` (jolt reads `bb.edn` tasks directly). `serve` still needs `bb`: +it binds the port with `http-kit`, which jolt doesn't have. External dependencies (`markdown-clj`, `selmer`, and the `jolt-lang/yaml`/`jolt-lang/time` shims that make those two resolve under jolt) are fetched on first run. @@ -85,15 +85,15 @@ callout. ```bash jolt run build ../your-project # generate ../your-project/_site/ jolt run clean ../your-project # delete the build output -bb test # the test suite +jolt test # the test suite (or bb test) bb serve ../your-project # build, then serve, honouring :base-path bb serve ../your-project 4000 ``` -`build`/`clean` run under either tool. Under `jolt` it's `jolt run `, -not bare `jolt `: `build` collides with jolt's own native -`build -m NS` compiler subcommand. `test` and `serve` stay `bb`-only, -since jolt doesn't bundle `clojure.test` or `http-kit`. +`build`, `clean` and `test` run under either tool. Under `jolt` it's +`jolt run `, not bare `jolt `: `build` collides with jolt's own +native `build -m NS` compiler subcommand. `serve` stays `bb`-only, since it +uses `http-kit`. `_site/` is generated. Add it to the project's `.gitignore`. diff --git a/bb.edn b/bb.edn index a0bbdee..6a63f48 100644 --- a/bb.edn +++ b/bb.edn @@ -39,7 +39,7 @@ ;; unchanged (bb already has real java.time; this just adds tick's ;; API on top of it). io.github.jolt-lang/time {:git/url "https://github.com/jolt-lang/time.git" - :git/sha "abeee49974c2c4efa2fa75c96d9a379822c6815f"}} + :git/sha "b6d64a9ea4a71c6d40f66d0c3c9c4fff28f1bf8c"}} :tasks {;; tick.core first, unconditionally -- see the io.github.jolt-lang/time ;; comment above :deps. Everything after it in this list, and every @@ -60,11 +60,11 @@ (println "docs-engine — the jlt-commons documentation site generator\n") (println " jolt run build generate /_site/") (println " jolt run clean delete /_site/") - (println " bb test run the test suite") + (println " jolt test run the test suite") (println " bb serve [port] build, then serve at localhost:3000\n") - (println "build/clean run under either tool (jolt run , not bare jolt :") - (println "build collides with jolt's own build -m NS subcommand). test/serve stay") - (println "bb-only: jolt doesn't bundle clojure.test or http-kit.\n") + (println "build/clean/test run under either tool (jolt run , not bare jolt :") + (println "build collides with jolt's own build -m NS subcommand). serve stays") + (println "bb-only: it uses http-kit.\n") (println "A project configures itself in docs/site.edn. See README.md."))} test {:doc "Run the full test suite" diff --git a/src/site/core.clj b/src/site/core.clj index 5fb753b..27e93c9 100644 --- a/src/site/core.clj +++ b/src/site/core.clj @@ -379,13 +379,12 @@ ;; ;; Everything below builds a plain Ring handler `(fn [req]) -> {:status ;; :headers :body}` and touches no HTTP-server library at all, so it costs -;; build/clean/test nothing. site.serve (bb/JVM) and site.serve.jolt (jolt) -;; are the two thin wrappers that actually bind a port, each requiring the -;; one HTTP-server library their own host has: org.httpkit.server for -;; bb/JVM, ring-chez.adapter for jolt. Splitting it this way is what makes -;; build/clean/test loadable under jolt at all — org.httpkit.server isn't -;; resolvable there, and previously every task here required it via this -;; namespace regardless of whether it ever started a server. +;; build/clean/test nothing. site.serve is the thin wrapper that actually +;; binds a port, with org.httpkit.server, so `serve` runs under bb only. +;; Splitting it this way is what makes build/clean/test loadable under jolt +;; at all — org.httpkit.server isn't resolvable there, and previously every +;; task here required it via this namespace regardless of whether it ever +;; started a server. (defn- content-type [path] (cond diff --git a/src/site/serve.clj b/src/site/serve.clj index 2297514..76e605a 100644 --- a/src/site/serve.clj +++ b/src/site/serve.clj @@ -4,12 +4,8 @@ library involved at all; this namespace is the thin wrapper around org.httpkit.server that turns it into a running server. - Jolt never loads this file. site/serve.jolt is the jolt-native twin - (ring-chez.adapter instead of http-kit) — jolt's require resolves - .jolt before .clj (see the docs-engine README, \"Local preview - server: two hosts, one namespace\"), so the two never collide, and - babashka/JVM never see the .jolt file at all, since their own require - only ever looks for .clj/.cljc." + http-kit isn't available under jolt, so `serve` is bb-only; no other + task requires this namespace." (:require [org.httpkit.server :as hk] [site.core :as core])) diff --git a/test/site/core_test.clj b/test/site/core_test.clj index 3758acb..554fd52 100644 --- a/test/site/core_test.clj +++ b/test/site/core_test.clj @@ -1,7 +1,7 @@ (ns site.core-test (:require [babashka.fs :as fs] [clojure.java.io :as io] - [cheshire.core :as json] + [clojure.data.json :as json] [clojure.string :as str] [clojure.test :refer [deftest is testing]] [site.core :as core])) @@ -90,7 +90,7 @@ {:out (:output-dir site) :site site :index (let [f (io/file (:output-dir site) "search-documents.json")] - (when (fs/exists? f) (json/parse-string (slurp f)))) + (when (fs/exists? f) (json/read-str (slurp f)))) :doc (when-not readme? (slurp (io/file (:output-dir site) "guide" "index.html"))) :plain (slurp (io/file (:output-dir site) "guide" "plain.html")) :home (slurp (io/file (:output-dir site) "index.html"))})))) diff --git a/test/site/markdown_test.clj b/test/site/markdown_test.clj index 3901485..d7c9ec2 100644 --- a/test/site/markdown_test.clj +++ b/test/site/markdown_test.clj @@ -303,13 +303,13 @@ ;; this pins the JVM-side behavior this function must keep matching). (testing "preamble before the first heading becomes its own leading chunk" (is (= ["pre" "

A

mid" "

B

end"] - (md/split-before-h2-headings "pre

A

mid

B

end")))) + (#'md/split-before-h2-headings "pre

A

mid

B

end")))) (testing "no preamble when the body starts exactly at a heading" (is (= ["

A

mid" "

B

"] - (md/split-before-h2-headings "

A

mid

B

")))) + (#'md/split-before-h2-headings "

A

mid

B

")))) (testing "no headings at all returns the whole string as one chunk" (is (= ["just prose, no headings"] - (md/split-before-h2-headings "just prose, no headings"))))) + (#'md/split-before-h2-headings "just prose, no headings"))))) (deftest collapse-long-sections-leaves-short-pages-untouched ;; Below collapse-min-long-sections (5) the page reads as prose, and diff --git a/test/site/search_test.clj b/test/site/search_test.clj index 0184216..2136186 100644 --- a/test/site/search_test.clj +++ b/test/site/search_test.clj @@ -1,5 +1,5 @@ (ns site.search-test - (:require [cheshire.core :as json] + (:require [clojure.data.json :as json] [clojure.string :as str] [clojure.test :refer [deftest is testing]] [site.markdown :as md] @@ -16,7 +16,7 @@ "é → ü" ""]] (is (= [{"text" s}] - (json/parse-string (search/->json [{:text s}])))))) + (json/read-str (search/->json [{:text s}])))))) (testing "empty seq produces empty array" (is (= "[]" (search/->json [])))) (testing "U+2028 LINE SEPARATOR is escaped as \\u2028, not raw character"