aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllie <13716824+ChildishGiant@users.noreply.github.com>2022-04-12 06:33:02 +0100
committerGitHub <noreply@github.com>2022-04-12 13:33:02 +0800
commite6567c0d290fc76a5919dae4c57d3550eb2541b8 (patch)
treece933871fb8d23a6aab92b217b66640374ae5bc6
parent911204c19378ef943c8daec5205fd60caa523321 (diff)
downloadyuescript-e6567c0d290fc76a5919dae4c57d3550eb2541b8.tar.gz
yuescript-e6567c0d290fc76a5919dae4c57d3550eb2541b8.tar.bz2
yuescript-e6567c0d290fc76a5919dae4c57d3550eb2541b8.zip
Add docs for += -= and []= (#90)
* add OpenGraph data * add docs for syntactic sugar
-rwxr-xr-xdoc/docs/doc/README.md61
1 files changed, 46 insertions, 15 deletions
diff --git a/doc/docs/doc/README.md b/doc/docs/doc/README.md
index be83be3..fcd7bba 100755
--- a/doc/docs/doc/README.md
+++ b/doc/docs/doc/README.md
@@ -118,14 +118,14 @@ export yuescript = "ζœˆδΉ‹θ„šζœ¬"
118 118
119&emsp;Use Yuescript module in Lua: 119&emsp;Use Yuescript module in Lua:
120 120
121* **Case 1** 121* **Case 1**
122Require "your_yuescript_entry.yue" in Lua. 122Require "your_yuescript_entry.yue" in Lua.
123```Lua 123```Lua
124require("yue")("your_yuescript_entry") 124require("yue")("your_yuescript_entry")
125``` 125```
126&emsp;And this code still works when you compile "your_yuescript_entry.yue" to "your_yuescript_entry.lua" in the same path. In the rest Yuescript files just use the normal **require** or **import**. The code line numbers in error messages will also be handled correctly. 126&emsp;And this code still works when you compile "your_yuescript_entry.yue" to "your_yuescript_entry.lua" in the same path. In the rest Yuescript files just use the normal **require** or **import**. The code line numbers in error messages will also be handled correctly.
127 127
128* **Case 2** 128* **Case 2**
129Require Yuescript module and rewite message by hand. 129Require Yuescript module and rewite message by hand.
130```lua 130```lua
131local yue = require("yue") 131local yue = require("yue")
@@ -136,7 +136,7 @@ end, function(err)
136end) 136end)
137``` 137```
138 138
139* **Case 3** 139* **Case 3**
140Use the Yuescript compiler function in Lua. 140Use the Yuescript compiler function in Lua.
141```lua 141```lua
142local yue = require("yue") 142local yue = require("yue")
@@ -174,12 +174,12 @@ Usage: yue [options|files|directories] ...
174 Execute without options to enter REPL, type symbol '$' 174 Execute without options to enter REPL, type symbol '$'
175 in a single line to start/stop multi-line mode 175 in a single line to start/stop multi-line mode
176``` 176```
177&emsp;&emsp;Use cases: 177&emsp;&emsp;Use cases:
178&emsp;&emsp;Recursively compile every Yuescript file with extension **.yue** under current path: **yue .** 178&emsp;&emsp;Recursively compile every Yuescript file with extension **.yue** under current path: **yue .**
179&emsp;&emsp;Compile and save results to a target path: **yue -t /target/path/ .** 179&emsp;&emsp;Compile and save results to a target path: **yue -t /target/path/ .**
180&emsp;&emsp;Compile and reserve debug info: **yue -l .** 180&emsp;&emsp;Compile and reserve debug info: **yue -l .**
181&emsp;&emsp;Compile and generate minified codes: **yue -m .** 181&emsp;&emsp;Compile and generate minified codes: **yue -m .**
182&emsp;&emsp;Execute raw codes: **yue -e 'print 123'** 182&emsp;&emsp;Execute raw codes: **yue -e 'print 123'**
183&emsp;&emsp;Execute a Yuescript file: **yue -e main.yue** 183&emsp;&emsp;Execute a Yuescript file: **yue -e main.yue**
184 184
185## Macro 185## Macro
@@ -360,11 +360,42 @@ tb::func! if tb != nil
360</pre> 360</pre>
361</YueDisplay> 361</YueDisplay>
362 362
363### Incrementing and Decrementing
364
365Yuescript adds the **+=** operator for incrementing and **-=** operator for decrementing values.
366
367```moonscript
368i = 0
369i += 1
370i -= 1
371```
372<YueDisplay>
373<pre>
374i = 0
375i += 1
376i -= 1
377</pre>
378</YueDisplay>
379
380### Appending to tables
381The **[] =** operator is used to append values to tables.
382
383```moonscript
384table = {}
385table[] = "Value"
386```
387<YueDisplay>
388<pre>
389table = {}
390table[] = "Value"
391</pre>
392</YueDisplay>
393
363### Metatable 394### Metatable
364 395
365The **#** operator can be used as a shortcut for metatable manipulation. 396The **#** operator can be used as a shortcut for metatable manipulation.
366 397
367* **Metatable Creation** 398* **Metatable Creation**
368Create normal table with key **#** or metamethod key that ends with **#**. 399Create normal table with key **#** or metamethod key that ends with **#**.
369 400
370```moonscript 401```moonscript
@@ -400,7 +431,7 @@ close _ = close#: -> print "out of scope"
400</pre> 431</pre>
401</YueDisplay> 432</YueDisplay>
402 433
403* **Metatable Accessing** 434* **Metatable Accessing**
404Accessing metatable with key **#** or metamethod key that ends with **#**. 435Accessing metatable with key **#** or metamethod key that ends with **#**.
405 436
406```moonscript 437```moonscript
@@ -423,7 +454,7 @@ print tb.item
423</pre> 454</pre>
424</YueDisplay> 455</YueDisplay>
425 456
426* **Metatable Destructure** 457* **Metatable Destructure**
427Destruct metatable with metamethod key that ends with **#**. 458Destruct metatable with metamethod key that ends with **#**.
428 459
429```moonscript 460```moonscript
@@ -643,7 +674,7 @@ do
643 674
644The export statement offers a concise way to define modules. 675The export statement offers a concise way to define modules.
645 676
646* **Named Export** 677* **Named Export**
647Named export will define a local variable as well as adding a field in the exported table. 678Named export will define a local variable as well as adding a field in the exported table.
648 679
649```moonscript 680```moonscript
@@ -679,7 +710,7 @@ export class Something
679</pre> 710</pre>
680</YueDisplay> 711</YueDisplay>
681 712
682* **Unnamed Export** 713* **Unnamed Export**
683Unnamed export will add the target item into the array part of the exported table. 714Unnamed export will add the target item into the array part of the exported table.
684 715
685```moonscript 716```moonscript
@@ -709,7 +740,7 @@ export with tmp
709</pre> 740</pre>
710</YueDisplay> 741</YueDisplay>
711 742
712* **Default Export** 743* **Default Export**
713Using the **default** keyword in export statement to replace the exported table with any thing. 744Using the **default** keyword in export statement to replace the exported table with any thing.
714 745
715```moonscript 746```moonscript