Skip to content

Commit 52d509e

Browse files
committed
Add std library docs
1 parent ed87167 commit 52d509e

File tree

14 files changed

+759
-8
lines changed

14 files changed

+759
-8
lines changed

docs/_meta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
},
77
{
88
"text": "Std Library",
9-
"link": "/std-library/",
10-
"activeMatch": "/std-library/"
9+
"link": "/std/overview",
10+
"activeMatch": "/std/"
1111
},
1212
{
1313
"text": "Reference",

docs/guide/_meta.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,5 @@
1313
"type": "dir",
1414
"name": "web",
1515
"label": "Web"
16-
},
17-
{
18-
"type": "dir",
19-
"name": "std-library",
20-
"label": "Standard Library"
2116
}
2217
]

docs/guide/std-library/index.mdx

Whitespace-only changes.

docs/std-library/index.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/std/_meta.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[
2+
{
3+
"type": "file",
4+
"name": "overview",
5+
"label": "Overview"
6+
},
7+
{
8+
"type": "file",
9+
"name": "db",
10+
"label": "std.db"
11+
},
12+
{
13+
"type": "file",
14+
"name": "env",
15+
"label": "std.env"
16+
},
17+
{
18+
"type": "file",
19+
"name": "http",
20+
"label": "std.http"
21+
},
22+
{
23+
"type": "file",
24+
"name": "io",
25+
"label": "std.io"
26+
},
27+
{
28+
"type": "file",
29+
"name": "math",
30+
"label": "std.math"
31+
},
32+
{
33+
"type": "file",
34+
"name": "random",
35+
"label": "std.random"
36+
},
37+
{
38+
"type": "file",
39+
"name": "serde",
40+
"label": "std.serde"
41+
},
42+
{
43+
"type": "file",
44+
"name": "time",
45+
"label": "std.time"
46+
}
47+
]

docs/std/db.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# std.db
2+
3+
array
4+
5+
## std.db.pg
6+
7+
## std.db.sqlite
8+
9+
## std.db.redis

docs/std/env.mdx

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# std.env
2+
3+
The `std.env` module provides functions for interacting with environment variables and command-line arguments.
4+
5+
## args()
6+
7+
Returns command-line arguments as an array of strings.
8+
9+
**Return Type**: `Array<string>`
10+
11+
**Example**:
12+
```rust
13+
use std.env;
14+
15+
// If you run: aiscript script.ai arg1 arg2
16+
let args = env.args();
17+
// args will be: ["aiscript", "script.ai", "arg1", "arg2"]
18+
```
19+
20+
## vars()
21+
22+
Returns all environment variables as an object where keys are variable names and values are their corresponding values.
23+
24+
**Return Type**: `Object<string, string>`
25+
26+
**Example**:
27+
```rust
28+
use std.env;
29+
30+
let variables = env.vars();
31+
// Example output:
32+
// {
33+
// "PATH": "/usr/local/bin:/usr/bin",
34+
// "HOME": "/home/user",
35+
// "USER": "username"
36+
// }
37+
```
38+
39+
## get_env(name: string)
40+
41+
Gets the value of an environment variable.
42+
43+
**Parameters**:
44+
- `name`: The name of the environment variable to retrieve
45+
46+
**Return Type**: `string | nil`
47+
48+
**Example**:
49+
```rust
50+
use std.env;
51+
52+
let home = env.get_env("HOME");
53+
// If HOME is set: "/home/user"
54+
// If HOME is not set: nil
55+
```
56+
57+
## set_env(name: string, value: string)
58+
59+
Sets the value of an environment variable.
60+
61+
**Parameters**:
62+
- `name`: The name of the environment variable to set
63+
- `value`: The value to set
64+
65+
**Return Type**: `nil`
66+
67+
**Example**:
68+
```rust
69+
use std.env;
70+
71+
env.set_env("MY_VAR", "my_value");
72+
let value = env.get_env("MY_VAR") // Returns "my_value"
73+
```

docs/std/http.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# std.http

docs/std/io.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# std.io

0 commit comments

Comments
 (0)