Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes doc links for procedural crate #5023

Merged
merged 25 commits into from
Jul 22, 2024
Merged

Fixes doc links for procedural crate #5023

merged 25 commits into from
Jul 22, 2024

Conversation

gupnik
Copy link
Contributor

@gupnik gupnik commented Jul 16, 2024

This PR fixes the documentation for FRAME Macros when pointed from polkadot_sdk_docs crate. This is achieved by referring to the examples in the procedural crate, embedded via docify.

@gupnik gupnik added the R0-silent Changes should not be mentioned in any release notes label Jul 16, 2024
@gupnik gupnik requested a review from a team as a code owner July 16, 2024 05:48
Copy link
Contributor

@gui1117 gui1117 left a comment

Choose a reason for hiding this comment

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

This is great, that mean all the macro doc can be moved from support to support-procedural isn't it 🤯

/// However, if `no_aggregated_types` is specified while using
/// [`#[derive_impl(..)]`](macro@derive_impl), then these items are attached verbatim to the
/// combined impl.
#[doc = docify::embed!("examples/inject_runtime_type.rs", derive_impl_works_with_no_aggregated_types)]
Copy link
Contributor

Choose a reason for hiding this comment

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

As a sidenote I find it a bit unfortunate that there is no button to click on to access the underlying file.

If there was a source button it would be great IMO.

@bkchr
Copy link
Member

bkchr commented Jul 16, 2024

This is great, that mean all the macro doc can be moved from support to support-procedural isn't it 🤯

But this still doesn't work for traits declared in frame-support.

@gupnik
Copy link
Contributor Author

gupnik commented Jul 16, 2024

This is great, that mean all the macro doc can be moved from support to support-procedural isn't it 🤯

But this still doesn't work for traits declared in frame-support.

Could you expand this on a bit please? Since frame-support is added as a dev-dependency, we are able to use it in tests which are then embedded via docify. Let me know if I misunderstood.

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: test-linux-stable 2/3
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6704585

@gui1117
Copy link
Contributor

gui1117 commented Jul 16, 2024

This is great, that mean all the macro doc can be moved from support to support-procedural isn't it 🤯

But this still doesn't work for traits declared in frame-support.

I tried, it seems pallet macro work in doc tests (even without docify), but runtime macro doesn't:

error[E0433]: failed to resolve: could not find `sp_api_hidden_includes_construct_runtime` in the crate root
  --> substrate/frame/support/procedural/src/lib.rs:287:1
   |
13 | #[frame_support::runtime]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^ could not find `sp_api_hidden_includes_construct_runtime` in the crate root

But runtime macro could be fixed by using the same import style as pallet macro.

Maybe they changed the environment for doc test so that pallet is now successful.
Or maybe I always mistaken.

@kianenigma
Copy link
Contributor

  • have tried the RA experience? If you hover over a macro now, it will show the right one? a screenshot would be nice
  • have you tried the situation where if you link from, for example a reference docs, to frame::pallet_macros::task using Rust's auto link resolved, it jumps to the right destination?

If yes to both, then it is green IMO.

Can you migrate the rest as well? and please take this as an opportunity and read the existing macro docs, and improve them if anything comes to mind.

These docs are not even more on the spotlight, as they are easily accessible via any IDE, and are the first thing that a developer will see once writing a pallet.

@gupnik
Copy link
Contributor Author

gupnik commented Jul 19, 2024

have tried the RA experience? If you hover over a macro now, it will show the right one? a screenshot would be nice

Yes, PFA. Note that docify examples are not visible in the hover experience. Probably something to dig further at some point.

Screenshot 2024-07-19 at 5 07 57 PM

have you tried the situation where if you link from, for example a reference docs, to frame::pallet_macros::task using Rust's auto link resolved, it jumps to the right destination?

Yes.

Can you migrate the rest as well? and please take this as an opportunity and read the existing macro docs, and improve them if anything comes to mind.

Yes, but I would prefer to do it in a separate PR.

Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

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

great stuff

@kianenigma kianenigma enabled auto-merge July 22, 2024 09:21
@kianenigma kianenigma added this pull request to the merge queue Jul 22, 2024
Merged via the queue into master with commit d0d8e29 Jul 22, 2024
157 of 159 checks passed
@kianenigma kianenigma deleted the gupnik/proc-examples branch July 22, 2024 10:41
TarekkMA pushed a commit to moonbeam-foundation/polkadot-sdk that referenced this pull request Aug 2, 2024
This PR fixes the documentation for FRAME Macros when pointed from
`polkadot_sdk_docs` crate. This is achieved by referring to the examples
in the `procedural` crate, embedded via `docify`.

---------

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R0-silent Changes should not be mentioned in any release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants