1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-29 14:47:42 +00:00

Add docs target to generate documentation.

This commit is contained in:
Calvin Rose
2018-12-17 01:41:11 -05:00
parent 05a957c524
commit 131ee29190
5 changed files with 61 additions and 33 deletions

View File

@@ -1074,8 +1074,18 @@ value, one key will be ignored."
(if (not x)
(print "symbol " sym " not found.")
(do
(def bind-type
(string " "
(cond
x:ref (string :var " (" (type (get x:ref 0)) ")")
x:macro :macro
(type x:value))
"\n"))
(def d x:doc)
(print "\n\n" (if d (doc-format d) "no documentation found.") "\n\n"))))
(print "\n\n"
(if d bind-type "")
(if d (doc-format d) "no documentation found.")
"\n\n"))))
(defmacro doc
"Shows documentation for the given symbol."
@@ -1176,15 +1186,15 @@ value, one key will be ignored."
ret)
(defn all
[pred xs]
"Returns true if all xs are truthy, otherwise the first false or nil value."
[pred xs]
(var ret true)
(loop [x :in xs :while ret] (set ret (pred x)))
ret)
(defn some
[pred xs]
"Returns false if all xs are false or nil, otherwise returns the first true value."
[pred xs]
(var ret nil)
(loop [x :in xs :while (not ret)] (if-let [y (pred x)] (set ret y)))
ret)

View File

@@ -47,7 +47,7 @@ struct IOFile {
static int janet_io_gc(void *p, size_t len);
JanetAbstractType janet_io_filetype = {
":core.file",
":core/file",
janet_io_gc,
NULL
};

View File

@@ -609,7 +609,7 @@ static int parsergc(void *p, size_t size) {
}
static JanetAbstractType janet_parse_parsertype = {
":core.parser",
":core/parser",
parsergc,
parsermark
};