blob: 2112647b0237d5fad8831062a3a1dd2cef2133ee (
plain) (
blame)
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
|
(ns generate-hooks-index.core
(:require [clojure.string :as str]
[hiccup.core :as h]
[taoensso.timbre :as log]
[clojure.java.shell :as sh])
(:gen-class))
(log/set-level! :info)
(defn clean-fn-arg
[s]
(-> s
(str/replace #"'" "")
(str/replace #"\"" "")
str/trim))
(defn check-fn-args
[xs]
(when (-> xs first empty?)
(throw (Exception. "empty function")))
(map clean-fn-arg xs))
(defn get-fn-arg
[s]
(->> s
(re-matches #".*call_hooks\((.+)\,(.*)\).*")
rest
check-fn-args))
(defn fix-path
[path file]
(str/replace file path ""))
(defn show-hooks
[path]
(for [s (-> (sh/sh "rgrep" "call_hooks" path)
:out
str/split-lines)
:let [[file hook] (str/split s #"\t*:")]]
(try
(-> (zipmap [:function :arg] (get-fn-arg hook))
(assoc :file (fix-path path file)))
(catch Exception e
(log/debug e s file hook)))))
(defn hiccupy
[path]
[:div
[:h3 "Hooks"]
[:table
[:tr (map #(vector :td %) ["Function" "Source File" "Arg"])]
(for [{:keys [function arg file]}
(->> path
show-hooks
(sort-by :function))]
[:tr (map #(vector :td (h/h %)) [function file arg])])]
[:p "Generated " (-> (java.util.Date.) str)]])
(defn make-hook-docs
[path-to-hubzillla]
(->> path-to-hubzillla
hiccupy
h/html
(spit (str path-to-hubzillla "doc/hooks.html"))))
(defn -main
[& args]
(log/info "Starting..")
(make-hook-docs (str (System/getProperty "user.dir") "/../../"))
(log/info "Done!")
(System/exit 0))
|