Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

[fix docs compiler warnings] Examples pallets #14669

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

sacha-l
Copy link
Contributor

@sacha-l sacha-l commented Jul 28, 2023

This PR fixes the following 38 compiler warnings when running RUSTFLAGS="-W missing_docs" cargo check -p pallet-examples :

  • pallet-example-offchain-worker (lib) generated 4 warnings
  • pallet-example-kitchensink (lib) generated 11 warnings
  • pallet-example-basic (lib) generated 13 warnings
  • pallet-dev-mode (lib) generated 6 warnings
  • pallet-example-split (lib) generated 4 warnings

@sacha-l sacha-l added A2-insubstantial Pull request requires no code review (e.g., a sub-repository hash update). I6-documentation Documentation needs fixing, improving or augmenting. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Jul 28, 2023
@sacha-l sacha-l requested review from sam0x17, kianenigma, gupnik and a team July 28, 2023 09:20
Copy link
Contributor

@gupnik gupnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@sacha-l sacha-l requested a review from ggwpez July 31, 2023 15:35
@sacha-l
Copy link
Contributor Author

sacha-l commented Jul 31, 2023

CI fails now because:

error: could not compile `pallet-example-offchain-worker` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...
error: missing documentation for an associated function
  --> frame/examples/dev-mode/src/lib.rs:45:1
   |
45 | #[frame_support::pallet(dev_mode)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: the lint level is defined here
  --> frame/examples/dev-mode/src/lib.rs:28:9
   |
28 | #![deny(missing_docs)]
   |         ^^^^^^^^^^^^
   = note: this error originates in the attribute macro `frame_support::pallet` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `pallet-dev-mode` (lib) due to previous error
error: missing documentation for an associated function
  --> frame/examples/kitchensink/src/lib.rs:46:1
   |
46 | #[frame_support::pallet]
   | ^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: the lint level is defined here
  --> frame/examples/kitchensink/src/lib.rs:28:9
   |
28 | #![deny(missing_docs)]
   |         ^^^^^^^^^^^^
   = note: this error originates in the attribute macro `frame_support::pallet` (in Nightly builds, run with -Z macro-backtrace for more info)

error: missing documentation for an associated function
   --> frame/examples/kitchensink/src/lib.rs:235:29
    |
235 |     #[pallet::generate_deposit(pub fn deposit_event)]
    |   

@sam0x17 any advice on how we may be able to fix this?

@sam0x17
Copy link
Contributor

sam0x17 commented Jul 31, 2023

@sam0x17 any advice on how we may be able to fix this?

This is likely some item in the expansion of dev_mode that does not come with built-in doc comments. I will poke around and see what I can find but feel free to jump in @gupnik

@sam0x17
Copy link
Contributor

sam0x17 commented Jul 31, 2023

So glancing through the dev mode implementation I didn't catch any undocumented items slipping through. Could you open the docs on the item it is complaining about @sacha-l and see if there is an undocumented associated function in the rust docs for that item and if so what it is?

@sacha-l
Copy link
Contributor Author

sacha-l commented Jul 31, 2023

I think this is related to the same reasons the I wasn't able to fix the warnings mentioned here.

Could you open the docs on the item it is complaining about @sacha-l and see if there is an undocumented associated function in the rust docs for that item and if so what it is?

After running RUSTFLAGS="-W missing_docs" cargo check -p frame-system I can see there are 22 warnings emitted. Do you think addressing those will fix this?

What I don't understand is with Rust analyzer running I'm able to verify that the docs for deposit_event are coming through. But the compiler is still complaining about them not existing.

Screenshot 2023-07-31 at 5 26 18 PM

Same for the pallet macro:

Screenshot 2023-07-31 at 5 56 37 PM

When I hover over the dev_mode item though, no docs show up at all.

@gupnik
Copy link
Contributor

gupnik commented Aug 1, 2023

@sacha-l @sam0x17 I think the docs for calls were missing. I have added some in pallet-dev-mode and the check seems to succeed. We will probably need to add the same for other crates as well.

Copy link
Contributor

@sam0x17 sam0x17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome good find. I didn't realize the problem was specifically with the dev mode pallet example -- I went digging in dev mode expansion to find stuff that might be missing docs in the expansion (for all dev mode pallets) but lol

Thanks!!!!

@sacha-l
Copy link
Contributor Author

sacha-l commented Aug 1, 2023

@sacha-l @sam0x17 I think the docs for calls were missing. I have added some in pallet-dev-mode and the check seems to succeed. We will probably need to add the same for other crates as well.

Thanks ! Applying these fixes to the other pallet lib.rs files.

@@ -301,11 +315,14 @@ pub mod pallet {
#[pallet::validate_unsigned]
impl<T: Config> ValidateUnsigned for Pallet<T> {
type Call = Call<T>;
fn validate_unsigned(_: TransactionSource, _: &Self::Call) -> TransactionValidity {

/// Validates an unsigned transaction.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trait functions should not be documented, the trait definition itself should be.

@@ -242,19 +244,18 @@ pub mod pallet {
/// Submit new price to the list via unsigned transaction.
///
/// Works exactly like the `submit_price` function, but since we allow sending the
/// transaction without a signature, and hence without paying any fees,
/// we need a way to make sure that only some transactions are accepted.
/// This function can be called only once every `T::UnsignedInterval` blocks.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you find a linter that will prohibit people from immaturely wrapping their lines early, I will indefinitely be grateful of you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you find a linter that will prohibit people from immaturely wrapping their lines early, I will indefinitely be grateful of you.

💯

@sacha-l
Copy link
Contributor Author

sacha-l commented Aug 15, 2023

bot rebase

@paritytech-processbot
Copy link

Rebased

@sacha-l
Copy link
Contributor Author

sacha-l commented Aug 18, 2023

bot rebase

@paritytech-processbot
Copy link

Rebased

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: cargo-check-benches
Logs: https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/3412671

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A2-insubstantial Pull request requires no code review (e.g., a sub-repository hash update). B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit I6-documentation Documentation needs fixing, improving or augmenting.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants