Skip to content

Commit 0aef360

Browse files
committed
Use pandoc to convert markdown docstrings
1 parent 81e2ac0 commit 0aef360

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

.github/workflows/asciidoc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Install AsciiDoctor
2626
uses: awalsh128/cache-apt-pkgs-action@latest
2727
with:
28-
packages: asciidoctor
28+
packages: asciidoctor pandoc
2929
version: 1.0
3030
- name: Build AsciiDoc
3131
id: adocbuild

build.clj

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
(ns build
2-
(:require [clojure.java.io :as io]
2+
(:require [clojure.java.shell :as sh]
3+
[clojure.java.io :as io]
34
[clojure.string :as str]
45
[integrant.core :as ig]))
56

67
(defn- ->asciidoc [s]
7-
(-> s
8-
(str/replace #"(?m)^ " "")
9-
(str/replace #"(\n[^-][^\n]*)\n-" "$1\n\n-")))
8+
(:out (sh/sh "pandoc" "-t" "asciidoc" :in s)))
9+
10+
(defn- space-out-lists [s]
11+
(str/replace s #"(\n[^-][^\n]*)\n-" "$1\n\n-"))
12+
13+
(defn- trim-indent [s]
14+
(str/replace s #"(?m)^ " ""))
1015

1116
(def keywords
1217
[:duct.database/sql
@@ -21,9 +26,11 @@
2126
(ig/load-annotations)
2227

2328
(with-open [writer (io/writer "keywords.adoc")]
24-
(binding [*out* writer]
25-
(doseq [kw (sort keywords)]
26-
(println (str "=== " kw))
27-
(newline)
28-
(println (->asciidoc (:doc (ig/describe kw))))
29-
(newline))))
29+
(doseq [kw (sort keywords)]
30+
(let [doc (-> kw ig/describe :doc trim-indent space-out-lists ->asciidoc)]
31+
(binding [*out* writer]
32+
(println "###" kw)
33+
(newline)
34+
(println doc)))))
35+
36+
(shutdown-agents)

0 commit comments

Comments
 (0)