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 |
"tasks/data/doc-snippets.json" fread from-json :snippets "site/contents" ls ("reference-" match) filter =src-files "\{\#op\|\|([^|]+)\|\|([^|]+)\|\|([^|]+)\|\|([^#])+\#\}" :op-regex "\{\#sig\|\|([^|]+)\|\|([^#]+)\#\}" :sig-regex "\{\#alias\|\|([^|]+)\|\|([^#]+)\#\}" :alias-regex "\{\{([^}]+)\}\}" :snippet-regex ">( >)*" :block-regex "%([^%]+)%" :title-regex "\{@[^@]+@\}" :incl-regex "`([^`]+)`" :code-regex ( symbol fix-name (string :s ==> string :result) ( s "!" (pop "!") replace-apply ">" (pop ">") replace-apply "<" (pop "<") replace-apply "'" (pop "'") replace-apply "*" (pop "*") replace-apply @result ) ) :: ;; Fixes names with special characters ( symbol process-block-markup (string :s ==> string :result) ( s block-regex (pop "") replace-apply title-regex (pop "") replace-apply incl-regex (pop "") replace-apply code-regex (1 get) replace-apply @result ) ) :: ;; Simplify block-level markup ( symbol process-snippets (string :s ==> string :result) ( s snippet-regex ( 1 get :id snippets id dget ) replace-apply @result ) ) :: ;; Resolves documentation snippets. ( symbol process (string :s ==> string :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 matches 2 get process :input matches 3 get process :output "$# ==> $#" (input output) =% %signature matches 4 get process %description "symbol" %kind @data ) ) :: ;; Processes operator reference documentation. ( symbol process-alias (quot :matches ==> dict :data) ( {} matches 1 get process fix-name %name matches 2 get :ref "See $#" (ref) =% %description "symbol" %kind @data ) ) :: ;; Processes alias reference documentation. ( symbol process-sig (quot :matches ==> dict :data) ( {} matches 1 get process fix-name %name matches 2 get :ref "See $#" (ref) =% %description "sigil" %kind @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) =% notice! file fread :contents contents op-regex search-all ( process-op :op op /name :op-name op-dict op op-name dset @op-dict ) foreach contents alias-regex search-all ( process-alias :alias alias /name :alias-name op-dict alias alias-name dset @op-dict ) foreach contents sig-regex search-all ( process-alias :sig sig /name :sig-name sig-dict sig sig-name dset @sig-dict ) foreach ref-dict op-dict %operators sig-dict %sigils @ref-dict ) foreach "Writing help.json" notice! ref-dict to-json "help.json" fwrite ) ) :: ;; Builds the reference help JSON sources. |