From ed7fe3485390c4e8f8ece45f488be24c1fb61840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Reuh=20Fildadut?= Date: Sat, 9 Nov 2024 17:03:39 +0100 Subject: [PATCH] [doc] update doc --- anselme/state/State.lua | 2 +- anselme/stdlib/conditionals.lua | 8 ++++---- doc/api.md | 3 ++- doc/language.md | 8 ++++---- doc/standard_library.md | 10 +++++----- doc/tutorial.md | 6 +++--- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/anselme/state/State.lua b/anselme/state/State.lua index 44e44eb..f3c4d35 100644 --- a/anselme/state/State.lua +++ b/anselme/state/State.lua @@ -118,7 +118,7 @@ State = class { self.scope:define_lua(name, value, func, raw_mode) end, --- Returns true if `name` (string) is defined in the global scope. - --- Returns false otherwise. + -- Returns false otherwise. defined = function(self, name) self.scope:push_global() local r = self:defined_local(name) diff --git a/anselme/stdlib/conditionals.lua b/anselme/stdlib/conditionals.lua index 315e895..6284c8e 100644 --- a/anselme/stdlib/conditionals.lua +++ b/anselme/stdlib/conditionals.lua @@ -109,7 +109,7 @@ return { -- -- ``` -- :i = 1 - -- while(i <= 5) + -- while($i <= 5) -- print(i) -- i += 1 -- // 1, 2, 3, 4, 5 @@ -117,7 +117,7 @@ return { -- -- ``` -- :i = 1 - -- while(i <= 5) + -- while($i <= 5) -- if(i == 3, break) -- print(i) -- i += 1 @@ -126,7 +126,7 @@ return { -- -- ``` -- :i = 1 - -- while(i <= 5) + -- while($i <= 5) -- if(i == 3, continue) -- print(i) -- i += 1 @@ -135,7 +135,7 @@ return { -- -- ``` -- :i = 10 - -- while(i <= 5) + -- while($i <= 5) -- print(i) -- i += 1 -- else! diff --git a/doc/api.md b/doc/api.md index b68f0b5..bde4601 100644 --- a/doc/api.md +++ b/doc/api.md @@ -199,6 +199,7 @@ _defined at line 117 of [anselme/state/State.lua](../anselme/state/State.lua):_ ### :defined (name) +Returns true if `name` (string) is defined in the global scope. Returns false otherwise. _defined at line 122 of [anselme/state/State.lua](../anselme/state/State.lua):_ `defined = function(self, name)` @@ -311,4 +312,4 @@ Otherwise, each Node has its own module file defined in the [ast/](../ast) direc --- -_file generated at 2024-06-04T14:22:53Z_ \ No newline at end of file +_file generated at 2024-11-09T17:00:43Z_ \ No newline at end of file diff --git a/doc/language.md b/doc/language.md index e0faef5..c534bc9 100644 --- a/doc/language.md +++ b/doc/language.md @@ -326,7 +326,7 @@ comment Variables can be defined and assigned using the `_=_` operator. -To define a variable, the left expression must be a [symbol](#symbol), for an assignment, an identifier. The left expression can also be a tuple for multiple assignments. +To define a variable, the left expression must be a [symbol](#symbols), for an assignment, an identifier. The left expression can also be a tuple for multiple assignments. ``` :x = 3 // definition @@ -355,11 +355,11 @@ constant symbol = 13 // value checking error! #### Exported variables -If the symbol has an export flag, the variable will be defined in the [export scope](#export-scope) instead of the current scope, i.e. will be defined for the whole file and be made accessible from outside files. See [export scope](#export-scope) for details. +If the symbol has an `@` export flag, the variable will be defined in the [export scope](#export-scope) instead of the current scope, i.e. will be defined for the whole file and be made accessible from outside files. See [export scope](#export-scope) for details. #### Alias variables -If the symbol has an alias flag, the variable will be an alias. Instead of directly accessing the value of the variable, the variable will: +If the symbol has an `&` alias flag, the variable will be an alias. Instead of directly accessing the value of the variable, the variable will: * when get, call its value with no argument and returns the result; * whet set, call its value with an assignment argument and returns the result. @@ -752,7 +752,7 @@ $1, $2 // same as ($1), ($2) as _,_ has a precedence of 2 A variable can be defined and assigned a new function quickly using the function definition syntax. -The function definition syntax consist of a modified [symbol literal](#symbol) with a `$` right before the symbol name, followed by either a parameter list and expression or the function expression directly, in the same way as the [`$_` operator](#functions) described above. +The function definition syntax consist of a modified [symbol literal](#symbols) with a `$` right before the symbol name, followed by either a parameter list and expression or the function expression directly, in the same way as the [`$_` operator](#functions) described above. When evaluated, the function definition will create a new function and define a new variable set to this function. diff --git a/doc/standard_library.md b/doc/standard_library.md index 8e3f778..114091b 100644 --- a/doc/standard_library.md +++ b/doc/standard_library.md @@ -296,7 +296,7 @@ If a `break` happens in the loop, the whole loop is stopped. ``` :i = 1 -while(i <= 5) +while($i <= 5) print(i) i += 1 // 1, 2, 3, 4, 5 @@ -304,7 +304,7 @@ while(i <= 5) ``` :i = 1 -while(i <= 5) +while($i <= 5) if(i == 3, break) print(i) i += 1 @@ -313,7 +313,7 @@ while(i <= 5) ``` :i = 1 -while(i <= 5) +while($i <= 5) if(i == 3, continue) print(i) i += 1 @@ -322,7 +322,7 @@ while(i <= 5) ``` :i = 10 -while(i <= 5) +while($i <= 5) print(i) i += 1 else! @@ -1336,4 +1336,4 @@ _defined at line 14 of [anselme/stdlib/wrap.lua](../anselme/stdlib/wrap.lua):_ ` --- -_file generated at 2024-06-04T14:22:53Z_ \ No newline at end of file +_file generated at 2024-11-09T16:02:36Z_ \ No newline at end of file diff --git a/doc/tutorial.md b/doc/tutorial.md index ef8e954..fd8c87b 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -225,7 +225,7 @@ else! ``` :i = 0 -while(i < 5) +while($i < 5) i += 1 if(i == 4) break! @@ -240,7 +240,7 @@ for(:x, range(10)) # Persistence -_For more detailled information on this, look at [persistence](standard_library.md#persistence-helpers), [alias variables](#api.md#alias-variables)._ +_For more detailled information on this, look at [persistence](standard_library.md#persistence-helpers), [alias variables](language.md#alias-variables)._ Variables that needs to be saved and loaded alongside the game's save files can be stored in persistent storage. @@ -333,4 +333,4 @@ Text and any value preceded by a `%` prefix will be replaced with its translatio %"red" // "rouge" ``` -An Anselme script containing a ready-to-translate list of all translatables elements of a file can be obtained using the [translation template generator Lua API methods](#api.md#generate-translation-template). The template can then be loaded as a regular Anselme file for all the translations to be applied. +An Anselme script containing a ready-to-translate list of all translatables elements of a file can be obtained using the [translation template generator Lua API methods](api.md#generate-translation-template). The template can then be loaded as a regular Anselme file for all the translations to be applied.