-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Pallet dispatchable+storage doc module. #13341
Conversation
Figuring out how we want to handle generics in fn signatures in pallets aka situations like this: #[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::force_transfer())]
pub fn force_transfer(
origin: OriginFor<T>,
source: AccountIdLookupOf<T>,
dest: AccountIdLookupOf<T>,
#[pallet::compact] value: T::Balance,
) -> DispatchResultWithPostInfo { are causing this error:
As far as I can tell that is the only outstanding thing not working |
Maybe put a
and then we export |
This clearly requires some screenshots on how that looks in the docs. I'm not 100% sure that adding fake items to the docs is such a great idea. |
Did you tried using But with the calls people will then not know how to use them. From the docs it looks like there is some module, which doesn't really exists 🤷 |
Yeah in that case I think the current solution is the best compromise because at least it points them to the right place for the types. As far as accessibility, I will add a comment saying these types and functions are available on the pallet itself or something to that effect |
Suggestion: For each dispatchable, link to the actually function in For storage items, I think this is great and already a massive improvement. I will try and help a bit with the auto-generated documents, making sure they are not confusing, especially for the dispatch stuff. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a good step forward, but perhaps we can chose the doc strings a bit better.
Can't approve as I opened the PR, but has my blessing.
Hmm I wonder if we could instead just add the docs to the Call enum variants as an alternative to the dispatchables module? thoughts? |
As with everything doc-related, it's hard to give comments if we don't know how it looks like on the UI, especially when it is about grouping similar items together, which is what the entire underlying issue is about. |
I still haven't seen how the docs on the enum variants look like, but I'm assuming it's similar to https://docs.rs/syn/latest/syn/enum.Type.html, in which case, it's clearly an improvement. We might want to write some doc comments on the Call enum itself so that people know how to click into it and look for docs on the dispatchables. |
Yeah I haven't seen it yet either as it will require moving parts of the macro around to a whole different part of the pallet expansion. And yeah, I think this would be better dev UX since the |
I guess the intent though of what @kianenigma was doing with the dispatchables was to render them in the docs as actual functions instead of enum variants. Given that, I think it might be better to leave it the way he set it up, but I'm going to add doc links to the actual variants like he suggested on each one |
Have also added a revamp of the very ugly |
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much better now, thanks!
@KiChjang this should be good for a final look now, screenshots at the top are updated |
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Bastian Köcher <git@kchr.de>
bot rebase |
Rebased |
bot merge |
* doc-only pallet * cargo fmt * generics fix for dispatchables * use a module instead * add doc comment warning that the dispatchable functions are generated * clean up * fix typo * hide Instance4-Instance16 from `pallet` module docs * revamp Instance1-16 comment * Document storage types Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * remove unused variables * crate::Call => Call Co-authored-by: Bastian Köcher <git@kchr.de> * fix indentation Co-authored-by: Bastian Köcher <git@kchr.de> * remove unneeded block Co-authored-by: Bastian Köcher <git@kchr.de> * don't need a Vec Co-authored-by: Bastian Köcher <git@kchr.de> * add "doc only" to coment Co-authored-by: Bastian Köcher <git@kchr.de> * crate::Call => Call Co-authored-by: Bastian Köcher <git@kchr.de> * cargo fmt --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Sam Johnson <sam@durosoft.com> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: parity-processbot <>
* doc-only pallet * cargo fmt * generics fix for dispatchables * use a module instead * add doc comment warning that the dispatchable functions are generated * clean up * fix typo * hide Instance4-Instance16 from `pallet` module docs * revamp Instance1-16 comment * Document storage types Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * remove unused variables * crate::Call => Call Co-authored-by: Bastian Köcher <git@kchr.de> * fix indentation Co-authored-by: Bastian Köcher <git@kchr.de> * remove unneeded block Co-authored-by: Bastian Köcher <git@kchr.de> * don't need a Vec Co-authored-by: Bastian Köcher <git@kchr.de> * add "doc only" to coment Co-authored-by: Bastian Köcher <git@kchr.de> * crate::Call => Call Co-authored-by: Bastian Köcher <git@kchr.de> * cargo fmt --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Sam Johnson <sam@durosoft.com> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: parity-processbot <>
hopefully closes #12398, but needs more work.
step toward #13299
Description
The goal of this PR is to make docs for dispatchables and storages on pallets more accessible and discoverable when browsing the generated docs. The PR accomplishes this by adding two auto-generated modules to all pallets:
dispatchables
andstorage_types
. These modules are only produced when building docs and otherwise do not exist or interfere with pallets. Thestorage_types
module is auto-populated with documented structs representing each storage type from the parent pallet. Thedispatchables
module is auto-populated with uncallable auto-generated functions matching the signature of eachCall
variant. Right now a link to the correspondingCall
enum variant is also included, though this may be removed. A note is included specifying that these cannot be called and are doc-only.Modules added to
pallet
module:Detail view of
storage_types
module:Detail view of of
dispatchables
module:Detail view of a particular dispatchable:
Also hides docs for
Instance2
-Instance16
on thepallet
module and adds a doc comment toInstance1
explaining this: