[#802] Support resolving docstring from function
This commit is contained in:
parent
bd08635793
commit
12cb5d637c
3 changed files with 14 additions and 6 deletions
|
|
@ -235,7 +235,7 @@
|
|||
(println "No such task:" task-name)) 1])))
|
||||
|
||||
(defn list-tasks
|
||||
[]
|
||||
[sci-ctx]
|
||||
(let [tasks (:tasks @bb-edn)]
|
||||
(if (seq tasks)
|
||||
(let [names (keys tasks)
|
||||
|
|
@ -251,7 +251,11 @@
|
|||
(doseq [k names
|
||||
:let [task (get tasks (symbol k))]]
|
||||
(let [task (if (qualified-symbol? task)
|
||||
{:doc (format "Runs %s. See `bb doc %s` for more info." task task)}
|
||||
{:doc (sci/eval-string*
|
||||
sci-ctx
|
||||
(format "
|
||||
(try (require '%s) (catch Exception _ nil))
|
||||
(:doc (meta (resolve '%s)))" (namespace task) task))}
|
||||
task)]
|
||||
(println (str (format fmt k)
|
||||
(when-let [d (:doc task)]
|
||||
|
|
|
|||
|
|
@ -735,7 +735,7 @@ When no eval opts or subcommand is provided, the implicit subcommand is repl.")
|
|||
repl [(repl/start-repl! sci-ctx) 0]
|
||||
nrepl [(start-nrepl! nrepl sci-ctx) 0]
|
||||
uberjar [nil 0]
|
||||
list-tasks [(tasks/list-tasks) 0]
|
||||
list-tasks [(tasks/list-tasks sci-ctx) 0]
|
||||
expressions
|
||||
(sci/binding [sci/file abs-path]
|
||||
(try
|
||||
|
|
|
|||
|
|
@ -96,7 +96,8 @@
|
|||
(test-utils/with-config {}
|
||||
(let [res (test-utils/bb nil "tasks")]
|
||||
(is (str/includes? res "No tasks found."))))
|
||||
(test-utils/with-config {:tasks {'task1
|
||||
(test-utils/with-config {:paths ["test-resources/task_scripts"]
|
||||
:tasks {'task1
|
||||
{:doc "task1 doc"
|
||||
:task '(+ 1 2 3)}
|
||||
'task2
|
||||
|
|
@ -106,9 +107,12 @@
|
|||
{:task '(+ 1 2 3)}
|
||||
'task4
|
||||
{:task '(+ 1 2 3)
|
||||
:private true}}}
|
||||
:private true}
|
||||
'foo 'tasks/foo
|
||||
'bar 'non-existing/bar}}
|
||||
(let [res (test-utils/bb nil "tasks")]
|
||||
(is (= "The following tasks are available:\n\ntask1 task1 doc\ntask2 task2 doc\n" res)))))
|
||||
(is (= "The following tasks are available:\n\nbar \nfoo Foo docstring\ntask1 task1 doc\ntask2 task2 doc\n"
|
||||
res)))))
|
||||
|
||||
(deftest task-priority-test
|
||||
(when-not test-utils/native?
|
||||
|
|
|
|||
Loading…
Reference in a new issue