tasks/help.min
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
"tasks/data/doc-snippets.json" fs.read from-json :snippets
"site/contents" sys.ls ("reference-" match?) filter :src-files
"(?sm)\\{#op\\|\\|([^|]+)\\|\\|([^|]+)\\|\\|([^|]+)\\|\\|(.+?)#\\}" :op-regex
"(?sm)\\{#sig\\|\\|([^|]+)\\|\\|([^#]+)#\\}" :sig-regex
"(?sm)\\{#alias\\|\\|([^|]+)\\|\\|([^#]+)#\\}" :alias-regex
"(?sm)\\{\\{([^}]+)\\}\\}" :snippet-regex
"(?sm)\\>( \\>)*" :block-regex
"(?sm)%([^%]+)%" :title-regex
"(?sm)\\{@[^@]+@\\}" :incl-regex
"(?sm)`([^`]+)`" :code-regex
(
symbol fix-name
(str :s ==> str :result)
(
s
"!" (stack.pop "!") replace-apply
""" (stack.pop "\"") replace-apply
"|" (stack.pop "|") replace-apply
"\\[" (stack.pop "") replace-apply
"\\]" (stack.pop "") replace-apply
"\\(class:kwd\\)" (stack.pop "") replace-apply
">" (stack.pop ">") replace-apply
"<" (stack.pop "<") replace-apply
"'" (stack.pop "'") replace-apply
"*" (stack.pop "*") replace-apply
@result
)
) ::
;; Fixes names with special characters
(
symbol process-block-markup
(str :s ==> str :result)
(
s
block-regex (stack.pop "") replace-apply
title-regex (stack.pop "") replace-apply
incl-regex (stack.pop "") replace-apply
code-regex (1 get) replace-apply
@result
)
) ::
;; Simplify block-level markup
(
symbol process-snippets
(str :s ==> str :result)
(
s snippet-regex (
1 get :id
snippets id dict.get
) replace-apply @result
)
) ::
;; Resolves documentation snippets.
(
symbol process
(str :s ==> str :result)
(
s process-snippets process-block-markup strip @result
)
) ::
;; Processes documentation snippets and markup.
(
symbol process-op
(quot :matches ==> dict :data)
(
{}
matches 1 get process fix-name "name" dict.set
matches 2 get process fix-name :input
matches 3 get process fix-name :output
"$# ==> $#" (input output) =% "signature" dict.set
matches 4 get process "description" dict.set
"symbol" "kind" dict.set
@data
)
) ::
;; Processes operator reference documentation.
(
symbol process-alias
(quot :matches ==> dict :data)
(
{}
matches 1 get process fix-name "name" dict.set
matches 2 get :ref
"See $#" (ref) =% "description" dict.set
"symbol" "kind" dict.set
@data
)
) ::
;; Processes alias reference documentation.
(
symbol process-sig
(quot :matches ==> dict :data)
(
{}
matches 1 get process fix-name "name" dict.set
matches 2 get :ref
"See $#" (ref) =% "description" dict.set
"sigil" "kind" dict.set
@data
)
) ::
;; Processes sigil reference documentation.
(
symbol default
(==>)
(
{} :ref-dict
{} :op-dict
{} :sig-dict
src-files (
:file
file "reference-([a-z]+)\\.md" search 1 get :mod-id
"Processing: $#" (mod-id) =% io.notice!
file fs.read :contents
contents op-regex search-all (
process-op :op
op "name" dict.get :op-name
op mod-id 'module dict.set @op
(mod-id "global" ==)
; Use namespaced names unless global
("$#.$#" (mod-id op-name) =% @op-name)
unless
op-dict
op op-name dict.set
@op-dict
) foreach
contents alias-regex search-all (
process-alias :alias
alias "name" dict.get :alias-name
alias mod-id 'module dict.set @alias
op-dict
alias alias-name dict.set
@op-dict
) foreach
contents sig-regex search-all (
process-sig :sig
sig "name" dict.get :sig-name
sig mod-id 'module dict.set @sig
sig-dict
sig sig-name dict.set
@sig-dict
) foreach
ref-dict
op-dict "symbols" dict.set
sig-dict "sigils" dict.set
@ref-dict
) foreach
"Writing help.json" io.notice!
ref-dict to-json "help.json" fs.write
)
) ::
;; Builds the reference help JSON sources.
|