Mercurial Hosting > luan
diff website/src/manual.html.luan @ 1813:fa0e73119b7c
docs work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 10 Jun 2024 23:19:40 -0600 |
parents | f44dcb3fedf7 |
children | e62c88b2883b |
line wrap: on
line diff
--- a/website/src/manual.html.luan Mon Jun 10 14:41:48 2024 -0600 +++ b/website/src/manual.html.luan Mon Jun 10 23:19:40 2024 -0600 @@ -1984,6 +1984,31 @@ <% end subs = { + ["Luan.arg"] = { + title = "Luan.arg" + content = function() +%> +<p>If Luan was run from the command line then this is a list of the command line arguments. For example if one runs Luan like this:</p> + +<code block> +luan t.luan a b c +</code> + +<p>Then Luan.arg will contain:</p> + +<code block> +{ + [0] = "t.luan" + [1] = "a" + [2] = "b" + [3] = "c" +} +</code> + +<p>And of course <code>#Luan.arg</code> will be <code>3</code>.</p> +<% + end + } ["Luan.do_file"] = { title = "Luan.do_file ([uri])" content = function() @@ -2180,6 +2205,38 @@ <% end } + ["Luan.parse"] = { + title = "Luan.parse (s)" + content = function() +%> +<p>This Luan's equivalent to Javascript's JSON.parse(), but for a Luan value. In addition to the usual JSON values, Luan.parse allows long strings and allows specifying numeric types of <i>double</i>, <i>float</i>, <i>integer</i>, and <i>long</i>. For example:</p> + +<code block> +local t = Luan.parse[=[ +{ + nothing = nil + t = true + f = false + s = "string" + ls = [[long string]] + n = 3 + d = double(3) + f = float(3) + i = integer(3) + l = long(3) + list = { 1, 2, 3 } + table = { + one = 1 + two = 2 + three = 3 + } + ["ugly-key"] = "something" +} +]=] +</code> +<% + end + } ["Luan.range"] = { title = "Luan.range (start, stop [, step])" content = function() @@ -2291,8 +2348,19 @@ content = function() %> <p> -Receives a value of any type and converts it to a string that is a Luan expression. <code>options</code> is a table. If <code>options.strict==true</code> then invalid types throw an error. Otherwise invalid types are represented but the resulting expression is invalid. If <code>options.number_types==true</code> then numbers will be wrapped in functions for their type. -</p> +This Luan's equivalent to Javascript's JSON.stringify(), but for a Luan value. +<code>v</code> is a value of any type which is converted to a string that is a Luan expression. <code>options</code> may be a table or a function. If <code>options</code> is a table, it may contain the following flags whose <code>true</code> value means: +</p> + +<ul> +<li><b>strict</b> - invalid types throw an error</li> +<li><b>number_types</b> - numbers will be wrapped in functions for their type</li> +<li><b>compressed</b> - eliminates white space</li> +<li><b>inline</b> - on one line</li> +<li><b>no_name_keys</b> - forces all keys to be of the form <code>["key"]</code></li> +</ul> + +<p>If <code>options</code> is a function then this function should take an argument <code>stack</code> and return an <code>options</code> table. The <code>stack</code> will be a list of keys indicating where stringify is currently processing. This allows different options to be applied at different places in a data structure.</p> <% end }