From 6022895fa85e84ce43a668df6034367c1d279caa Mon Sep 17 00:00:00 2001 From: Scott Richmond Date: Sat, 15 Jun 2024 21:52:19 -0400 Subject: [PATCH] improve formatting and add new functions to topics --- src/doc.janet | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/doc.janet b/src/doc.janet index e73836c..a1b3329 100644 --- a/src/doc.janet +++ b/src/doc.janet @@ -22,14 +22,15 @@ (string/join (map toc-entry sorted-names) "    ")) (def topics { - "math" ["abs" "add" "angle" "atan/2" "between?" "ceil" "cos" "dec" "deg/rad" "deg/turn" "dist" "div" "div/0" "div/safe" "even?" "floor" "gt?" "gte?" "heading/vector" "inc" "inv" "inv/0" "inv/safe" "lt?" "lte?" "max" "min" "mod" "mult" "neg" "neg?" "odd?" "pi" "pos?" "rad/deg" "rad/turn" "random" "random_int" "range" "round" "sin" "square" "sub" "sum_of_squares" "tan" "tau" "turn/deg" "turn/rad" "zero?"] - "boolean" ["and" "bool" "bool?" "false?" "not" "or"] + "math" ["abs" "add" "angle" "atan/2" "between?" "ceil" "cos" "dec" "deg/rad" "deg/turn" "dist" "div" "div/0" "div/safe" "even?" "floor" "gt?" "gte?" "heading/vector" "inc" "inv" "inv/0" "inv/safe" "lt?" "lte?" "max" "min" "mod" "mod/0" "mod/safe" "mult" "neg" "neg?" "odd?" "pi" "pos?" "rad/deg" "rad/turn" "random" "random_int" "range" "round" "sin" "sqrt" "sqrt/safe" "square" "sub" "sum_of_squares" "tan" "tau" "turn/deg" "turn/rad" "zero?"] + "boolean" ["and" "bool" "bool?" "false?" "not" "or" "true?"] "dicts" ["any?" "assoc" "assoc?" "coll?" "count" "dict" "dict?" "diff" "dissoc" "empty?" "get" "keys" "random" "update" "values"] - "lists" ["any?" "append" "at" "butlast" "coll?" "concat" "count" "each!" "empty?" "filter" "first" "fold" "join" "keep" "last" "list" "list?" "map" "ordered?""random" "range" "rest" "second" "sentence" "slice"] - "sets" ["any?" "append" "coll?" "concat" "count" "empty?" "random" "set" "set?"] + "lists" ["any?" "append" "at" "butlast" "coll?" "concat" "count" "each!" "empty?" "filter" "first" "fold" "join" "keep" "last" "list" "list?" "map" "ordered?" "random" "range" "rest" "second" "sentence" "slice"] + "sets" ["any?" "append" "coll?" "concat" "contains?" "count" "empty?" "omit" "random" "set" "set?"] + "tuples" ["any?" "at" "coll?" "count" "empty?" "first" "ordered?" "second" "tuple?"] "strings" ["any?" "concat" "count" "downcase" "empty?" "join" "sentence" "show" "slice" "split" "string" "string?" "strip" "trim" "upcase" "words"] - "types and values" ["assoc?" "bool?" "coll?" "dict?" "eq?" "fn?" "keyword?" "list?" "neq?" "nil?" "number?" "ordered?" "show" "some" "some?" "string?" "type"] - "boxes and state" ["unbox" "store!" "update!"] + "types and values" ["assoc?" "bool?" "box?" "coll?" "dict?" "eq?" "fn?" "keyword?" "list?" "neq?" "nil?" "number?" "ordered?" "set?" "show" "some" "some?" "string?" "tuple?" "type"] + "boxes and state" ["box?" "unbox" "store!" "update!"] "results" ["err" "err?" "ok" "ok?" "unwrap!" "unwrap_or"] "errors" ["assert!"] "turtle graphics" ["back!" "background!" "bk!" "clear!" "colors" "fd!" "forward!" "goto!" "heading" "heading/vector" "home!" "left!" "lt!" "pc!" "pd!" "pencolor" "pencolor!" "pendown!" "pendown?" "penup!" "penwidth" "penwidth!" "position" "pu!" "pw!" "render_turtle!" "reset_turtle!" "right!" "rt!" "turtle_state"] @@ -54,18 +55,19 @@ (string/join topics-entries "\n"))) (defn compose-entry [name] - (def header (string "### " name "\n")) + (def header (string "\n### " name "\n")) (def the-doc (get with-docs name)) (when (= "No documentation available." the-doc) (break (string header the-doc "\n"))) (def lines (string/split "\n" the-doc)) (def description (last lines)) (def patterns (string/join (slice lines 1 (-> lines length dec)) "\n")) - (string header description "\n```\n" patterns "\n```\n")) + (def backto "[Back to top.](#ludus-prelude-documentation)\n") + (string header description "\n```\n" patterns "\n```\n" backto)) (compose-entry "update") -(def entries (string/join (map compose-entry sorted-names) "\n\n")) +(def entries (string/join (map compose-entry sorted-names) "\n---")) (def doc-file (string ```