-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
awb99
committed
Sep 11, 2024
1 parent
6aa9e67
commit 9cbe6b1
Showing
9 changed files
with
390 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Prepare java | ||
uses: actions/setup-java@v2 | ||
with: | ||
distribution: 'zulu' # https://github.com/actions/setup-java/blob/main/README.md#Supported-distributions | ||
java-version: '14' | ||
java-package: jdk # optional (jdk or jre) - defaults to jdk | ||
- name: Install clojure tools | ||
uses: DeLaGuardo/setup-clojure@3.5 | ||
with: | ||
cli: 1.11.1.1413 # Clojure CLI based on tools.deps | ||
clj-kondo: 2022.05.31 # Clj-kondo | ||
cljfmt: 0.10.2 # cljfmt | ||
- name: deploy to clojars | ||
if: success() | ||
env: | ||
CLOJARS_USERNAME: ${{ secrets.ReleaseUsername }} | ||
CLOJARS_PASSWORD: ${{ secrets.ReleasePassword }} | ||
run: | | ||
git config --global user.email "ci@pinkgorilla.org" | ||
git config --global user.name "CI/CD" | ||
clojure -T:build jar | ||
clojure -T:build deploy |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
*.jar | ||
*.class | ||
/lib/ | ||
/classes/ | ||
/target/ | ||
/checkouts/ | ||
.nrepl-port | ||
.cpcache/ | ||
/test/creds.edn | ||
.classpath | ||
.project | ||
.settings/* | ||
.calva | ||
.lsp/ | ||
.webly | ||
certs | ||
target/ | ||
ci/deps.edn | ||
demo-webly/karma.conf.js | ||
\#*\# | ||
creds.edn | ||
creds-wien.edn | ||
creds-localhost.edn | ||
.clj-kondo | ||
*~ | ||
\#*\# | ||
.\#* | ||
.~* | ||
.shadow-cljs | ||
node_modules | ||
karma.conf.js | ||
package.json | ||
package-lock.json | ||
shadow-cljs.edn | ||
goldly_bindings_generated.cljs | ||
resources/META-INF |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
# docy | ||
# docy [![GitHub Actions status |pink-gorilla/docy](https://github.com/pink-gorilla/docy/workflows/CI/badge.svg)](https://github.com/pink-gorilla/docy/actions?workflow=CI)[![Clojars Project](https://img.shields.io/clojars/v/org.pinkgorilla/docy.svg)](https://clojars.org/org.pinkgorilla/docy) | ||
|
||
|
||
## features | ||
|
||
- Docy shows dynamically customizable documentation for clojure namespaces. | ||
- Generated Documentation can be shown statically (say on github pages) | ||
- or it can be run interactively, which allows evaluating discovered examples. | ||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
(ns build | ||
(:require | ||
[babashka.fs :as fs] | ||
[clojure.tools.build.api :as b] | ||
[deps-deploy.deps-deploy :as dd])) | ||
|
||
(def lib 'org.pinkgorilla/docy) | ||
(def version (format "0.0.%s" (b/git-count-revs nil))) | ||
(def class-dir "target/classes") | ||
(def basis (b/create-basis {:project "deps.edn"})) | ||
(def jar-file (format "target/%s-%s.jar" (name lib) version)) | ||
|
||
(defn clean [_] | ||
(b/delete {:path "target"})) | ||
|
||
|
||
(def pom-template | ||
[[:licenses | ||
[:license | ||
[:name "Eclipse Public License"] | ||
[:url "https://www.eclipse.org/legal/epl-v10.html"]]] | ||
[:developers | ||
[:developer | ||
[:name "pink-gorilla"]]] | ||
[:scm | ||
[:url "https://github.com/pink-gorilla/docy"] | ||
[:connection "scm:git:git://github.com/pink-gorilla/docy.git"] | ||
[:developerConnection "scm:git:ssh://git@github.com/pink-gorilla/docy.git"]]]) | ||
|
||
|
||
(def opts {:class-dir class-dir | ||
:lib lib | ||
:version version | ||
:basis basis | ||
:pom-data pom-template | ||
:src-dirs ["src"]}) | ||
|
||
(defn jar [_] | ||
(b/write-pom opts) | ||
(b/copy-dir {:src-dirs ["src" "resources"] | ||
:target-dir class-dir}) | ||
(b/jar {:class-dir class-dir | ||
:jar-file jar-file})) | ||
|
||
|
||
(defn deploy "Deploy the JAR to Clojars." [_] | ||
(println "Deploying to Clojars.") | ||
(dd/deploy {:installer :remote | ||
;:sign-releases? true | ||
:pom-file (b/pom-path (select-keys opts [:lib :class-dir])) | ||
;:artifact "target/tech.ml.dataset.jar" | ||
:artifact (b/resolve-path jar-file)})) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{:paths ["src" | ||
"resources" ; extension data | ||
] | ||
:deps | ||
{org.clojure/clojure {:mvn/version "1.11.3"} | ||
cider/orchard {:mvn/version "0.26.1"} | ||
org.pinkgorilla/extension {:mvn/version "0.0.12"} | ||
org.pinkgorilla/clj-service {:mvn/version "0.3.20"}} | ||
:aliases | ||
{; github ci | ||
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.9.6"} | ||
slipset/deps-deploy {:mvn/version "0.2.1"} | ||
babashka/fs {:mvn/version "0.0.5"}} | ||
:ns-default build}} | ||
; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{:name "docy" | ||
; run-time | ||
:sci-cljs-ns [docy.page] | ||
:cljs-routes {"docy" {"" docy.page/docy-page | ||
["/ns/" :nss] docy.page/docy-ns-page | ||
["/ns/" :nss "/" :fun] docy.page/docy-fun-page}} | ||
|
||
; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
(ns docy.core | ||
(:require | ||
[orchard.info :as orchard] | ||
[taoensso.timbre :refer [info warn error]] | ||
[extension :as ext] | ||
[clj-service.core :refer [expose-functions]])) | ||
|
||
(defn docstring [symbol] | ||
(:doc (meta (resolve symbol)))) | ||
|
||
(defn describe-fun [nss fun] | ||
(let [data (orchard/info nss fun)] | ||
(merge | ||
data | ||
{:ns (str (:ns data)) | ||
:name (str (:name data))}))) | ||
|
||
|
||
(defn describe-ns [nss] | ||
(require [nss]) | ||
(let [symbols (keys (ns-publics nss))] | ||
{:ns (str nss) | ||
:names (->> symbols | ||
(map #(describe-fun nss %)) | ||
(filter :doc) | ||
(remove :deprecated ) | ||
(sort-by :name) | ||
)})) | ||
|
||
(defn build-namespaces [ns-symbol-seq] | ||
(info "building namespaces: " (count ns-symbol-seq)) | ||
(let [r (->> (map describe-ns ns-symbol-seq) | ||
(sort-by :ns) | ||
;(take 1) | ||
(into []))] | ||
;(info "result: " r) | ||
r)) | ||
|
||
(defn start-docy [{:keys [exts clj role namespaces]}] | ||
(info "starting docy .. ") | ||
(assert (vector? namespaces)) | ||
(info "starting docy namespaces: " (count namespaces)) | ||
;(add-discovered-namespaces this exts) | ||
(if clj | ||
(do | ||
(info "starting docy clj-services..") | ||
(expose-functions clj | ||
{:name "docy" | ||
:symbols ['docy.core/build-namespaces] | ||
:permission role | ||
:fixed-args [namespaces]})) | ||
(warn "docy starting without clj-services, perhaps you want to pass :clj key")) | ||
(info "docy running!") | ||
namespaces) | ||
|
||
(comment | ||
(orchard/info 'missionary.core 'amb>) | ||
(describe-fun 'missionary.core 'amb>) | ||
|
||
; deprecated should be removed | ||
; so amb and amb= should exist, but amb> should not | ||
(->> (describe-ns 'missionary.core) | ||
:names | ||
(map :name)) | ||
|
||
(->> (describe-ns 'missionary.core) | ||
:names | ||
(filter #(= "amb" (:name %))) | ||
) | ||
|
||
|
||
(describe-ns 'ta.calendar.core) | ||
|
||
(describe-ns 'ta.indicator.band) | ||
|
||
|
||
(require '[modular.system]) | ||
|
||
(def d (modular.system/system :docy)) | ||
|
||
d | ||
|
||
(build-namespaces d) | ||
|
||
|
||
|
||
; | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
(ns docy.page | ||
(:require | ||
[reagent.core :as r] | ||
[promesa.core :as p] | ||
[frontend.notification :refer [show-notification]] | ||
[goldly.service.core :refer [clj]] | ||
[docy.util :refer [link text]])) | ||
|
||
(def namespaces-dict-a (r/atom {})) | ||
|
||
(defn ns-seq->dict [ns-seq] | ||
(->> ns-seq | ||
(map (fn [{:keys [ns names]}] | ||
[ns names])) | ||
(into {}))) | ||
|
||
(defn ^:export init-docy! | ||
[new-namespaces] | ||
(println "init-docy: " new-namespaces) | ||
(println "init-docy! ns-count: " (count new-namespaces)) | ||
(reset! namespaces-dict-a (ns-seq->dict new-namespaces))) | ||
|
||
(defn get-data [] | ||
(let [rp (clj 'docy.core/build-namespaces)] | ||
(-> rp | ||
(p/then (fn [ns-seq] | ||
(init-docy! ns-seq))) | ||
(p/catch (fn [err] | ||
(println "docy fetch ns-seq error: " err) | ||
(show-notification :error "docy ns-seq fetch failed!")))))) | ||
|
||
; this makes sense because it only needs to be done once. | ||
(get-data) | ||
|
||
(defn docy-fun-page [{:keys [route-params] :as route}] | ||
(fn [{:keys [route-params] :as route}] | ||
(let [{:keys [nss fun]} route-params | ||
data (get @namespaces-dict-a nss)] | ||
[:div | ||
[:h1.text-xxl.text-blue-800 "Namespace: " (str nss) " Function: " (str fun)] | ||
[:div (pr-str data)]]))) | ||
|
||
;{:ns "missionary.core", | ||
; :name "amb", | ||
; :doc "In an `ap` block, evaluates each form sequentially and returns successive results.", | ||
; :file "missionary/core.cljc", | ||
; :arglists ([] [form] [form & forms]), | ||
; :macro true, | ||
; :line 496, | ||
; :column 1} | ||
|
||
|
||
(defn fun-ui [{:keys [name doc file line column arglists macro] :as fun}] | ||
[:<> | ||
; colum left - function name | ||
[:h1.text-xxl.text-blue-800.m-1.p-1 | ||
name] | ||
; column right - arglist and docstring | ||
[:div {:class "bg-gray-300 border-solid border-green-300" | ||
:style {:max-height "4cm" | ||
:overflow "auto"}} | ||
(when arglists | ||
[:span {:class "text-blue-900 text-bold"} | ||
(str arglists)]) | ||
(when macro | ||
[:span {:class "text-red-500 p-1"} "macro"]) | ||
[text doc]]]) | ||
|
||
(defn docy-ns-page [{:keys [route-params] :as route}] | ||
(fn [{:keys [route-params] :as route}] | ||
(let [{:keys [nss]} route-params | ||
data (get @namespaces-dict-a nss)] | ||
[:div.p-5 | ||
[:h1.text-xxl.text-blue-800 "Namespace: " (str nss)] | ||
;[:div (pr-str data)] | ||
[into [:div | ||
{:class "grid gap-1" ;.grid-cols-2.auto-cols-min | ||
:style {:grid-template-columns "1fr 4fr" | ||
:max-width "1200px"}}] (map fun-ui data)]]))) | ||
|
||
(defn ns-entry [ns-name] | ||
[:li {:style {:width "100px" | ||
:min-width "100px"}} | ||
[link {:to ['docy.page/docy-ns-page :nss (str ns-name)]} | ||
[:span {:style {:width "100px" | ||
:min-width "100px"} | ||
:class "w-64" | ||
} | ||
(str ns-name)]]]) | ||
|
||
(defn ns-list [ns-symbol-seq] | ||
(if (seq? ns-symbol-seq) | ||
(into [:ul {:style {:width "100px" | ||
:min-width "100px"}}] | ||
|
||
(map ns-entry ns-symbol-seq)) | ||
[:div "no docs available!"])) | ||
|
||
(defn docy-page [_route] | ||
(fn [{:keys [route-params] :as route}] | ||
(let [ns-symbol-seq (keys @namespaces-dict-a)] | ||
[:div.m-3.h-screen.w-screen | ||
[:h1.text-xxl.text-blue-800.p-2 "Docy Documentation "] | ||
[ns-list ns-symbol-seq] | ||
;[:div (pr-str ns-symbol-seq)] | ||
]))) |
Oops, something went wrong.