aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/macro/template.lux
blob: 00be1845ad02b63df1f775e30aa3074a364b621f (plain)
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
(.module:
  [library
   [lux {"-" [let]}
    ["$" documentation {"+" [documentation:]}]
    [data
     [text {"+" [\n]}
      ["%" format {"+" [format]}]]
     [collection
      ["." list]]]]]
  [\\library
   ["." /]])

(documentation: /.spliced
  ""
  [(spliced [a b c d])
   "=>"
   a
   b
   c
   d])

(documentation: /.amount
  ""
  [(amount [a b c d])
   "=>"
   4])

(documentation: /.with_locals
  "Creates names for local bindings aliased by the names you choose."
  [(with_locals [my_var]
     (let [my_var 123]
       (text [my_var])))
   "=>"
   "__gensym__my_var506"])

(documentation: /.text
  "A text literal made by concatenating pieces of code."
  [(text [#0 123 +456 +789.0 "abc" .def ..ghi])
   "=>"
   "#0123+456+789.0abcdefghi"])

(documentation: /.identifier
  (format "An identifier made by concatenating pieces of code."
          \n "The (optional) module part and the short part are specified independently.")
  [(identifier ["abc" .def ..ghi])
   "=>"
   abcdefghi]
  [(identifier [.def] ["abc" .def ..ghi])
   "=>"
   .abcdefghi])

(documentation: /.let
  "Lexically-bound templates."
  [(let [(!square <root>)
         [(* <root> <root>)]]
     (def: (square root)
       (-> Nat Nat)
       (!square root)))])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            "Utilities commonly used while templating."
            [..spliced
             ..amount
             ..with_locals
             ..text
             ..identifier
             ..let
             ($.default /.irregular_arguments)]
            []))