Skip to content

Commit

Permalink
feat(docs): enable rust snippets in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cmgriffing committed May 9, 2024
1 parent 6748083 commit 56e03e5
Show file tree
Hide file tree
Showing 7 changed files with 9,665 additions and 19,866 deletions.
11 changes: 10 additions & 1 deletion apps/docs/src/content/documentation/getting-started.mdoc
Expand Up @@ -17,7 +17,16 @@ You will need to use the App to set up your flags. You will also be responsible

## Application

Head over to the application and start creating your Flag Groups, Environments, and Flags. For more information about how to use the app, see (the guide)[/guides/application].
Head over to the application and start creating your Flag Groups, Environments, and Flags. For more information about how to use the app, see [the guide](/guides/application).

## Supported languages

| Language | Github | Repo Link |
| -------- | ------ | --------- |
| JS/TS | [https://github.com/Vexilla/vexilla/tree/main/clients/js](https://github.com/Vexilla/vexilla/tree/main/clients/js) | [https://www.npmjs.com/package/@vexilla/client](https://www.npmjs.com/package/@vexilla/client) |
| Rust | [https://github.com/Vexilla/vexilla/tree/main/clients/rust](https://github.com/Vexilla/vexilla/tree/main/clients/rust) | [https://crates.io/crates/vexilla_client](https://crates.io/crates/vexilla_client) |

We are working on publishing more SDKs for the languages you use. If you want to suggest one that we don't have yet, please feel free to chime in over on [this issue](https://github.com/Vexilla/vexilla/issues/1).

## Installation

Expand Down
6 changes: 3 additions & 3 deletions apps/docs/src/content/snippets/generate-types.toml
Expand Up @@ -2,6 +2,6 @@ typescript = """
vexilla generate typescript -o ./types
"""

# rust = """
# vexilla generate rust -o ./types
# """
rust = """
vexilla generate rust -o ./types
"""
6 changes: 3 additions & 3 deletions apps/docs/src/content/snippets/installation.toml
Expand Up @@ -6,6 +6,6 @@ yarn add @vexilla/client
pnpm add @vexilla/client
"""

# rust = """
# cargo add vexilla_client
# """
rust = """
cargo add vexilla_client
"""
35 changes: 10 additions & 25 deletions apps/docs/src/content/snippets/usage-instantiation.toml
Expand Up @@ -15,30 +15,15 @@ await client.syncFlags("FLAG_GROUP_NAME_OR_ID", (url) => {
});
"""

# rust = """
# // Warning: unwraps are just for example code brevity
# // create client
# let mut client = VexillaClient::new(
# "dev",
# "http://localhost:3000",
# "YOUR_USERS_ID",
# );
rust = """
// Warning: unwraps are just for example code brevity
let mut client = VexillaClient::new("dev", "https://BUCKET_NAME.s3-website-AWS_REGION.amazonaws.com", user_id);
# // sync manifest
# client.sync_manifest(|url| {
# reqwest::blocking::get(url)
# .unwrap()
# .text()
# .unwrap()
# });
client.sync_manifest(|url| reqwest::blocking::get(url).unwrap().text().unwrap());
# // sync flags
# client.sync_flags(
# "FLAG_GROUP_NAME_OR_ID",
# |url| {
# reqwest::blocking::get(url)
# .unwrap()
# .text()
# .unwrap()
# }).unwrap();
# """
client
.sync_flags("Scheduled", |url| {
reqwest::blocking::get(url).unwrap().text().unwrap()
})
.unwrap();
"""
12 changes: 6 additions & 6 deletions apps/docs/src/content/snippets/usage-logic.toml
Expand Up @@ -4,9 +4,9 @@ if (client.should("GROUP_NAME_OR_ID", "FLAG_NAME_OR_ID")) {
}
"""

# rust = """
# match client.should("GROUP_NAME_OR_ID", "FLAG_NAME_OR_ID") {
# Ok() => println!("Do the thing for the flag"),
# _ => println!("DON'T do the thing for the flag"),
# };
# """
rust = """
match client.should("GROUP_NAME_OR_ID", "FLAG_NAME_OR_ID") {
Ok() => println!("Do the thing for the flag"),
_ => println!("DON'T do the thing for the flag"),
};
"""
9 changes: 5 additions & 4 deletions clients/rust/README.toml
Expand Up @@ -38,14 +38,15 @@ let mut client = VexillaClient::new(environment, server_host, user_id);
client.sync_manifest(|url| reqwest::blocking::get(url).unwrap().text().unwrap());
client
.sync_flags("Scheduled", |url| {
.sync_flags(GROUP_NAME_OR_ID, |url| {
reqwest::blocking::get(url).unwrap().text().unwrap()
})
.unwrap();
if client.should(FEATURE_NAME) {
// Do the thing
}
match client.should("GROUP_NAME_OR_ID", "FLAG_NAME_OR_ID") {
Ok() => println!("Do the thing for the flag"),
_ => println!("DON'T do the thing for the flag"),
};
```
'''

Expand Down

0 comments on commit 56e03e5

Please sign in to comment.