2018-05-18 15:35:00 +00:00
|
|
|
(ns cljdoc.reaper
|
|
|
|
|
(:require [clojure.java.io :as io]
|
2018-10-31 06:48:14 +00:00
|
|
|
[clojure.pprint :as pprint]
|
2018-05-18 15:35:00 +00:00
|
|
|
[clojure.string :as str]))
|
|
|
|
|
|
|
|
|
|
(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
|
|
|
|
|
(fn [acc data]
|
|
|
|
|
(if (vector? (first data))
|
|
|
|
|
(update-in acc [(dec (count acc)) 2] (fnil into []) data)
|
|
|
|
|
(conj acc data))
|
|
|
|
|
) [])
|
|
|
|
|
;; 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!))
|