diff --git a/backend/resources/api-doc.css b/backend/resources/api-doc.css index b9b14a889..2404aea93 100644 --- a/backend/resources/api-doc.css +++ b/backend/resources/api-doc.css @@ -85,6 +85,16 @@ header { .rpc-row-info > .name { width: 280px; /* font-weight: bold; */ + border-right: 1px dotted #777; + padding-right: 10px; +} + +.rpc-row-info > .module { + width: 120px; + font-weight: bold; + border-right: 1px dotted #777; + text-align: right; + padding-right: 10px; } .rpc-row-info > .tags > .tag > span:first-child { diff --git a/backend/resources/api-doc.tmpl b/backend/resources/api-doc.tmpl index 35d3a700d..fa1a6d9ab 100644 --- a/backend/resources/api-doc.tmpl +++ b/backend/resources/api-doc.tmpl @@ -26,6 +26,7 @@
  • {#
    {{item.type}}
    #} +
    {{item.module}}:
    {{item.name}}
    @@ -53,6 +54,8 @@
  • {#
    {{item.type}}
    #} + +
    {{item.module}}:
    {{item.name}}
    @@ -80,6 +83,7 @@
  • {#
    {{item.type}}
    #} +
    {{item.module}}:
    {{item.name}}
    diff --git a/backend/src/app/http/doc.clj b/backend/src/app/http/doc.clj index 5addbb9a6..c467e8644 100644 --- a/backend/src/app/http/doc.clj +++ b/backend/src/app/http/doc.clj @@ -14,6 +14,7 @@ [app.util.template :as tmpl] [clojure.java.io :as io] [clojure.spec.alpha :as s] + [cuerdas.core :as str] [integrant.core :as ig] [pretty-spec.core :as ps] [yetti.response :as yrs])) @@ -30,25 +31,26 @@ [methods] (letfn [(gen-doc [type [name f]] (let [mdata (meta f)] - ;; (prn name mdata) {:type (d/name type) :name (d/name name) + :module (-> (:ns mdata) (str/split ".") last) :auth (:auth mdata true) :docs (::sv/docs mdata) :spec (get-spec-str (::sv/spec mdata))}))] {:command-methods - (into [] - (map (partial gen-doc :command)) - (->> methods :commands (sort-by first))) + (->> (:commands methods) + (map (partial gen-doc :command)) + (sort-by (juxt :module :name))) + :query-methods - (into [] - (map (partial gen-doc :query)) - (->> methods :queries (sort-by first))) + (->> (:queries methods) + (map (partial gen-doc :query)) + (sort-by (juxt :module :name))) :mutation-methods - (into [] - (map (partial gen-doc :mutation)) - (->> methods :mutations (sort-by first)))})) + (->> (:mutations methods) + (map (partial gen-doc :query)) + (sort-by (juxt :module :name)))})) (defn- handler [methods] diff --git a/backend/src/app/rpc.clj b/backend/src/app/rpc.clj index bfe570d7e..801fc5c1f 100644 --- a/backend/src/app/rpc.clj +++ b/backend/src/app/rpc.clj @@ -204,8 +204,9 @@ (defn- process-method [cfg vfn] (let [mdata (meta vfn)] + ;; (prn mdata) [(keyword (::sv/name mdata)) - (wrap cfg (deref vfn) mdata)])) + (wrap cfg vfn mdata)])) (defn- resolve-query-methods [cfg] diff --git a/backend/src/app/util/services.clj b/backend/src/app/util/services.clj index 9faa8adcb..5131f45c4 100644 --- a/backend/src/app/util/services.clj +++ b/backend/src/app/util/services.clj @@ -40,9 +40,14 @@ (comp (d/domap require) (map find-ns) - (mapcat ns-publics) - (map second) - (filter #(::spec (meta %))))) + (mapcat (fn [ns] + (->> (ns-publics ns) + (map second) + (filter #(::spec (meta %))) + (map (fn [fvar] + (with-meta (deref fvar) + (-> (meta fvar) + (assoc :ns (-> ns ns-name str))))))))))) (defn scan-ns [& nsyms]