Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: dust doc improvements #29 #32

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions dust
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@ if [ -L "$base_path" ]; then
fi
base_path=`dirname $base_path`

pixie_path=`which pixie-vm`
pixie_path=`which pixie`
if [ -z "$pixie_path" ]; then
echo "Error: 'pixie-vm' must be on your PATH"
exit 1
pixie_path=`which pixie-vm`
if [ -z "$pixie_path" ]; then
pixie_path=`which pxi`
if [ -z "$pixie_path" ]; then
echo "Error: 'pixie' must be on your PATH"
exit 1
#else
# echo "Warning: Using 'pxi' on path is deprecated. 'pixie' is preferred."
fi
#else
# echo "Warning: Using 'pixie-vm' on path is deprecated. 'pixie' is preferred."
fi
fi

function set_load_path() {
Expand All @@ -22,7 +32,7 @@ function set_load_path() {
if [ ! -f "project.edn" ] && [ -f "project.pxi" ]; then
echo "Warning: 'project.pxi' is deprecated, please use 'project.edn'."
echo "To start you can run the following command:"
echo " pixie-vm -l $base_path/src -e '(require dust.project :as p) (p/load-project!) (prn (dissoc @p/*project* :path))'"
echo " $pixie_path -l $base_path/src -e '(require dust.project :as p) (p/load-project!) (prn (dissoc @p/*project* :path))'"
echo
fi

Expand Down
3 changes: 0 additions & 3 deletions project.pxi

This file was deleted.

50 changes: 32 additions & 18 deletions run.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@


(defn showdoc [ns function]
(let [name (str (if (not= ns "pixie.stdlib") (str ns "/") (str ns "/")))]
(let [name (str (if (= function "/") (str ns) (str ns "/")))]
;loads other possible namespaces in case function is in other namespace
(if (= @show-all true) (eval (read-string (str "(require " ns ")"))))

(let [data (meta (eval (read-string (str name function))))]
(print (str "\n " name function "\n\n\t"))
(let [func-name (if (not= (str/index-of function "/") nil) (str function) (str name function))]
(loop [sigs (lazy-seq (:signatures data))]
(when (not= sigs '())
(print (str/replace (str (lazy-seq (first sigs)) " ") "(" (str "(" func-name " ")))
(recur (rest sigs)))))
(let [data (meta (eval (read-string (str name function)))) func-name (if (and (not= (str/index-of function "/") nil) (not= (str function) "/")) (str function) (str name function))]
(print (str "\n " func-name "\n\n\t"))
(loop [sigs (lazy-seq (:signatures data))]
(when (not= sigs '())
(print (str/replace (str (lazy-seq (first sigs)) " ") "(" (str "(" func-name " ")))
(recur (rest sigs))))

(if (nil? data)
(do
Expand All @@ -67,17 +66,32 @@



(defcmd doc
(defcmd ^:no-project doc
"Show function documentation. Broaden search using -all"
[function-name & search-all]
(if (= (str (first search-all)) "-all") (reset! show-all true))
(loop [_ 0]
(when (not= @namespaces '())
(try (showdoc (str (first @namespaces)) (str function-name))
(catch e
nil))
(recur (reset! namespaces (rest @namespaces)))))
(if (= @unknown-command true) (println (str "\n " function-name "\n\n\t Function not found. " (if (not= (str (first search-all)) "-all") (str "Broaden search using -all flag.\n") (str "\n"))))))
[ & args]
(if (empty? args)
(help-cmd "doc")
(let [function-name (first args) search-all (first (rest args))]
(if (and (not= (str/index-of (str function-name) "/") nil) (not= (str function-name) "/") )
;test for division operator as function to be documented
(do
(try
(eval (read-string (str "(require " (str/substring function-name 0 (str/index-of function-name "/")) ")")))
;load the required namespaces

(showdoc (str (first @namespaces)) (str function-name))
(catch e
(reset! unknown-command true)))
(reset! namespaces '())))
(if (= (str search-all) "-all") (reset! show-all true))
(loop [_ 0]
(when (not= @namespaces '())
(try (showdoc (str (first @namespaces)) (if (= function-name "deps") (str "*") (str function-name)))
; $ dust doc * -> dust doc deps ???
(catch e
nil))
(recur (reset! namespaces (rest @namespaces)))))
(if (= @unknown-command true) (println (str "\n " function-name "\n\n\t Function not found. " (if (not= (str search-all) "-all") (str "Broaden search using -all flag.\n") (str "\n"))))))))

(defcmd deps
"List the dependencies and their versions of the current project."
Expand Down