-
Notifications
You must be signed in to change notification settings - Fork 746
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
Switch proc macro docs to be on re-exports so we can have doc links to outer crate items #247
Comments
IMO the primary goal should be there to have proper |
The pre-#12334 structure was that all of the paritytech/substrate#12334 introduced stubs for these macros with effectively duplicated docs from the Currently, the version of the docs that is on the IMO this is the best compromise dev UX-wise until In the interim while we wait for I'm watching this closely and just want to keep this issue open until |
I don't assume that |
Right but we already did the copy that was part of paritytech/substrate#12334 so we should be good for now just wanted to describe this issue somewhere |
#1689) Small tweak to #1642 to incorporate the ideas from #247. I think this is the good middle ground, where we have good rust-docs, and the RA users will also have some hope. cc @wentelteefje @aaronbassett @sam0x17
paritytech#1689) Small tweak to paritytech#1642 to incorporate the ideas from paritytech#247. I think this is the good middle ground, where we have good rust-docs, and the RA users will also have some hope. cc @wentelteefje @aaronbassett @sam0x17
Right now the frame proc macros (especially the
pallet::
ones) follow the pattern of documenting proc macros inside their corresponding inner proc macro crates (i.e.frame_support_procedural
). I standardized this in a number of places in paritytech/substrate#12333 / paritytech/substrate#12334.A major reason for this is tools like
rust-analyzer
right now do not conform with thecargo doc
behavior of prepending docs that are attached to re-exported items (i.e. macros, functions, traits, etc) and in fact completely ignore docs on re-exports (see my companion issue inrust-analyzer
: rust-lang/rust-analyzer#13431).This is why in paritytech/substrate#12334 I ended up switching all of the
pallet::
macros to have their docs insideframe_support_procedural
because thenrust-analyzer
will actually pick them up upon mouse-over.The problem with this is inner crates can only generate doc links to items that are visible from the inner crate. For non-proc-macro crates the workaround is easy -- simply set up a circular reference between the inner crate and the outer crate so the outer crate items are visible/linkable from the inner crate. This doesn't work for proc macro crates, however, because rust restricts proc macro crates so that they are only allowed to publicly export proc macros (no other items are allowed), so even if we
pub use outer_crate::*
to make all the outer crate's items accessible within the inner crate, this will fail to compile since we are trying to export something other than a proc macro in a proc macro crate.Thus we are at a bit of a stand-still. Ideally
rust-analyzer
would handle docs on re-exports properly the waycargo doc
does and we would switch to only documenting proc macros where their re-exports are defined in the outer crate.So this is blocked until rust-lang/rust-analyzer#13431 is addressed in
rust-analyzer
or some other solution (like better support for inter-crate doc linking) is added to rust.One possible alternative solution would be to link directly to the docs.rs links for the outer items from the inner macro declarations. This has some obvious downsides (like
rust-analyzer
will open a web browser instead of following the links inline), but if this issue sits for a long period of time this might be the way to go.Note: the one thing I haven't tried is trying to
pub use
the outer crate items in the inner proc macro crate while gating this with a#[cfg(doc)]
directive. I doubt it will compile but it's the only thing I haven't tried so would be cool if someone could confirm (or if someone knows) that this doesn't work.Related Issues
Related PRs
The text was updated successfully, but these errors were encountered: