Improve formatting

This commit is contained in:
oakes
2014-03-30 21:48:55 -04:00
parent 1891ca3463
commit 58828802e9
2 changed files with 27 additions and 16 deletions

View File

@@ -8,13 +8,6 @@
(def targets (-> "targets.edn" io/resource slurp edn/read-string)) (def targets (-> "targets.edn" io/resource slurp edn/read-string))
(defn camel->keyword
[s]
(->> (string/split (string/replace s "_" "-") #"(?<=[a-z])(?=[A-Z])")
(map string/lower-case)
(string/join "-")
keyword))
(defn parse-param (defn parse-param
[^Parameter p] [^Parameter p]
[(.typeName p) (.name p)]) [(.typeName p) (.name p)])
@@ -28,7 +21,7 @@
(subs (.name d) (+ 1 (.lastIndexOf (.name d) "."))) (subs (.name d) (+ 1 (.lastIndexOf (.name d) ".")))
:else :else
(.name d)) (.name d))
camel->keyword) html/camel->keyword)
(.commentText d) (.commentText d)
(when (isa? (type d) ExecutableMemberDoc) (when (isa? (type d) ExecutableMemberDoc)
(->> d .parameters (map parse-param) vec))]) (->> d .parameters (map parse-param) vec))])
@@ -60,7 +53,7 @@
(defn save (defn save
[doc-map] [doc-map]
(->> doc-map pr-str (spit (io/file "uberdoc.edn"))) (->> doc-map pr-str (spit (io/file "uberdoc.edn")))
(->> doc-map html/create-html (spit (io/file "uberdoc.html")))) (->> doc-map html/create (spit (io/file "uberdoc.html"))))
(defn parse (defn parse
[^RootDoc root] [^RootDoc root]

View File

@@ -1,18 +1,36 @@
(ns play-clj-doclet.html (ns play-clj-doclet.html
(:require [hiccup.core :refer :all])) (:require [clojure.string :as string]
[hiccup.core :refer :all]))
(defn create-item (defn camel->keyword
[s]
(->> (string/split (string/replace s "_" "-") #"(?<=[a-z])(?=[A-Z])")
(map string/lower-case)
(string/join "-")
keyword))
(defn param
[[type-name param-name]]
(html [:span {}
[:span {:class "type-name"} "^" type-name]
" "
(-> param-name camel->keyword name)]))
(defn item
[[name text params]] [[name text params]]
[:div [:div
[:h3 (str name)] [:p
[:b (str name)]
" "
(string/join ", " (map param params))]
[:i text]]) [:i text]])
(defn create-section (defn section
[[clj-name items]] [[clj-name items]]
[:div [:div
[:h2 {} clj-name] [:h2 {} clj-name]
(map create-item items)]) (map item (sort-by first items))])
(defn create-html (defn create
[doc-map] [doc-map]
(html (map create-section doc-map))) (html (map section doc-map)))