Created
January 28, 2014 00:09
-
-
Save johnwalker/8659992 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns coogle.core | |
(use [clojure.core.typed] | |
[clojure.core.typed.base-env] | |
[compojure.core]) | |
(require [compojure.route :as route] | |
[hiccup.core :refer [html]]) | |
(:gen-class)) | |
(cf +) | |
(defmacro get-sigs [symbols] | |
`(zipmap ~symbols | |
(for [k# ~symbols] | |
(eval `(try (cf ~k#) | |
(catch Exception ~(gensym) nil)))))) | |
(defn- get-signatures [symbols] | |
(binding [*out* nil | |
*err* nil] | |
(get-sigs symbols))) | |
(defn- get-signatures-ns [ns] | |
(-> ns | |
ns-publics | |
keys | |
get-signatures)) | |
(defn- get-signatures-by-all-ns [] | |
(let [nss (all-ns)] | |
(zipmap nss (map get-signatures-ns nss)))) | |
(def db (atom (get-signatures-by-all-ns))) | |
(defn query-fn->sig [] | |
(into {} (map (fn [[_ m]] m) @db))) | |
(defn query-fn->sig-nonil [] | |
(into {} (remove (fn [[_ v]] (nil? v)) (query-fn->sig)))) | |
(defmacro require-all [] | |
(loop [nss# (remove #{*ns*} (all-ns))] | |
(println (first nss#)) | |
(when (seq? nss#) | |
`(require ~(first nss#)) | |
(recur (next nss#))))) | |
(def docs (html [:ul | |
(for [f (query-fn->sig-nonil)] | |
[:li (pr-str f)])])) | |
(defn doc-page [req] | |
docs) | |
(defroutes app | |
(GET "/" [] doc-page) | |
(route/not-found "<h1>Page not found</h1>")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment