Browse Source

docs: update doc comments for `Program` and `#[account]` (#1606)

Matthew Callens 3 years ago
parent
commit
041414f52a
2 changed files with 20 additions and 4 deletions
  1. 2 1
      lang/attribute/account/src/lib.rs
  2. 18 3
      lang/src/accounts/program.rs

+ 2 - 1
lang/attribute/account/src/lib.rs

@@ -13,8 +13,9 @@ mod id;
 /// - [`AccountDeserialize`](./trait.AccountDeserialize.html)
 /// - [`AnchorSerialize`](./trait.AnchorSerialize.html)
 /// - [`AnchorDeserialize`](./trait.AnchorDeserialize.html)
-/// - [`Owner`](./trait.Owner.html)
+/// - [`Clone`](https://doc.rust-lang.org/std/clone/trait.Clone.html)
 /// - [`Discriminator`](./trait.Discriminator.html)
+/// - [`Owner`](./trait.Owner.html)
 ///
 /// When implementing account serialization traits the first 8 bytes are
 /// reserved for a unique account discriminator, self described by the first 8

+ 18 - 3
lang/src/accounts/program.rs

@@ -18,14 +18,19 @@ use std::ops::Deref;
 /// if the program is owned by the [`BPFUpgradeableLoader`](https://docs.rs/solana-program/latest/solana_program/bpf_loader_upgradeable/index.html)
 /// and will contain the `programdata_address` property of the `Program` variant of the [`UpgradeableLoaderState`](https://docs.rs/solana-program/latest/solana_program/bpf_loader_upgradeable/enum.UpgradeableLoaderState.html) enum.
 ///
+/// # Table of Contents
+/// - [Basic Functionality](#basic-functionality)
+/// - [Out of the Box Types](#out-of-the-box-types)
+///
+/// # Basic Functionality
+///
 /// Checks:
 ///
-/// - `Account.info.key == Program`
-/// - `Account.info.executable == true`
+/// - `account_info.key == expected_program`
+/// - `account_info.executable == true`
 ///
 /// # Example
 /// ```ignore
-///
 /// #[program]
 /// mod my_program {
 ///     fn set_admin_settings(...){...}
@@ -58,6 +63,16 @@ use std::ops::Deref;
 /// will be `None` if it's not).
 /// - `program_data`'s constraint checks that its upgrade authority is the `authority` account.
 /// - Finally, `authority` needs to sign the transaction.
+///
+/// # Out of the Box Types
+///
+/// Between the [`anchor_lang`](https://docs.rs/anchor-lang/latest/anchor_lang) and [`anchor_spl`](https://docs.rs/anchor_spl/latest/anchor_spl) crates,
+/// the following `Program` types are provided out of the box:
+///
+/// - [`System`](https://docs.rs/anchor-lang/latest/anchor_lang/struct.System.html)
+/// - [`AssociatedToken`](https://docs.rs/anchor-spl/latest/anchor_spl/associated_token/struct.AssociatedToken.html)
+/// - [`Token`](https://docs.rs/anchor-spl/latest/anchor_spl/token/struct.Token.html)
+///
 #[derive(Clone)]
 pub struct Program<'info, T: Id + Clone> {
     info: AccountInfo<'info>,