aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/macro/template.lux
blob: 0a0191099eab16b0b67b44babfd98b2089ec7ad5 (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
(.using
 [library
  [lux (.except let symbol)
   ["$" documentation (.only documentation:)]
   [data
    [text (.only \n)
     ["%" \\format (.only format)]]
    [collection
     ["[0]" list]]]]]
 [\\library
  ["[0]" /]])

(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: /.symbol
  (format "An symbol made by concatenating pieces of code."
          \n "The (optional) module part and the short part are specified independently.")
  [(symbol ["abc" .def ..ghi])
   "=>"
   abcdefghi]
  [(symbol [.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
             ..symbol
             ..let
             ($.default /.irregular_arguments)]
            []))