Skip to content

Commit 449ddff

Browse files
committed
docs: add blocks documentation and improve syntax guide
- Add blocks.md with syntax and examples - Update navigation and remove Next Steps sections
1 parent bc29145 commit 449ddff

File tree

11 files changed

+138
-534
lines changed

11 files changed

+138
-534
lines changed

docs/.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default defineConfig({
2424
items: [
2525
{ text: "Overview", link: "/syntax-guide/overview" },
2626
{ text: "Literals", link: "/syntax-guide/literals" },
27+
{ text: "Blocks", link: "/syntax-guide/blocks" },
2728
{ text: "Collections", link: "/syntax-guide/collections" },
2829
{ text: "Operations", link: "/syntax-guide/operations" },
2930
{ text: "Functions", link: "/syntax-guide/functions" },

docs/introduction/what-is-resl.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RESL is designed to bring programming capabilities to config files, eliminating
2121

2222
- **🔄 Dynamic Configuration**: Variables, functions, and computed values
2323
- **📝 Familiar Syntax**: Combines the best of JSON, JavaScript, and functional programming
24-
- **🏗️ Flexible Structure**: Any expression can be top-level, not just objects
24+
- **🏗️ Flexible Structure**: Any expression can be top-level
2525
- **📊 Rich Data Types**: Strings, numbers, booleans, lists, and maps
2626
- **⚡ Powerful Operations**: Binary operations, conditionals, transformations, and more
2727

@@ -35,6 +35,14 @@ RESL is ideal for:
3535
- **Data Generation**: Test data, mock configurations, templated content
3636
- **API Responses**: Dynamic JSON generation with computed fields
3737

38+
## 🔍 How is RESL Different from a Programming Language?
39+
40+
- Programming languages offer extensive capabilities, often beyond what is needed for configuration.
41+
- RESL is intentionally restrictive, focusing solely on configuration and serialization tasks.
42+
- RESL files store data in a structured yet flexible format, designed for clarity and simplicity.
43+
- During runtime evaluation, RESL processes and computes the data to produce the desired output.
44+
- This design minimizes the risk of arbitrary code execution, ensuring safer and more predictable behavior.
45+
3846
## 💡 Philosophy
3947

4048
RESL follows the principle that configuration should be:

docs/introduction/why-resl.md

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RESL addresses the fundamental limitations of traditional configuration formats
2121

2222
**RESL Solutions:**
2323

24-
JSON: Repetitive and verbose
24+
**Step 1:** RESL can replicate JSON exactly as-is
2525

2626
```json
2727
{
@@ -32,19 +32,46 @@ JSON: Repetitive and verbose
3232
}
3333
```
3434

35-
RESL: Variables and computed values
35+
```resl
36+
[
37+
"services": [
38+
[ "name": "auth", "image": "app/auth:v1.2.0", "port": 8080 ],
39+
[ "name": "api", "image": "app/api:v1.2.0", "port": 8081 ]
40+
]
41+
]
42+
```
43+
44+
**Step 2:** Then enhance with variables to eliminate repetition
45+
46+
```resl
47+
{
48+
version = "v1.2.0";
49+
base_port = 8080;
50+
51+
[
52+
"services": [
53+
[ "name": "auth", "image": concat("app/auth:", version), "port": base_port ],
54+
[ "name": "api", "image": concat("app/api:", version), "port": base_port + 1 ]
55+
]
56+
]
57+
}
58+
```
59+
60+
**Step 3:** Add computed values and loops for ultimate flexibility
3661

3762
```resl
3863
{
3964
version = "v1.2.0";
4065
base_port = 8080;
4166
services = ["auth", "api"];
4267
43-
["services": services > (i, name): [
44-
"name": name,
45-
"image": concat("app/", name, ":", version),
46-
"port": base_port + i
47-
]]
68+
[
69+
"services": services > (i, name): [
70+
"name": name,
71+
"image": concat("app/", name, ":", version),
72+
"port": base_port + i
73+
]
74+
]
4875
}
4976
```
5077

@@ -86,17 +113,17 @@ RESL: Variables and computed values
86113

87114
Variables and computed values eliminate repetition, typically reducing config file sizes by 30-50% compared to JSON.
88115

89-
**Before (JSON - 156 characters):**
116+
**Step 1: Direct JSON equivalent (RESL - 156 characters):**
90117

91-
```json
92-
{
93-
"db": { "host": "localhost", "port": 5432 },
94-
"cache": { "host": "localhost", "port": 6379 },
118+
```resl
119+
[
120+
"db": [ "host": "localhost", "port": 5432 ],
121+
"cache": ["host": "localhost", "port": 6379 ],
95122
"url": "http://localhost:8080"
96-
}
123+
]
97124
```
98125

99-
**After (RESL - 98 characters):**
126+
**Step 2: Enhanced with variables (RESL - 98 characters):**
100127

101128
```resl
102129
{host="localhost";["db":["host":host,"port":5432],"cache":["host":host,"port":6379],"url":concat("http://",host,":8080")]}

0 commit comments

Comments
 (0)