-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Use #[doc(fake_variadic)]
to improve docs readability
#14703
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
0, | ||
12, | ||
P | ||
); | ||
|
||
#[cfg(feature = "functions")] | ||
const _: () = { |
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.
Any reason not to include the all_tuples!
usages in this block? I think it should be doable if we modify the internal macros (e.g. impl_get_ownership!
, impl_from_arg!
, and impl_into_return!
).
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 assume because the block is gated by #[cfg(feature = "functions")]
? I'm afraid that I'm the wrong person to answer this question, I saw this code for the first time :)
That's a shame that re-exports don't work. IMO this isn't worth merging until that's fixed here or upstream. |
I may have found the culprit: rust-lang/cargo#8811 [package.metadata.docs.rs]
rustc-args = ["--cfg", "bevy_docsrs"] # not `docsrs` because web-time fails to compile with --cfg docsrs 🤷🏼 Also TIL that https://package.metadata.docs.rs redirects to the correct documentation page, how cool is that? ✨ |
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.
Great use of comments and docs here: explaining why we're doing such a weird thing is really important. Now that re-exports are working I'm happy to merge this! We'll verify this on dev-docs.bevyengine.org before shipping :)
# Objective This PR is a follow-up to #14703. I forgot to also add the flags from `package.metadata.docs.rs` to the docs build. ## Solution As [discussed on Discord](https://discord.com/channels/691052431525675048/1272629407659589663/1272643734260940940), I added the missing flags to `docs.yml`. I also updated `rustc-args` to properly make use of the array (I think the value has to be either a space-separated string *or* an array of strings but not an array of space-separated strings 😆)
…vyengine#14962) # Objective Make the documentation for `SystemParamBuilder` nicer by combining the tuple implementations into a single line of documentation. ## Solution Use `#[doc(fake_variadic)]` for `SystemParamBuilder` tuple impls. ![image](https://github.com/user-attachments/assets/b4665861-c405-467f-b30b-82b4b1d99bf7) (This got missed originally because bevyengine#14050 and bevyengine#14703 were open at the same time.)
Thank you to everyone involved with the authoring or reviewing of this PR! This work is relatively important and needs release notes! Head over to bevyengine/bevy-website#1672 if you'd like to help out. |
Objective
fake_variadic
to improve docs #14697Solution
This PR modifies the existing
all_tuples!
macro to optionally accept a#[doc(fake_variadic)]
attribute in its input. If the attribute is present, each invocation of the impl macro gets the correct attributes (i.e. the first impl receives#[doc(fake_variadic)]
while the other impls are hidden using#[doc(hidden)]
.Impls for the empty tuple (unit type) are left untouched (that's what the standard library and serde do).
To work around rust-lang/cargo#8811 and to get impls on re-exports to correctly show up as variadic,
--cfg docsrs_dep
is passed when building the docs for the toplevelbevy
crate.#[doc(fake_variadic)]
only works on tuples and fn pointers, so impls for structs likeAnyOf<(T1, T2, ..., Tn)>
are unchanged.Testing
I built the docs locally using
RUSTDOCFLAGS='--cfg docsrs' RUSTFLAGS='--cfg docsrs_dep' cargo +nightly doc --no-deps --workspace
and checked the documentation page of a trait both in its original crate and the re-exported version inbevy
.The description should correctly mention for how many tuple items the trait is implemented.
I added
rustc-args
for docs.rs to thebevy
crate, I hope there aren't any other notable crates that re-export#[doc(fake_variadic)]
traits.Showcase
bevy_ecs::query::QueryData
:bevy::ecs::query::QueryData
(re-export):Original Description
Resolves #14697
Submitting as a draft for now, very WIP.
Unfortunately, the docs don't show the variadics nicely when looking at reexported items.
For example:
bevy_ecs::bundle::Bundle
correctly shows the variadic impl:while
bevy::ecs::bundle::Bundle
(the reexport) shows all the impls (not good):Built using
RUSTDOCFLAGS='--cfg docsrs' cargo +nightly doc --workspace --no-deps
(--no-deps
because of wgpu-core).Maybe I missed something or this is a limitation in the totally not private
#[doc(fake_variadic)]
thingy. In any case I desperately need some sleep now :))