Skip to content

docs: add rust api documents #342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/reference/xlang-api/rust-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
sidebar_position: 7
---

# Rust API

## Installation

```shell
cargo add --git https://github.com/kcl-lang/lib
```

## Quick Start

```rust
use kcl_lang::*;
use anyhow::Result;

fn main() -> Result<()> {
let api = API::default();
let args = &ExecProgramArgs {
k_filename_list: vec!["main.k".to_string()],
k_code_list: vec!["a = 1".to_string()],
..Default::default()
};
let exec_result = api.exec_program(args)?;
println!("{}", exec_result.yaml_result);
Ok(())
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
sidebar_position: 7
---

# Rust API

## 添加依赖

```shell
cargo add --git https://github.com/kcl-lang/lib
```

## 快速开始

```rust
use kcl_lang::*;
use anyhow::Result;

fn main() -> Result<()> {
let api = API::default();
let args = &ExecProgramArgs {
k_filename_list: vec!["main.k".to_string()],
k_code_list: vec!["a = 1".to_string()],
..Default::default()
};
let exec_result = api.exec_program(args)?;
println!("{}", exec_result.yaml_result);
Ok(())
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
sidebar_position: 7
---

# Rust API

## 添加依赖

```shell
cargo add --git https://github.com/kcl-lang/lib
```

## 快速开始

```rust
use kcl_lang::*;
use anyhow::Result;

fn main() -> Result<()> {
let api = API::default();
let args = &ExecProgramArgs {
k_filename_list: vec!["main.k".to_string()],
k_code_list: vec!["a = 1".to_string()],
..Default::default()
};
let exec_result = api.exec_program(args)?;
println!("{}", exec_result.yaml_result);
Ok(())
}
```
1 change: 1 addition & 0 deletions mindwm-gitops
Submodule mindwm-gitops added at 465a39
30 changes: 30 additions & 0 deletions versioned_docs/version-0.8/reference/xlang-api/rust-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
sidebar_position: 7
---

# Rust API

## Installation

```shell
cargo add --git https://github.com/kcl-lang/lib
```

## Quick Start

```rust
use kcl_lang::*;
use anyhow::Result;

fn main() -> Result<()> {
let api = API::default();
let args = &ExecProgramArgs {
k_filename_list: vec!["main.k".to_string()],
k_code_list: vec!["a = 1".to_string()],
..Default::default()
};
let exec_result = api.exec_program(args)?;
println!("{}", exec_result.yaml_result);
Ok(())
}
```