Guest User

Untitled

a guest
Apr 26th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. (ns cljex.core
  2. (:gen-class)
  3. [:use compojure,
  4. clojure.contrib.duck-streams,
  5. clojure.contrib.shell-out,
  6. clojure.contrib.str-utils,
  7. cljex.view]
  8. [:import java.io.File])
  9.  
  10. (defn get-markdown-paths
  11. [docs-path] ; must be the /full/path, no ~ allowed
  12. (let [path (java.io.File. docs-path)]
  13. (filter #(re-matches #"(.*markdown)" %)
  14. (map #(str %) (file-seq path)))))
  15.  
  16. (defn apply-markdown
  17. [path-to-md write-to-path]
  18. (sh "/usr/local/bin/markdown" path-to-md "-f" write-to-path "-x codehilite"))
  19.  
  20. (defn sort-ns
  21. "Sorts the keys from the map returned by ns-publics for a given nspace into alphabetical order."
  22. [nspace]
  23. (vals (ns-publics nspace)))
  24.  
  25. ;; modified print doc to pop the current clj documentation for a form into the markdown file of the same name
  26. (defn print-doc-out)
  27.  
  28. ;; temporary reference for the above fn
  29. (defn print-ns-docs-to-file
  30. "Prints the documentation for a given nspace to a file-name which is located on path."
  31. [nspace, path-to-file, file-name]
  32. (with-out-writer
  33. (file-str path-to-file file-name)
  34. (doseq [s (sort-ns nspace)]
  35. (print-doc s))))
  36.  
  37. (routes
  38. (defroutes main-routes
  39. (GET "/"
  40. index)
  41. (GET "/docs/*"
  42. example-entry)))
Add Comment
Please, Sign In to add comment