Skip to content

Commit

Permalink
book setup
Browse files Browse the repository at this point in the history
  • Loading branch information
daslu committed Jun 19, 2024
1 parent 2fc34c6 commit 86bcdd0
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions notebooks/chapters.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["walkthrough"]
13 changes: 13 additions & 0 deletions notebooks/dev.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(ns dev
(:require [scicloj.clay.v2.api :as clay]))

(clay/make! {:format [:quarto :html]
:base-source-path "notebooks"
:source-path (->> "notebooks/chapters.edn"
slurp
clojure.edn/read-string
(map #(format "hanacloth/%s.clj" %))
(cons "index.clj"))
:base-target-path "docs"
:book {:title "Hanacloth"}
:clean-up-target-dir true})
42 changes: 42 additions & 0 deletions notebooks/index.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
;; # Preface

^:kindly/hide-code
(ns index
(:require [scicloj.kindly.v4.api :as kindly]
[scicloj.kindly.v4.kind :as kind]
[clojure.string :as str]
[clojure.string :as string]
[scicloj.clay.v2.api :as clay]))

^:kindly/hide-code
(def md
(comp kindly/hide-code kind/md))

(md "
Hanacloth is a composition of Hanami data visualizations and Tablecloth datasets
## Existing chapters in this book:
")

^:kindly/hide-code
(defn chapter->title [chapter]
(or (some->> chapter
(format "notebooks/hanacloth/%s.clj")
slurp
str/split-lines
(filter #(re-matches #"^;; # .*" %))
first
(#(str/replace % #"^;; # " "")))
chapter))

(->> "notebooks/chapters.edn"
slurp
clojure.edn/read-string
(map (fn [chapter]
(prn [chapter (chapter->title chapter)])
(format "\n- [%s](hanacloth.%s.html)\n"
(chapter->title chapter)
chapter)))
(string/join "\n")
md)

0 comments on commit 86bcdd0

Please sign in to comment.