feat(doc gen): fixed mdx issues
This commit is contained in:
550
tools/generate-rhai-docs/auto_gen/apilib.mdx
Normal file
550
tools/generate-rhai-docs/auto_gen/apilib.mdx
Normal file
@@ -0,0 +1,550 @@
|
||||
---
|
||||
title: linux
|
||||
slug: /linux
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
|
||||
|
||||
# API Library Module
|
||||
|
||||
These are all the API modules available in ewwii.
|
||||
|
||||
Each library in this module is under `api::<m>`, where `<m>` is the name of the specific module.
|
||||
|
||||
The API library provides system-level functionality, allowing you to interact with external resources and perform advanced operations. Examples include interacting with Wi-Fi, networking, and more.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## <code>fn</code> get_battery_perc {#fn-get_battery_perc}
|
||||
|
||||
```js
|
||||
fn get_battery_perc() -> int
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the current battery percentage.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
This function does not require any arguments.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
The battery percentage as an integer.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "api::linux" as linux;
|
||||
|
||||
let battery_perc = linux::get_battery_perc();
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> get_cpu_info {#fn-get_cpu_info}
|
||||
|
||||
```js
|
||||
fn get_cpu_info() -> Array
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the device CPU information.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
This function does not require any arguments.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
An `Array` containing the CPU information in a `Map`:
|
||||
- `core_id` (Integer)
|
||||
- `model`
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "api::linux" as linux;
|
||||
|
||||
let cpu_info = linux::get_cpu_info();
|
||||
let cpu_model = cpu_info[0].model; // get the model of the 1st core
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> get_disk_info {#fn-get_disk_info}
|
||||
|
||||
```js
|
||||
fn get_disk_info() -> Map
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the device disk information.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
This function does not require any arguments.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
A `Map` containing the disk information:
|
||||
- Each key is a `mountpoint`, value is a map with:
|
||||
- `device` (String)
|
||||
- `total_kb` (Integer)
|
||||
- `used_kb` (Integer)
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "api::linux" as linux;
|
||||
|
||||
let disk_info = linux::get_disk_info();
|
||||
let device = disk_info.device;
|
||||
let total_kb = disk_info.total_kb;
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> get_gpu_info {#fn-get_gpu_info}
|
||||
|
||||
```js
|
||||
fn get_gpu_info() -> Array
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the device GPU information.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
This function does not require any arguments.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
An `Array` containing the GPU information in a `Map`:
|
||||
- `sys_name` (String): e.g., "card0"
|
||||
- `model` (String)
|
||||
- `vendor` (String)
|
||||
- `memory_kb` (Integer)
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "api::linux" as linux;
|
||||
|
||||
let gpu_info = linux::get_gpu_info();
|
||||
let model = gpu_info[0].model; // 1st GPU card model
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> get_kernel_version {#fn-get_kernel_version}
|
||||
|
||||
```js
|
||||
fn get_kernel_version() -> String
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the installed Linux Kernel version.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
This function does not require any arguments.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
The Kernel version as a `String`. (e.g. "6.16.4-arch1-1")
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "api::linux" as linux;
|
||||
|
||||
let k_version = linux::get_kernel_version();
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> get_ram_info {#fn-get_ram_info}
|
||||
|
||||
```js
|
||||
fn get_ram_info() -> Map
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the device RAM information.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
This function does not require any arguments.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
A `Map` containing the RAM information:
|
||||
- `total_kb`
|
||||
- `free_kb`
|
||||
- `available_kb`
|
||||
- `used_kb`
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "api::linux" as linux;
|
||||
|
||||
let ram_info = linux::get_ram_info();
|
||||
let used_kb = ram_info.used_kb;
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
---
|
||||
title: wifi
|
||||
slug: /wifi
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
```Namespace: global/api/wifi```
|
||||
|
||||
|
||||
|
||||
|
||||
## <code>fn</code> connect {#fn-connect}
|
||||
|
||||
```js
|
||||
fn connect(ssid: String, password: String)
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Connects to a Wi-Fi network with the specified SSID and password.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
* `ssid` - The SSID of the Wi-Fi network.
|
||||
* `password` - The password of the Wi-Fi network (optional for open networks).
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns nothing if the connection is successful, or an error message if it fails.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "api::wifi" as wifi;
|
||||
|
||||
wifi::connect("MySecretNetwork", "password123");
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> connect_without_password {#fn-connect_without_password}
|
||||
|
||||
```js
|
||||
fn connect_without_password(ssid: String)
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Connects to a Wi-Fi network with the specified SSID using saved profile (no password required).
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
* `ssid` - The SSID of the Wi-Fi network.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns nothing if the connection is successful, or an error message if it fails.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "api::wifi" as wifi;
|
||||
|
||||
wifi::connect_without_password("MySecretNetwork", "password123");
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> current_connection {#fn-current_connection}
|
||||
|
||||
```js
|
||||
fn current_connection() -> Map
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Retrieves the current active Wi-Fi connection's details (SSID, signal, and security).
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
This function does not require any arguments.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
A `Map` containing the current connection's SSID, signal strength, and security type.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "api::wifi" as wifi;
|
||||
|
||||
let connection = wifi::current_connection();
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> disable_adapter {#fn-disable_adapter}
|
||||
|
||||
```js
|
||||
fn disable_adapter()
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Disables the Wi-Fi adapter.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
This function does not require any arguments.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns nothing if the connection is successful, or an error message if it fails.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "api::wifi" as wifi;
|
||||
|
||||
wifi::disable_adapter();
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> disconnect {#fn-disconnect}
|
||||
|
||||
```js
|
||||
fn disconnect()
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Disconnects from the current Wi-Fi network.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
This function does not require any arguments.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns nothing if the connection is successful, or an error message if it fails.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "api::wifi" as wifi;
|
||||
|
||||
wifi::disconnect();
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> enable_adapter {#fn-enable_adapter}
|
||||
|
||||
```js
|
||||
fn enable_adapter()
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Enables the Wi-Fi adapter.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
This function does not require any arguments.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns nothing if the connection is successful, or an error message if it fails.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "api::wifi" as wifi;
|
||||
|
||||
wifi::enable_adapter();
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> get_adapter_connectivity {#fn-get_adapter_connectivity}
|
||||
|
||||
```js
|
||||
fn get_adapter_connectivity() -> String
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the currenet state of adapter.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
This function does not require any arguments.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns the state of the adapter as a `string` and returns an error if getting the state failed.
|
||||
|
||||
**Possible returns in Linux:**
|
||||
|
||||
- `"full"` (internet available)
|
||||
- `"limited"` (network only, no internet)
|
||||
- `"portal"` (captive portal)
|
||||
- `"none"` (no connectivity)
|
||||
|
||||
**Possible returns in macOS:**
|
||||
|
||||
- `"full"` (connected to a Wi-Fi network)
|
||||
- `"none"` (not connected)
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "api::wifi" as wifi;
|
||||
|
||||
wifi::enable_adapter();
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> scan {#fn-scan}
|
||||
|
||||
```js
|
||||
fn scan() -> Array
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Scans for all available Wi-Fi connections, platform-dependent (Linux or macOS).
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
This function does not require any arguments.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
An `Array` containing information about each Wi-Fi connection, where each entry is a `Map`
|
||||
with keys "ssid", "signal", and "security" representing the Wi-Fi network's SSID, signal strength,
|
||||
and security type.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "api::wifi" as wifi;
|
||||
|
||||
let networks = wifi::scan();
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> scan_linux {#fn-scan_linux}
|
||||
|
||||
```js
|
||||
fn scan_linux() -> Array
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Scans for all available Wi-Fi connections on Linux.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
This function does not require any arguments.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
An `Array` containing information about each Wi-Fi connection, where each entry is a `Map`
|
||||
with keys "ssid", "signal", and "security" representing the Wi-Fi network's SSID, signal strength,
|
||||
and security type.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "api::wifi" as wifi;
|
||||
|
||||
let networks = wifi::scan();
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
4492
tools/generate-rhai-docs/auto_gen/global.md
Normal file
4492
tools/generate-rhai-docs/auto_gen/global.md
Normal file
File diff suppressed because it is too large
Load Diff
726
tools/generate-rhai-docs/auto_gen/stdlib.md
Normal file
726
tools/generate-rhai-docs/auto_gen/stdlib.md
Normal file
@@ -0,0 +1,726 @@
|
||||
---
|
||||
title: command
|
||||
slug: /command
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
|
||||
|
||||
# Std Library Module
|
||||
|
||||
These are all the standard modules in ewwii.
|
||||
|
||||
Each library in this module is under `std::<m>`, where `<m>` is the name of the specific module.
|
||||
These modules provide essential functionalities that are will be useful for making widgets.
|
||||
They cover tasks like string manipulation, environmental variable manipuation, running shell commands, and more.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## <code>fn</code> run {#fn-run}
|
||||
|
||||
```js
|
||||
fn run(cmd: String)
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Executes a shell command without capturing the output.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
* `cmd` - The shell command to execute as a string.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
This function returns nothing if the command executes successfully. If there is an error
|
||||
running the command, it returns the error.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::command" as cmd;
|
||||
|
||||
// Run a shell command (e.g., list directory contents)
|
||||
cmd::run("ls -l");
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> run_and_read {#fn-run_and_read}
|
||||
|
||||
```js
|
||||
fn run_and_read(cmd: String) -> String
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Executes a shell command and captures its output.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
* `cmd` - The shell command to execute as a string.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
This function returns the standard output of the command as a `string`. If the command fails,
|
||||
it returns the error.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::command" as cmd;
|
||||
|
||||
// Run a shell command and capture its output
|
||||
let output = cmd::run_and_read("echo 'Hello, world!'");
|
||||
print(output); // output: Hello, world!
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
---
|
||||
title: monitor
|
||||
slug: /monitor
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
```Namespace: global/std/monitor```
|
||||
|
||||
|
||||
|
||||
|
||||
## <code>fn</code> all_resolutions {#fn-all_resolutions}
|
||||
|
||||
```js
|
||||
fn all_resolutions() -> Vec<[int;2]>
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the resolutions of all connected monitors.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns an array of arrays, where each inner array contains the width and height of a monitor.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::monitor" as monitor;
|
||||
|
||||
let resolutions = monitor::all_resolutions();
|
||||
print(resolutions); // Output: [[width1, height1], [width2, height2], ...]
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> all_resolutions_str {#fn-all_resolutions_str}
|
||||
|
||||
```js
|
||||
fn all_resolutions_str() -> String
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the resolutions of all connected monitors as a string.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns a string where each monitor's resolution is formatted as "width x height", separated by commas.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::monitor" as monitor;
|
||||
|
||||
let resolutions_str = monitor::all_resolutions_str();
|
||||
print(resolutions_str); // Output: "1920x1080, 1280x720"
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> count {#fn-count}
|
||||
|
||||
```js
|
||||
fn count() -> int
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the number of connected monitors.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns the total number of connected monitors as an `i64`.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::monitor" as monitor;
|
||||
|
||||
let count = monitor::count();
|
||||
print(count); // Output: Number of connected monitors
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> dimensions {#fn-dimensions}
|
||||
|
||||
```js
|
||||
fn dimensions(index: int) -> [int;4]
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the dimensions (x, y, width, height) of a specific monitor.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
* `index` - The index of the monitor (0-based).
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns an array with the monitor's position (x, y) and size (width, height).
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::monitor" as monitor;
|
||||
|
||||
let dimensions = monitor::dimensions(0);
|
||||
print(dimensions); // Output: [x, y, width, height]
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> dimensions_str {#fn-dimensions_str}
|
||||
|
||||
```js
|
||||
fn dimensions_str(index: int) -> String
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the dimensions of a specific monitor as a string.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
* `index` - The index of the monitor (0-based).
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns the monitor's dimensions as a string in the format "x,y - width x height".
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::monitor" as monitor;
|
||||
|
||||
let dimensions_str = monitor::dimensions_str(0);
|
||||
print(dimensions_str); // Output: "0,0 - 1920x1080"
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> dpi {#fn-dpi}
|
||||
|
||||
```js
|
||||
fn dpi(index: int) -> float
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the DPI (dots per inch) of a specific monitor.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
* `index` - The index of the monitor (0-based).
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns the DPI (scale factor * base DPI) of the monitor as a `f64`.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::monitor" as monitor;
|
||||
|
||||
let dpi = monitor::dpi(0);
|
||||
print(dpi); // Output: DPI of the monitor
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> dpi_str {#fn-dpi_str}
|
||||
|
||||
```js
|
||||
fn dpi_str(index: int) -> String
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the DPI of a specific monitor as a string.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
* `index` - The index of the monitor (0-based).
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns the DPI of the monitor as a string formatted to 1 decimal place.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::monitor" as monitor;
|
||||
|
||||
let dpi_str = monitor::dpi_str(0);
|
||||
print(dpi_str); // Output: "96.0"
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> primary_resolution {#fn-primary_resolution}
|
||||
|
||||
```js
|
||||
fn primary_resolution() -> [int;2]
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the resolution of the primary monitor.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns an array containing the width and height of the primary monitor as two `i64` values.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::monitor" as monitor;
|
||||
|
||||
let resolution = monitor::primary_resolution();
|
||||
print(resolution); // Output: [width, height]
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> primary_resolution_str {#fn-primary_resolution_str}
|
||||
|
||||
```js
|
||||
fn primary_resolution_str() -> String
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the resolution of the primary monitor as a string.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns the resolution of the primary monitor as a string in the format "width x height".
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::monitor" as monitor;
|
||||
|
||||
let resolution_str = monitor::primary_resolution_str();
|
||||
print(resolution_str); // Output: "1920x1080"
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
---
|
||||
title: env
|
||||
slug: /env
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
```Namespace: global/std/env```
|
||||
|
||||
|
||||
|
||||
|
||||
## <code>fn</code> get_current_dir {#fn-get_current_dir}
|
||||
|
||||
```js
|
||||
fn get_current_dir() -> String
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the current working directory.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
This function returns the current working directory as a `String`. If there is an error
|
||||
(e.g., if the path cannot be retrieved), it returns a `Result::Err` with the error message.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::env" as env;
|
||||
|
||||
// Get the current working directory
|
||||
let current_dir = env::get_current_dir();
|
||||
print(current_dir); // output: /home/username/project
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> get_env {#fn-get_env}
|
||||
|
||||
```js
|
||||
fn get_env(var: String) -> String
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the value of an environment variable.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
* `var` - The name of the environment variable to retrieve.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
This function returns the value of the environment variable as a `String`.
|
||||
If the variable is not found or there is an error, it returns a `Result::Err` with the error message.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::env" as env;
|
||||
|
||||
// Get the value of the "HOME" environment variable
|
||||
let home_dir = env::get_env("HOME");
|
||||
print(home_dir); // output: /home/username
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> get_home_dir {#fn-get_home_dir}
|
||||
|
||||
```js
|
||||
fn get_home_dir() -> String
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the path to the home directory.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
This function returns the value of the "HOME" environment variable as a `String`.
|
||||
If the variable is not found or there is an error, it returns a `Result::Err` with the error message.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::env" as env;
|
||||
|
||||
// Get the home directory
|
||||
let home_dir = env::get_home_dir();
|
||||
print(home_dir); // output: /home/username
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> get_username {#fn-get_username}
|
||||
|
||||
```js
|
||||
fn get_username() -> String
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Get the current username.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
This function returns the value of the "USER" environment variable as a `String`.
|
||||
If the variable is not found or there is an error, it returns a `Result::Err` with the error message.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::env" as env;
|
||||
|
||||
// Get the username of the current user
|
||||
let username = env::get_username();
|
||||
print(username); // output: username
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> set_env {#fn-set_env}
|
||||
|
||||
```js
|
||||
fn set_env(var: String, value: String)
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Set the value of an environment variable.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
* `var` - The name of the environment variable to set.
|
||||
* `value` - The value to assign to the environment variable.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
This function does not return a value.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::env" as env;
|
||||
|
||||
// Set the value of the "MY_VAR" environment variable
|
||||
env::set_env("MY_VAR", "SomeValue");
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
---
|
||||
title: text
|
||||
slug: /text
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
```Namespace: global/std/text```
|
||||
|
||||
A module providing utility functions for string manipulation.
|
||||
|
||||
|
||||
## <code>fn</code> to_camel_case {#fn-to_camel_case}
|
||||
|
||||
```js
|
||||
fn to_camel_case(text: String) -> String
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Converts a string to camel case.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
* `text` - A string to be converted to camel case.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns the `text` in camel case format.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::text" as text;
|
||||
|
||||
let result = text::to_camel_case("hello world example");
|
||||
print(result); // output: "helloWorldExample"
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> to_lower {#fn-to_lower}
|
||||
|
||||
```js
|
||||
fn to_lower(s: String) -> String
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Converts a string to lowercase.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
* `s` - A string to be converted to lowercase.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns the string in lowercase.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::text" as text;
|
||||
|
||||
let result = text::to_lower("HELLO");
|
||||
print(result); // output: "hello"
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> to_slug {#fn-to_slug}
|
||||
|
||||
```js
|
||||
fn to_slug(text: String) -> String
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Converts a string to a slug (lowercase words joined by hyphens).
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
* `text` - A string to be converted to a slug.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns the `text` as a slug.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::text" as text;
|
||||
|
||||
let result = text::to_slug("Hello World!");
|
||||
print(result); // output: "hello-world"
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> to_upper {#fn-to_upper}
|
||||
|
||||
```js
|
||||
fn to_upper(s: String) -> String
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Converts a string to uppercase.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
* `s` - A string to be converted to uppercase.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns the string in uppercase.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::text" as text;
|
||||
|
||||
let result = text::to_upper("hello");
|
||||
print(result); // output: "HELLO"
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## <code>fn</code> truncate_chars {#fn-truncate_chars}
|
||||
|
||||
```js
|
||||
fn truncate_chars(text: String, max_chars: int) -> String
|
||||
```
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Description" default>
|
||||
|
||||
Truncates a string to the specified number of characters.
|
||||
</TabItem>
|
||||
<TabItem value="Arguments" default>
|
||||
|
||||
|
||||
* `text` - A string to be truncated.
|
||||
* `max_chars` - The maximum number of characters to keep in the string.
|
||||
</TabItem>
|
||||
<TabItem value="Returns" default>
|
||||
|
||||
|
||||
Returns a truncated string.
|
||||
</TabItem>
|
||||
<TabItem value="Example" default>
|
||||
|
||||
|
||||
```javascript
|
||||
import "std::text" as text;
|
||||
|
||||
let result = text::truncate_chars("Hello World!", 5);
|
||||
print(result); // output: "Hello"
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
@@ -28,7 +28,44 @@ fn generate_docs(
|
||||
docs_content.into_iter().map(|(_, doc)| doc).collect::<Vec<String>>().join("\n");
|
||||
|
||||
// combination of all docs and pre description
|
||||
let final_docs = format!("{}\n\n{}", pre_description, full_docs);
|
||||
let mut final_docs = String::new();
|
||||
let mut lines = full_docs.lines();
|
||||
|
||||
let mut in_frontmatter = false;
|
||||
for line in &mut lines {
|
||||
if line.trim() == "---" {
|
||||
final_docs.push_str(line);
|
||||
final_docs.push('\n');
|
||||
|
||||
if !in_frontmatter {
|
||||
in_frontmatter = true;
|
||||
} else {
|
||||
in_frontmatter = false;
|
||||
break;
|
||||
}
|
||||
} else if in_frontmatter {
|
||||
final_docs.push_str(line);
|
||||
final_docs.push('\n');
|
||||
}
|
||||
}
|
||||
|
||||
for line in &mut lines {
|
||||
if line.starts_with("import ") || line.trim().is_empty() {
|
||||
final_docs.push_str(line);
|
||||
final_docs.push('\n');
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final_docs.push('\n');
|
||||
final_docs.push_str(pre_description);
|
||||
final_docs.push('\n');
|
||||
|
||||
for line in lines {
|
||||
final_docs.push_str(line);
|
||||
final_docs.push('\n');
|
||||
}
|
||||
|
||||
// Write documentation to markdown file
|
||||
let file_path = Path::new(path).join(format!("{}.md", filename));
|
||||
@@ -38,7 +75,7 @@ fn generate_docs(
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
let path = if args.len() > 1 { &args[1] } else { "./tools/generate-rhai-docs/" };
|
||||
let path = if args.len() > 1 { &args[1] } else { "./tools/generate-rhai-docs/auto_gen" };
|
||||
|
||||
// engine/resolver
|
||||
let engine = Engine::new();
|
||||
|
||||
Reference in New Issue
Block a user