subtensor icon indicating copy to clipboard operation
subtensor copied to clipboard

Incorrect placement of Rustdoc comments on storage variables

Open antlerminator opened this issue 1 year ago • 1 comments

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

antlerminator avatar Oct 02 '25 19:10 antlerminator

I agree with you. I use the polkadot api, the doc is missing or wrong for some storage. will create a PR to fix it.

open-junius avatar Oct 20 '25 07:10 open-junius