Skip to content

Commit

Permalink
added fn to render notebook files
Browse files Browse the repository at this point in the history
  • Loading branch information
behrica committed Nov 23, 2024
1 parent 2a64c26 commit 29ed195
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
with:

push: never
runCmd: clj -Adev notebooks/dev.clj
runCmd: clj -A:dev -X dev/render-all-notebooks

- name: fix permisions
run: sudo chmod o+w docs/
Expand Down
45 changes: 31 additions & 14 deletions notebooks/dev.clj
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
(ns dev
(:require [scicloj.clay.v2.api :as clay]))
(:require
[clojure.edn :as edn]
[scicloj.clay.v2.api :as clay]))

(defn base-config []



(defn base-config [clj-files]
{:show false
:format [:quarto :html]
:base-source-path "notebooks"
:source-path (->> "notebooks/chapters.edn"
slurp
clojure.edn/read-string
(map (fn [part]
(-> part
(update
:chapters
(partial map #(format "noj_book/%s.clj" %))))))
(cons "index.clj"))
:source-path clj-files
:base-target-path "docs"
:book {:title "Noj"}
:clean-up-target-dir true
Expand All @@ -23,13 +20,33 @@
<link rel = \"icon\" href = \"data:,\" />"}}})


(def clj-files
(->> "notebooks/chapters.edn"
slurp
edn/read-string
(map (fn [part]
(-> part
(update
:chapters
(partial map #(format "noj_book/%s.clj" %))))))
(cons "index.clj"))

)

;; For interactive local testing:
(comment
(-> (base-config)
(-> (base-config clj-files)
(assoc :show true
:base-target-path "docs-draft")
clay/make!))

;; can be called by
;; clj -A:dev -X dev/render-notebook :notebook '"noj_book/ml_basic.clj"'
(defn render-notebook [opts]
(clay/make! (base-config [(:notebook opts)]))
(System/exit 0))

(defn render-all-notebooks [_opts]
(clay/make! (base-config clj-files))
(System/exit 0))

(clay/make! (base-config))
(System/exit 0)

0 comments on commit 29ed195

Please sign in to comment.