aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/macro/template.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/documentation/lux/macro/template.lux77
1 files changed, 77 insertions, 0 deletions
diff --git a/stdlib/source/documentation/lux/macro/template.lux b/stdlib/source/documentation/lux/macro/template.lux
new file mode 100644
index 000000000..894d68c3d
--- /dev/null
+++ b/stdlib/source/documentation/lux/macro/template.lux
@@ -0,0 +1,77 @@
+(.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"])
+
+(template [<a/an> <name> <short_example> <full_example>]
+ [(documentation: <name>
+ (format <a/an> " " (/.text [<name>]) " made by concatenating pieces of code."
+ \n "The (optional) module part and the short part are specified independently.")
+ [(<name> ["abc" .def ..ghi])
+ "=>"
+ <short_example>]
+ [(<name> [.def] ["abc" .def ..ghi])
+ "=>"
+ <full_example>])]
+
+ ["An" /.identifier abcdefghi .abcdefghi]
+ ["A" /.tag #abcdefghi #.abcdefghi]
+ )
+
+(documentation: /.let
+ "Lexically-bound templates."
+ [(let [(!square <root>)
+ [(* <root> <root>)]]
+ (def: (square root)
+ (-> Nat Nat)
+ (!square root)))])
+
+(.def: .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [..spliced
+ ..amount
+ ..with_locals
+ ..text
+ ..identifier
+ ..tag
+ ..let
+ ($.default /.irregular_arguments)]
+ []))