-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.clj
More file actions
91 lines (78 loc) · 2.76 KB
/
build.clj
File metadata and controls
91 lines (78 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
(ns build
(:require [clojure.java.shell :as sh]
[clojure.java.io :as io]
[clojure.string :as str]
[integrant.core :as ig]))
(defn- ->asciidoc [s]
(:out (sh/sh "pandoc" "-t" "asciidoc" :in s)))
(defn- space-out-lists [s]
(str/replace s #"(?m)^([^-][^\n]*)\n-" "$1\n\n-"))
(defn- trim-indent [s]
(str/replace s #"(?m)^ " ""))
(def keywords
(sort [:duct.compiler.cljs.shadow/release
:duct.compiler.cljs.shadow/server
:duct.database/sql
:duct.database.sql/hikaricp
:duct.handler/file
:duct.handler/reitit
:duct.handler/resource
:duct.handler/static
:duct.handler.static/ok
:duct.handler.static/bad-request
:duct.handler.static/not-found
:duct.handler.static/method-not-allowed
:duct.handler.static/internal-server-error
:duct.logger/simple
:duct.middleware.web/log-requests
:duct.middleware.web/log-errors
:duct.middleware.web/hide-errors
:duct.middleware.web/defaults
:duct.middleware.web/webjars
:duct.middleware.web/stacktrace
:duct.middleware.web/hiccup
:duct.migrator/ragtime
:duct.module/cljs
:duct.module/logging
:duct.module/sql
:duct.module/web
:duct.repl/refers
:duct.router/reitit
:duct.scheduler/simple
:duct.server.http/jetty
:duct.session-store/cookie]))
(defn- namespace->path [kw]
(-> (namespace kw) (str/replace #"\." "/") (str/replace #"-" "_")))
(defn- keyword->path [kw]
(str (namespace->path kw) "/" (-> (name kw) (str/replace #"-" "_"))))
(defn- find-resource [kw]
(or (io/resource (str (keyword->path kw) ".clj"))
(io/resource (str (namespace->path kw) ".clj"))))
(def ^:private re-artifact-path
#"\/\.m2/repository/(.*)/(.*?)/(.*?)/(.*?)\.jar\!")
(defn- get-dependency [path]
(let [[_ group artifact version _] (re-find re-artifact-path (str path))]
(str (str/replace group #"/" ".") "/" artifact
" {:mvn/version \"" version "\"}")))
(defn- get-fragment [kw]
(-> kw str (str/replace #"[:.-]" "_") (str/replace #"/" "")))
(ig/load-annotations)
(with-open [writer (io/writer "docs/keywords.adoc")]
(binding [*out* writer]
(println "[.concise-index]")
(println ".Index")
(println "****")
(doseq [kw keywords]
(println (str "- <<" (get-fragment kw) ">>")))
(println "****")
(newline)
(doseq [kw keywords]
(let [doc (-> kw ig/describe :doc trim-indent
space-out-lists ->asciidoc)]
(println "[discrete]")
(println "###" kw)
(newline)
(println (str "`" (get-dependency (find-resource kw)) "`"))
(newline)
(println doc)))))
(shutdown-agents)