Skip to content

Commit 0083416

Browse files
committed
Add docstring build task
Adds a Clojure script to add docstrings from Duct libraries into the documentation.
1 parent 9f89434 commit 0083416

File tree

6 files changed

+45
-4
lines changed

6 files changed

+45
-4
lines changed

.github/workflows/asciidoc.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ jobs:
1818
- name: Setup Pages
1919
id: pages
2020
uses: actions/configure-pages@v5
21+
- name: Install clojure tools
22+
uses: DeLaGuardo/[email protected]
23+
with:
24+
bb: latest
25+
- name: Install AsciiDoctor
26+
run: sudo apt install -y asciidoctor
2127
- name: Run ASCIIDoc
2228
id: adocbuild
23-
uses: tonynv/asciidoctor-action@master
24-
with:
25-
program: "asciidoctor -D build index.adoc"
29+
run: bb build
2630
- name: Print execution time
2731
run: echo "Time ${{ steps.adocbuild.outputs.time }}"
2832
- name: Upload artifact

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
build/
22
.clj-kondo/
3+
.cpcache/
4+
keywords.adoc

bb.edn

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
{:tasks
2-
{build (shell "asciidoctor -D build -b html5 index.adoc")}}
2+
{docstrings
3+
{:task (clojure "-M" "build.clj")}
4+
build
5+
{:depends [docstrings]
6+
:task (shell "asciidoctor -D build -b html5 index.adoc")}}}

build.clj

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
(ns build
2+
(:require [clojure.java.io :as io]
3+
[clojure.string :as str]
4+
[integrant.core :as ig]))
5+
6+
(defn- ->asciidoc [s]
7+
(-> s
8+
(str/replace #"(?m)^ " "")
9+
(str/replace #"(\n[^-][^\n]*)\n-" "$1\n\n-")))
10+
11+
(def keywords
12+
[:duct.logger/simple
13+
:duct.module/logging])
14+
15+
(ig/load-annotations)
16+
17+
(with-open [writer (io/writer "keywords.adoc")]
18+
(binding [*out* writer]
19+
(doseq [kw (sort keywords)]
20+
(println (str "=== " kw))
21+
(newline)
22+
(println (->asciidoc (:doc (ig/describe kw))))
23+
(newline))))

deps.edn

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{:paths ["."]
2+
:deps {org.clojure/clojure {:mvn/version "1.12.2"}
3+
integrant/integrant {:mvn/version "1.0.0"}
4+
org.duct-framework/module.logging {:mvn/version "0.6.6"}}}

index.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,3 +2022,7 @@ clj꞉user꞉> (go)
20222022

20232023
To reset the project, you can use `(reset)` at the REPL, or run the
20242024
command: *Calva: Refresh All Namespaces*.
2025+
2026+
== Keywords
2027+
2028+
include::keywords.adoc[]

0 commit comments

Comments
 (0)