From e5a2df93abada7595059e11907f5f3ccd8b79fff Mon Sep 17 00:00:00 2001 From: sogaiu <983021772@users.noreply.github.com> Date: Thu, 6 May 2021 21:21:23 +0900 Subject: [PATCH] Make doc work for special forms --- src/boot/boot.janet | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/boot/boot.janet b/src/boot/boot.janet index 845fafc6..feb577ad 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -2891,6 +2891,13 @@ (if d (doc-format d) " no documentation found.") "\n\n")) +(defn- print-special-form-entry + [x] + (print "\n\n" + (string " special form\n\n") + (string " (" x " ...)\n\n") + (string " See https://janet-lang.org/docs/specials.html\n\n"))) + (defn doc* "Get the documentation for a symbol in a given environment. Function form of doc." [&opt sym] @@ -2903,14 +2910,17 @@ (do (def x (dyn sym)) (if (not x) - (do - (def [fullpath mod-kind] (module/find (string sym))) - (if-let [mod-env (in module/cache fullpath)] - (print-module-entry {:module true - :kind mod-kind - :source-map [fullpath nil nil] - :doc (in mod-env :doc)}) - (print "symbol " sym " not found."))) + (if (index-of sym '[break def do fn if quasiquote quote + set splice unquote upscope var while]) + (print-special-form-entry sym) + (do + (def [fullpath mod-kind] (module/find (string sym))) + (if-let [mod-env (in module/cache fullpath)] + (print-module-entry {:module true + :kind mod-kind + :source-map [fullpath nil nil] + :doc (in mod-env :doc)}) + (print "symbol " sym " not found.")))) (print-module-entry x))) # else