Skip to content

Commit b0741d4

Browse files
Finish documenting #[pallet::xxx] macros (#2638)
Closes paritytech/polkadot-sdk-docs#35 - Moves pallet proc macro docs to `frame_support` - Adds missing docs - Revise revise existing docs, adding compiling doctests where appropriate --------- Co-authored-by: command-bot <> Co-authored-by: Kian Paimani <[email protected]>
1 parent cdc8d19 commit b0741d4

File tree

5 files changed

+1127
-1987
lines changed

5 files changed

+1127
-1987
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/sdk/src/guides/your_first_pallet/mod.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,16 @@
250250
// of event is probably not the best.
251251
//!
252252
//! With the explanation out of the way, let's see how these components can be added. Both follow a
253-
//! fairly familiar syntax: normal Rust enums, with an extra `#[frame::event/error]` attribute
254-
//! attached.
253+
//! fairly familiar syntax: normal Rust enums, with extra
254+
//! [`#[frame::event]`](frame::pallet_macros::event) and
255+
//! [`#[frame::error]`](frame::pallet_macros::error) attributes attached.
255256
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", Event)]
256257
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", Error)]
257258
//!
258-
//! One slightly custom part of this is the `#[pallet::generate_deposit(pub(super) fn
259-
//! deposit_event)]` part. Without going into too much detail, in order for a pallet to emit events
260-
//! to the rest of the system, it needs to do two things:
259+
//! One slightly custom part of this is the [`#[pallet::generate_deposit(pub(super) fn
260+
//! deposit_event)]`](frame::pallet_macros::generate_deposit) part. Without going into too
261+
//! much detail, in order for a pallet to emit events to the rest of the system, it needs to do two
262+
//! things:
261263
//!
262264
//! 1. Declare a type in its `Config` that refers to the overarching event type of the runtime. In
263265
//! short, by doing this, the pallet is expressing an important bound: `type RuntimeEvent:
@@ -266,7 +268,8 @@
266268
//! store it where needed.
267269
//!
268270
//! 2. But, doing this conversion and storing is too much to expect each pallet to define. FRAME
269-
//! provides a default way of storing events, and this is what `pallet::generate_deposit` is doing.
271+
//! provides a default way of storing events, and this is what
272+
//! [`pallet::generate_deposit`](frame::pallet_macros::generate_deposit) is doing.
270273
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", config_v2)]
271274
//!
272275
//! > These `Runtime*` types are better explained in
@@ -280,8 +283,9 @@
280283
#![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", runtime_v2)]
281284
//!
282285
//! In this snippet, the actual `RuntimeEvent` type (right hand side of `type RuntimeEvent =
283-
//! RuntimeEvent`) is generated by `construct_runtime`. An interesting way to inspect this type is
284-
//! to see its definition in rust-docs:
286+
//! RuntimeEvent`) is generated by
287+
//! [`construct_runtime`](frame::runtime::prelude::construct_runtime). An interesting way to inspect
288+
//! this type is to see its definition in rust-docs:
285289
//! [`crate::guides::your_first_pallet::pallet_v2::tests::runtime_v2::RuntimeEvent`].
286290
//!
287291
//!

substrate/frame/support/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ aquamarine = { version = "0.5.0" }
6666
[dev-dependencies]
6767
assert_matches = "1.3.0"
6868
pretty_assertions = "1.2.1"
69+
sp-timestamp = { path = "../../primitives/timestamp", default-features = false }
6970
frame-system = { path = "../system" }
7071
sp-crypto-hashing = { path = "../../primitives/crypto/hashing" }
7172

@@ -96,6 +97,7 @@ std = [
9697
"sp-std/std",
9798
"sp-tracing/std",
9899
"sp-weights/std",
100+
"sp-timestamp/std"
99101
]
100102
runtime-benchmarks = [
101103
"frame-system/runtime-benchmarks",

0 commit comments

Comments
 (0)