-
Notifications
You must be signed in to change notification settings - Fork 1.9k
chore: fix doc-test parsing errors in doc examples #4290
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
f22bce8
a675ac7
751a01a
32acf0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1555,9 +1555,12 @@ pub type Files = Vec<(PathBuf, String)>; | |
| /// Create files from the given (path, content) tuple array. | ||
| /// | ||
| /// # Example | ||
| /// | ||
| /// ```ignore | ||
| /// crate_files(vec![("programs/my_program/src/lib.rs".into(), "// Content".into())])?; | ||
| /// # fn main() -> anyhow::Result<()> { | ||
| /// # use std::path::PathBuf; | ||
| /// # let files = vec![(PathBuf::from("programs/my_program/src/lib.rs"), "// Content".to_string())]; | ||
| /// # crate::create_files(&files)?; | ||
| /// # Ok(()) | ||
| /// # } | ||
| /// ``` | ||
| pub fn create_files(files: &Files) -> Result<()> { | ||
| for (path, content) in files { | ||
|
|
@@ -1586,8 +1589,14 @@ pub fn create_files(files: &Files) -> Result<()> { | |
| /// | ||
| /// # Example | ||
| /// | ||
| /// ```ignore | ||
| /// override_or_create_files(vec![("programs/my_program/src/lib.rs".into(), "// Content".into())])?; | ||
| /// ```rust | ||
| /// # fn main() -> anyhow::Result<()> { | ||
| /// # let temp_dir = tempfile::tempdir()?; | ||
| /// # let file_path = temp_dir.path().join("lib.rs"); | ||
| /// # let files = vec![(file_path, "// Content".to_string())]; | ||
| /// // override_or_create_files(&files)?; | ||
|
||
| /// # Ok(()) | ||
| /// # } | ||
| /// ``` | ||
| pub fn override_or_create_files(files: &Files) -> Result<()> { | ||
| for (path, content) in files { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -569,6 +569,7 @@ impl<C: Deref<Target = impl Signer> + Clone, S: AsSigner> RequestBuilder<'_, C, | |
| /// # Example | ||
| /// | ||
| /// ```ignore | ||
| /// # fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
|
||
| /// program | ||
| /// .request() | ||
| /// // Regular accounts | ||
|
|
@@ -585,6 +586,8 @@ impl<C: Deref<Target = impl Signer> + Clone, S: AsSigner> RequestBuilder<'_, C, | |
| /// }]) | ||
| /// .args(instruction::Initialize { field: 42 }) | ||
| /// .send()?; | ||
| /// # Ok(()) | ||
| /// # } | ||
| /// ``` | ||
| #[must_use] | ||
| pub fn accounts(mut self, accounts: impl ToAccountMetas) -> Self { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,23 +20,26 @@ use syn::parse_macro_input; | |||||
| /// pub fn create(ctx: Context<Create>, bump_seed: u8) -> Result<()> { | ||||||
| /// let my_account = &mut ctx.accounts.my_account; | ||||||
| /// my_account.bump_seed = bump_seed; | ||||||
| // / Ok(()) // This was missing. | ||||||
| /// } | ||||||
| /// } | ||||||
| /// | ||||||
| /// #[derive(Accounts)] | ||||||
| /// pub struct Create { | ||||||
| /// pub struct Create <'info> { // <'info> added | ||||||
|
||||||
| /// pub struct Create <'info> { // <'info> added | |
| /// pub struct Create <'info> { |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,8 @@ use syn::{ | |
| /// #[account(init, payer = payer, space = 8 + ExampleAccount::INIT_SPACE)] | ||
| /// pub data: Account<'info, ExampleAccount>, | ||
| /// } | ||
| /// | ||
| /// # fn main() {} | ||
|
||
| /// ``` | ||
| #[proc_macro_derive(InitSpace, attributes(max_len))] | ||
| pub fn derive_init_space(item: TokenStream) -> TokenStream { | ||
|
|
||
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.
This should not be commented out, the doctest will be empty