Skip to content

Instantly share code, notes, and snippets.

@curist
Created October 2, 2019 12:53
Show Gist options
  • Save curist/565346cd6937ac894391f33e7e6dc3ff to your computer and use it in GitHub Desktop.
Save curist/565346cd6937ac894391f33e7e6dc3ff to your computer and use it in GitHub Desktop.
jdoc() {
export JANET_PATH=/usr/local/lib/janet
janet -l ~/scripts/misc/import-all -e '(import-all) (each b (all-bindings) (print b))' \
| fzf --preview "echo {} | xargs -I[] \
janet -l ~/scripts/misc/import-all \
-e '(import-all) \
(def is-fun (let [t (type [])] (or (= t :function) (= t :cfunction)))) \
(if is-fun (doc []) (do (pp (type []))(pp [])))' \
| sed 's/^\s*//g' \
| awk NF" \
--preview-window top:70%:wrap \
--bind "alt-j:preview-down,alt-k:preview-up,ctrl-f:preview-page-down,ctrl-b:preview-page-up" \
| xargs -I{} janet -l ~/scripts/misc/import-all \
-e "(import-all) \
(def is-fun (let [t (type {})] (or (= t :function) (= t :cfunction)))) \
(if is-fun (doc {}) \
(do \
(print (quote {})) \
(pp (type {})) \
(pp {})))"
}
# alt+j to bring up jdoc
bind -x '"\ej":"jdoc"'
(defn import-all []
(def modules
(->> (os/dir (dyn :syspath))
(filter |(string/has-suffix? "janet" $))
(map |((string/split "." $) 0))))
(each m modules (import* m)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment