Skip to content

Commit 835a05c

Browse files
committed
fix: chaptering system
1 parent fd7e440 commit 835a05c

29 files changed

+34
-80
lines changed
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
# Advanced Syntax
2-
3-
In the subsequent section you will learn more about Amber syntax that is recommended for advanced Amber or Shell Script developers.
1+
In the subsequent section you will learn more about Amber syntax that is recommended for advanced Amber or Shell Script developers.

docs/advanced_syntax/as_cast.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# As cast
2-
31
As cast is a tool that might initially seem like an easy way to convert types. So, why has this functionality found its place in the advanced category? Well, with great power comes great responsibility. You could perform some casts that make sense, like from `Bool` to `Num`, but you could also perform casts that we refer to as _absurd_. An example of this might be converting `Text` to `Num`.
42

53
## Regular casts

docs/advanced_syntax/builtins.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# Builtins
2-
3-
Builtins are native methods (built in the compiler itself) and they are also reserved keywords in Amber.
1+
Builtins are native methods (built in the compiler itself) and they are also reserved keywords in Amber.
42

53
Similar to the standard library, they generate valid [Shellcheck](https://www.shellcheck.net/) code (though full support for this in Amber is still in progress).
64

@@ -22,7 +20,7 @@ echo "Hello World!"
2220

2321
## Mv
2422

25-
If you need to move files you can use the `mv` builtin, requires two `Text` parameters.
23+
If you need to move files you can use the `mv` builtin, requires two `Text` parameters.
2624
*Doesn't support the `mv` unix command parameters*.
2725

2826
```ab
@@ -38,7 +36,7 @@ mv "/tmp/a" "/tmp/b" failed {
3836

3937
## Nameof
4038

41-
For more advanced commands, you might need the name of the variable in the compiled script. The `nameof` keyword provides this functionality.
39+
For more advanced commands, you might need the name of the variable in the compiled script. The `nameof` keyword provides this functionality.
4240

4341
For example, this allows you to perform operations like:
4442

docs/advanced_syntax/compiler_flags.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Compiler Flags
2-
31
Compiler flags allow you to change the behavior of the compiler for the given scope of a function. Remember that some warnings are there for a reason. If you do not understand why some warning is being emitted, go ahead and learn more about basic syntax. Here is a list of all the compiler flags that are ready to be used:
42
- `allow_nested_if_else` - Turns off the warning that encourages developer to use the syntax designed to handle if else chains.
53
- `allow_generic_return` - Turns off the warning that tells user to specify a concrete return type when arguments with concrete types are used
@@ -11,4 +9,4 @@ Example:
119
fun foo() {
1210
// ...
1311
}
14-
```
12+
```
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Type condition
2-
31
Sometimes when building generic functions one could find it very convenient to additionally validate if passed value is one of the data types that are supported.
42

53
```ab
@@ -9,4 +7,4 @@ fun getObject(value) {
97
value is Num: getById(value)
108
}
119
}
12-
```
10+
```

docs/basic_syntax/arrays.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Arrays
2-
31
We learned about array literals in the first chapter. In this chapter we will learn how to make use of them. Arrays are indexed from zero.
42

53
To store or retrieve a value at a particular index of an array, you can use the following syntax:

docs/basic_syntax/basic_syntax.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Basic Syntax
2-
31
> This language documentation assumes that you understand the basics of programming
42
53
Since Amber was designed based on the ECMA script syntax some of the following parts of programming language may be familiar.
@@ -29,4 +27,4 @@ echo "My favorite fruits are:"
2927
loop fruit in fruits {
3028
echo fruit
3129
}
32-
```
30+
```

docs/basic_syntax/commands.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Commands
2-
31
The only way to access the bash shell is through Amber's commands. Commands can be used in the form of a statement or an expression.
42

53
The important thing regarding commands is that they can `fail`. Failing is a new concept that forces the caller to handle the failure. There are many ways to handle failure:
@@ -88,7 +86,7 @@ silent unsafe {
8886
}
8987
```
9088

91-
## Unsafe command execution
89+
## Unsafe command execution
9290

9391
```ab
9492
unsafe $test -d /path/to/file$
@@ -106,5 +104,3 @@ You can easily silent given command. Here is an example usage:
106104
```ab
107105
silent $very loud command$
108106
```
109-
110-

docs/basic_syntax/conditions.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Conditions
2-
31
There are three ways to perform conditional logic:
42
- **If Statement** - This is a regular if statement that can be used anywhere
53
- **If Chain** - This is _syntactical sugar_ for pesky if-else chained together.
@@ -100,4 +98,3 @@ The ternary expression can of course be inlined when the expressions inside are
10098
```ab
10199
let candy = count > 1 then "candies" else "candy"
102100
```
103-

docs/basic_syntax/data_types.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Data types
2-
31
Amber supports 5 data types:
42
- `Text` - The textual data type. In other programming languages it can also be called "string".
53
- `Num` - The numeric data type. It's basically any number.

0 commit comments

Comments
 (0)