Skip to content

Commit 75d6be4

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

File tree

7 files changed

+83
-2
lines changed

7 files changed

+83
-2
lines changed

.github/workflows/asciidoc.yml

Lines changed: 5 additions & 1 deletion
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/setup-clojure@13.4
23+
with:
24+
bb: latest
2125
- name: Run ASCIIDoc
2226
id: adocbuild
2327
uses: tonynv/asciidoctor-action@master
2428
with:
25-
program: "asciidoctor -D build index.adoc"
29+
program: "bb build"
2630
- name: Print execution time
2731
run: echo "Time ${{ steps.adocbuild.outputs.time }}"
2832
- name: Upload artifact

.gitignore

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

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[]

keywords.adoc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
=== :duct.logger/simple
2+
3+
A simple buffered logger that adheres to the duct.logger/Logger protocol.
4+
5+
Takes the following options:
6+
7+
- `:appenders` - a collection of appender configurations
8+
- `:buffer-size` - the size of the logging ring buffer (default: 1024)
9+
- `:polling-rate` - the delay in ms between each poll (default: 5)
10+
- `:poll-chunk-size` - the max no. of logs to process each poll (default: 8)
11+
- `:shutdown-delay` - the delay in ms before shutting down (default: 100)
12+
- `:shutdown-timeout` - the time to wait in ms for shutdown (default: 1000)
13+
14+
Appender configurations are maps that have a `:type` option that can be one
15+
of:
16+
17+
- `:file` - logs are appended to a file
18+
- `:stdout` - logs are sent to STDOUT
19+
20+
File appenders have the following options:
21+
22+
- `:levels` - a set of log levels (or `:all`) to limit the appender to
23+
- `:brief?` - whether to omit timestamps and levels (defaults to false)
24+
25+
STDOUT appenders have the following options:
26+
27+
- `:levels` - a set of log levels (or `:all`) to limit the appender to
28+
- `:path` - the path of the log file
29+
30+
=== :duct.module/logging
31+
32+
A Duct module that adds logging to the configuration using the
33+
`:duct.logger/simple` component. Takes no options, but uses a different
34+
logging setup depending on the active profile:
35+
36+
- `:main` - write all logs in full to STDOUT
37+
- `:repl` - write all logs to `logs/repl.log` and `:report` level logs to
38+
STDOUT in brief (no timestamp)
39+
40+
- `:test` - write all logs to `logs/test.log`
41+

0 commit comments

Comments
 (0)