-
Notifications
You must be signed in to change notification settings - Fork 180
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
Automatically validate sncast docs snippets #2733
base: master
Are you sure you want to change the base?
Automatically validate sncast docs snippets #2733
Conversation
This reverts commit 62bb35a.
…//github.com/foundry-rs/starknet-foundry into franciszekjob/2479-2-shell-commands-validation
…//github.com/foundry-rs/starknet-foundry into franciszekjob/2479-2-shell-commands-validation
…ciszekjob/2479-2-shell-commands-validation
…s://github.com/foundry-rs/starknet-foundry into franciszekjob/2479-2-shell-commands-validation
…ps://github.com/foundry-rs/starknet-foundry into franciszekjob/2479-4-sncast-commands-validation
crates/docs/src/snippet.rs
Outdated
use std::sync::LazyLock; | ||
|
||
use regex::Regex; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
static RE_SNCAST: LazyLock<Regex> = LazyLock::new(|| { | ||
Regex::new( r"(?ms)^(?:<!--\s*(?P<config>\{.*?\})\s*-->\n)?```shell\n\$ (?P<command>sncast .+?)\n```(?:\s*<details>\n<summary>Output:<\/summary>\n\n```shell\n(?P<output>[\s\S]+?)\n```[\s]*<\/details>)?").expect("Failed to create regex for normalizing loop function names") | ||
}); | ||
|
||
static RE_SNFORGE: LazyLock<Regex> = LazyLock::new(|| { | ||
Regex::new( r"(?ms)^(?:<!--\s*(?P<config>\{.*?\})\s*-->\n)?```shell\n\$ (?P<command>snforge .+?)\n```(?:\s*<details>\n<summary>Output:<\/summary>\n\n```shell\n(?P<output>[\s\S]+?)\n```[\s]*<\/details>)?").expect("Failed to create regex for normalizing loop function names") | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: Using static regex is more efficient.
…ps://github.com/foundry-rs/starknet-foundry into franciszekjob/2479-4-sncast-commands-validation
Ok(Utf8PathBuf::from_str(relative_path)? | ||
.canonicalize_utf8()? | ||
.to_string() | ||
.replace('\\', "/")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the user standpoint, having outputs with [..]
in docs is a bit weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the steps to resolve this?
@@ -74,7 +74,7 @@ To import an account into the file holding the accounts info (`~/.starknet_accou | |||
```shell | |||
$ sncast \ | |||
account import \ | |||
--url http://127.0.0.1:5050 \ | |||
--url http://127.0.0.1:5055 \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we change the devnet port?
@@ -255,6 +255,8 @@ sncast_std = "0.33.0" | |||
|
|||
To run the script, do: | |||
|
|||
<!-- TODO: Add script example and remove ignoring output --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link issue please
.get(contract_name.as_str()) | ||
.unwrap_or_else(|| panic!("Contract {contract_name} not found")); | ||
|
||
// In case of invoke/call/verify, we need to replace contract address insnippet's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// In case of invoke/call/verify, we need to replace contract address insnippet's | |
// In case of invoke/call/verify, we need to replace contract address in snippet's |
Retales #2479
Introduced changes
This PR adds validation of sncast command snippets. Before validation, we declare + deploy contracts which are used in the examples.
hello_sncast
package with necessary examplesChecklist
CHANGELOG.md