reitit/test/clj/cljdoc/reaper.clj

35 lines
1.7 KiB
Clojure
Raw Normal View History

2018-05-18 15:35:00 +00:00
(ns cljdoc.reaper
2022-02-12 20:35:27 +00:00
(:require
[clojure.java.io :as io]
[clojure.pprint :as pprint]
[clojure.string :as str]))
2018-05-18 15:35:00 +00:00
(defn reap! []
(let [docs (->> (for [line (-> (io/file "./doc/SUMMARY.md") (slurp) (str/split #"\n"))
:let [data (-> (re-seq #"^(.*)\* \[(.*)\]\((.*)\)" line) first rest seq)]
:when data]
(let [[indent name file] data
wrap (if (pos? (count indent)) vector identity)]
(wrap [name {:file (str "doc/" file)}])))
(reduce
2022-02-12 20:34:26 +00:00
(fn [acc data]
(if (vector? (first data))
(update-in acc [(dec (count acc)) 2] (fnil into []) data)
(conj acc data))) [])
2018-05-18 15:35:00 +00:00
;; third sweep to flatten chids...
(mapv (fn [[n o c]] (if c (into [n o] c) [n o]))))
data {:cljdoc/include-namespaces-from-dependencies ['metosin/reitit
'metosin/reitit-core
'metosin/reitit-ring
'metosin/reitit-spec
'metosin/reitit-schema
'metosin/reitit-swagger
2018-08-24 15:39:20 +00:00
'metosin/reitit-swagger-ui
'metosin/reitit-frontend
'metosin/reitit-middleware]
2018-05-18 15:35:00 +00:00
:cljdoc.doc/tree docs}]
2018-10-31 06:48:14 +00:00
(spit "doc/cljdoc.edn" (with-out-str (pprint/pprint data)))))
2018-05-18 15:35:00 +00:00
(comment
(reap!))