all repos — min @ aaf8faf94be598853620113b86935f24364be419

A small but practical concatenative programming language.

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
"tasks/data/doc-snippets.json" fread from-json :snippets
"site/contents" ls ("reference-" match) filter =src-files
"\{\#op\|\|([^|]+)\|\|([^|]+)\|\|([^|]+)\|\|([^#])+\#\}" :op-regex
"\{\\{([^}]+)\}\}" :snippet-regex
">( >)*" :block-regex
"%([^%]+)%" :title-regex
"\{@[^@]+@\}" :incl-regex
"`([^`]+)`" :code-regex

(
    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 %name
            matches 2 get process %input
            matches 3 get process %output
            matches 4 get process %description
        @data
    )   
) ::
;; Processes operator reference documentation.

(
    symbol default
    (==>)
    ( 
        {} :ref-dict
        src-files (
            :file 
            file "reference-([a-z]+)\.md" search 1 get :mod-id
            "Generating: $#" (mod-id) =% notice!
            {} :mod-dict
            file fread op-regex search-all (
                process-op :op
                op /name :op-name
                mod-dict 
                  op op-name dset
                @mod-dict
            ) foreach
            ref-dict
              mod-dict mod-id dset
            @ref-dict
        ) foreach
        "Writing help.json" notice!
        ref-dict to-json "help.json" fwrite
    )
) ::
;; Builds the reference help JSON sources.