Skip to content

Incorrect placement of Rustdoc comments on storage variables #2099

@antlerminator

Description

@antlerminator

A LOT of Rustdoc comments on storage variables have incorrect positioning which means external tooling that read the node's metadata has no access to these comments.

Here's a real example straight from the codebase:

// ❌ Example of incorrect Rustdoc
#[pallet::storage] // --- MAP ( netuid ) --> alpha_supply_user_in_pool | Returns the amount of alpha in the pool provided by users as liquidity.
pub type SubnetAlphaInProvided<T: Config> =
    StorageMap<_, Identity, NetUid, AlphaCurrency, ValueQuery, DefaultZeroAlpha<T>>;

// ✅ Example of correct Rustdoc
#[pallet::storage]
/// --- MAP ( netuid ) --> alpha_supply_in_subnet | Returns the amount of alpha in the subnet.
pub type SubnetAlphaOut<T: Config> =
    StorageMap<_, Identity, NetUid, AlphaCurrency, ValueQuery, DefaultZeroAlpha<T>>;

Why it matters? Because correctly placed Rustdoc comments greatly improve the DX of working with Bittensor. Here's an example how the above storage variables look like after types generation in TypeScript:

Image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions