Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
20 changes: 16 additions & 4 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1556,8 +1556,14 @@ pub type Files = Vec<(PathBuf, String)>;
///
/// # Example
///
/// ```ignore
/// crate_files(vec![("programs/my_program/src/lib.rs".into(), "// Content".into())])?;
/// ```rust,no_run
/// # use anchor_cli::create_files;
/// # use std::path::PathBuf;
/// # fn main() -> anyhow::Result<()> {
/// let files = vec![(PathBuf::from("programs/my_program/src/lib.rs"), "// Content".to_string())];
/// create_files(&files)?;
/// # Ok(())
/// # }
/// ```
pub fn create_files(files: &Files) -> Result<()> {
for (path, content) in files {
Expand Down Expand Up @@ -1586,8 +1592,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,no_run
/// # use anchor_cli::override_or_create_files;
/// # use std::path::PathBuf;
/// # fn main() -> anyhow::Result<()> {
/// let files = vec![(PathBuf::from("test.rs"), "// Content".to_string())];
/// override_or_create_files(&files)?;
/// # Ok(())
/// # }
/// ```
pub fn override_or_create_files(files: &Files) -> Result<()> {
for (path, content) in files {
Expand Down
3 changes: 3 additions & 0 deletions client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all changes like these to tests which are still marked ignore

/// program
/// .request()
/// // Regular accounts
Expand All @@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion idl/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ pub trait IdlBuild {
///
/// # Example
///
/// ```ignore
/// ```rust,no_run
/// # use std::path::PathBuf;
/// # use anchor_lang_idl::build::IdlBuilder;
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let path = PathBuf::from("programs/my_program");
/// let idl = IdlBuilder::new().program_path(path).skip_lint(true).build()?;
/// # Ok(())
/// # }
/// ```
#[derive(Default)]
pub struct IdlBuilder {
Expand Down
17 changes: 13 additions & 4 deletions lang/attribute/access-control/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,29 @@ 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(())
/// }
/// }
///
/// #[derive(Accounts)]
/// pub struct Create {
/// #[account(init)]
/// pub struct Create<'info> {
/// #[account(init, payer = payer, space = 8 + 1)]
/// my_account: Account<'info, MyAccount>,
/// #[account(mut)]
/// payer: Signer<'info>,
/// system_program: Program<'info, System>,
/// }
///
/// impl Create {
/// #[account]
/// pub struct MyAccount {
/// bump_seed: u8,
/// }
///
/// impl Create<'_> {
/// pub fn accounts(ctx: &Context<Create>, bump_seed: u8) -> Result<()> {
/// let seeds = &[ctx.accounts.my_account.to_account_info().key.as_ref(), &[bump_seed]];
/// Pubkey::create_program_address(seeds, ctx.program_id)
/// .map_err(|_| ErrorCode::InvalidNonce)?;
/// .map_err(|_| error!(ErrorCode::InvalidNonce))?;
/// Ok(())
/// }
/// }
Expand Down
4 changes: 2 additions & 2 deletions lang/attribute/account/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mod lazy;
/// To enable zero-copy-deserialization, one can pass in the `zero_copy`
/// argument to the macro as follows:
///
/// ```ignore
/// ```rust,ignore
/// #[account(zero_copy)]
/// ```
///
Expand Down Expand Up @@ -406,7 +406,7 @@ pub fn derive_zero_copy_accessor(item: proc_macro::TokenStream) -> proc_macro::T
///
/// `#[zero_copy]` is just a convenient alias for
///
/// ```ignore
/// ```rust,ignore
/// #[derive(Copy, Clone)]
/// #[derive(bytemuck::Zeroable)]
/// #[derive(bytemuck::Pod)]
Expand Down
7 changes: 6 additions & 1 deletion lang/attribute/error/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ pub fn error_code(
/// Generates an [`Error::AnchorError`](../../anchor_lang/error/enum.Error.html) that includes file and line information.
///
/// # Example
/// ```rust,ignore
/// ```ignore
/// use anchor_lang::prelude::*;
///
/// #[program]
/// mod errors {
/// use super::*;
Expand All @@ -75,6 +77,9 @@ pub fn error_code(
/// }
/// }
///
/// #[derive(Accounts)]
/// pub struct Example {}
///
/// #[error_code]
/// pub enum MyError {
/// #[msg("This is an error message clients will automatically display")]
Expand Down
4 changes: 4 additions & 0 deletions lang/attribute/event/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ pub fn emit_cpi(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
/// # Example
///
/// ```ignore
/// use anchor_lang::prelude::*;
///
/// #[event_cpi]
/// #[derive(Accounts)]
/// pub struct MyInstruction<'info> {
Expand All @@ -210,6 +212,8 @@ pub fn emit_cpi(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
/// The code above will be expanded to:
///
/// ```ignore
/// use anchor_lang::prelude::*;
///
/// #[derive(Accounts)]
/// pub struct MyInstruction<'info> {
/// pub signer: Signer<'info>,
Expand Down
2 changes: 2 additions & 0 deletions lang/derive/space/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use syn::{
///
/// # Example
/// ```ignore
/// use anchor_lang::prelude::*;
///
/// #[account]
/// #[derive(InitSpace)]
/// pub struct ExampleAccount {
Expand Down
2 changes: 1 addition & 1 deletion lang/src/accounts/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! # Example
//! ```ignore
//! #[derive(Accounts)]
//! pub struct Example {
//! pub struct Example<'info> {
//! pub my_acc: Box<Account<'info, MyData>>
//! }
//! ```
Expand Down
2 changes: 1 addition & 1 deletion lang/src/accounts/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! # Example
//! ```ignore
//! #[derive(Accounts)]
//! pub struct Example {
//! pub struct Example<'info> {
//! pub my_acc: Option<Account<'info, MyData>>
//! }
//! ```
Expand Down
2 changes: 1 addition & 1 deletion lang/src/accounts/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::ops::Deref;
///
/// #[derive(Accounts)]
/// pub struct Example<'info> {
/// #[account(init, payer = payer)]
/// #[account(init, payer = payer, space = 8 + 8)]
/// pub my_acc: Account<'info, MyData>,
/// #[account(mut)]
/// pub payer: Signer<'info>,
Expand Down
3 changes: 3 additions & 0 deletions lang/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,9 @@ macro_rules! require_gte {
/// pub enum MyError {
/// SomeError
/// }
///
/// #[derive(Accounts)]
/// pub struct Example {}
/// ```
#[macro_export]
macro_rules! err {
Expand Down
Loading