Skip to content

Commit a2ee242

Browse files
authored
Merge pull request #342 from Peefy/rust-api-doc
docs: add rust api documents
2 parents 6c926ac + 114aa00 commit a2ee242

File tree

5 files changed

+121
-0
lines changed

5 files changed

+121
-0
lines changed

docs/reference/xlang-api/rust-api.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
sidebar_position: 7
3+
---
4+
5+
# Rust API
6+
7+
## Installation
8+
9+
```shell
10+
cargo add --git https://github.com/kcl-lang/lib
11+
```
12+
13+
## Quick Start
14+
15+
```rust
16+
use kcl_lang::*;
17+
use anyhow::Result;
18+
19+
fn main() -> Result<()> {
20+
let api = API::default();
21+
let args = &ExecProgramArgs {
22+
k_filename_list: vec!["main.k".to_string()],
23+
k_code_list: vec!["a = 1".to_string()],
24+
..Default::default()
25+
};
26+
let exec_result = api.exec_program(args)?;
27+
println!("{}", exec_result.yaml_result);
28+
Ok(())
29+
}
30+
```
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
sidebar_position: 7
3+
---
4+
5+
# Rust API
6+
7+
## 添加依赖
8+
9+
```shell
10+
cargo add --git https://github.com/kcl-lang/lib
11+
```
12+
13+
## 快速开始
14+
15+
```rust
16+
use kcl_lang::*;
17+
use anyhow::Result;
18+
19+
fn main() -> Result<()> {
20+
let api = API::default();
21+
let args = &ExecProgramArgs {
22+
k_filename_list: vec!["main.k".to_string()],
23+
k_code_list: vec!["a = 1".to_string()],
24+
..Default::default()
25+
};
26+
let exec_result = api.exec_program(args)?;
27+
println!("{}", exec_result.yaml_result);
28+
Ok(())
29+
}
30+
```
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
sidebar_position: 7
3+
---
4+
5+
# Rust API
6+
7+
## 添加依赖
8+
9+
```shell
10+
cargo add --git https://github.com/kcl-lang/lib
11+
```
12+
13+
## 快速开始
14+
15+
```rust
16+
use kcl_lang::*;
17+
use anyhow::Result;
18+
19+
fn main() -> Result<()> {
20+
let api = API::default();
21+
let args = &ExecProgramArgs {
22+
k_filename_list: vec!["main.k".to_string()],
23+
k_code_list: vec!["a = 1".to_string()],
24+
..Default::default()
25+
};
26+
let exec_result = api.exec_program(args)?;
27+
println!("{}", exec_result.yaml_result);
28+
Ok(())
29+
}
30+
```

mindwm-gitops

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 465a39c29ebc890275802de0b5388d823762f5cd
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
sidebar_position: 7
3+
---
4+
5+
# Rust API
6+
7+
## Installation
8+
9+
```shell
10+
cargo add --git https://github.com/kcl-lang/lib
11+
```
12+
13+
## Quick Start
14+
15+
```rust
16+
use kcl_lang::*;
17+
use anyhow::Result;
18+
19+
fn main() -> Result<()> {
20+
let api = API::default();
21+
let args = &ExecProgramArgs {
22+
k_filename_list: vec!["main.k".to_string()],
23+
k_code_list: vec!["a = 1".to_string()],
24+
..Default::default()
25+
};
26+
let exec_result = api.exec_program(args)?;
27+
println!("{}", exec_result.yaml_result);
28+
Ok(())
29+
}
30+
```

0 commit comments

Comments
 (0)