Skip to content

Fill out some missing docs for bevy_assets #17829

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

Merged
merged 2 commits into from
Feb 13, 2025

Conversation

alice-i-cecile
Copy link
Member

Objective

bevy_assets has long been unapproachable for contributors and users. More and better documentation would help that.

We're gradually moving towards globally denying missing docs (#3492)!
However, writing all of the hundreds of missing doc strings in a single go will be miserable to review.

Solution

Remove the allow for missing docs temporarily, and then pick some easy missing doc warnings largely at random to tackle.

Stop when the change set is starting to feel intimidating.

@alice-i-cecile alice-i-cecile added C-Docs An addition or correction to our documentation A-Assets Load files from disk to use for things like images, models, and sounds S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 12, 2025
@alice-i-cecile alice-i-cecile added X-Uncontroversial This work is generally agreed upon D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Feb 12, 2025
Copy link
Contributor

@andriyDev andriyDev left a comment

Choose a reason for hiding this comment

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

Looks good!

@alice-i-cecile
Copy link
Member Author

@Carter0, want to take a look at this PR too?

@@ -26,15 +26,20 @@ pub enum AssetId<A: Asset> {
///
/// [`Assets`]: crate::Assets
Index {
/// The unstable, opaque index of the asset.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment sent me down a giant rabbit whole lol.

I get that opaque means that there is some data known to the compiler but not to the user. I don't really know what unstable means in this context though.

Maybe it's worth linking to the AssetIndex struct for users to read more?

Copy link
Contributor

Choose a reason for hiding this comment

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

Opaque means you can't "see inside" it, or e.g. do arithmetic with it, but only use it by giving it to APIs. The compiler helps us enforce this but that's not a requirement for using the term.

Unstable means you can't expect to get the same index between restarts of the application, so it doesn't make sense to serialize it for example.

In all cases I can think of where doc links are rendered you'd also have the type right there, so a link is probably redundant.

@@ -24,6 +24,7 @@ pub struct EmbeddedWatcher {
}

impl EmbeddedWatcher {
/// Creates a new `EmbeddedWatcher` that watches for changes to the embedded assets in the given `dir`.
Copy link
Contributor

@Carter0 Carter0 Feb 13, 2025

Choose a reason for hiding this comment

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

I don't really think you need this. The comment above the struct is better. I guess you might want it for the future lints though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah this is lint-proofing.

@@ -15,6 +15,8 @@ use std::path::{Path, PathBuf};
#[cfg(feature = "embedded_watcher")]
use alloc::borrow::ToOwned;

/// The name of the `embedded` [`AssetSource`],
/// as stored in the [`AssetSourceBuilders`] resource.
pub const EMBEDDED: &str = "embedded";
Copy link
Contributor

@Carter0 Carter0 Feb 13, 2025

Choose a reason for hiding this comment

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

What does "embedding" an asset in this context mean? I looked at the example and it didn't really explain it either.

Copy link
Contributor

Choose a reason for hiding this comment

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

It means putting the asset inside the game executable file, in contrast to other assets that are normally loaded from disk to memory when needed. It's normally only used for small engine-related assets so you can use them without having them in your own asset directory.

It sounds like the example could use a line or 2 describing that.

pub watcher: Option<
Box<
dyn FnMut(crossbeam_channel::Sender<AssetSourceEvent>) -> Option<Box<dyn AssetWatcher>>
+ Send
+ Sync,
>,
>,
/// The [`ErasedAssetReader`] to use for processed assets.
Copy link
Contributor

@Carter0 Carter0 Feb 13, 2025

Choose a reason for hiding this comment

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

Might be worth linking to this somewhere? That way people know what processing is. https://github.com/bevyengine/bevy/blob/main/crates/bevy_asset/src/processor/mod.rs

@@ -32,8 +32,10 @@ pub struct ProcessorTransactionLog {
/// An error that occurs when reading from the [`ProcessorTransactionLog`] fails.
#[derive(Error, Debug)]
Copy link
Contributor

@Carter0 Carter0 Feb 13, 2025

Choose a reason for hiding this comment

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

Also might be worth linking to this above the ProcessorTransactionLog
struct. https://github.com/bevyengine/bevy/blob/main/crates/bevy_asset/src/processor/mod.rs

Copy link
Contributor

@Carter0 Carter0 left a comment

Choose a reason for hiding this comment

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

As a new user to the bevy_assets crate, there is a lot of docs here for fields in structs. That's good and I think that its a step towards requiring docs in the lints, which is also good!

Personally though, I find the docs over the small stuff is only useful if you already know the big picture stuff. Thats why I like links to the big docs in mod files or above structs because its a place for people like me to learn the concept first, then dig into the specifics.

Idk if Bevy has a documentation roadmap or plan already. Documentation is hard because there are several different kinds of documentation and they all serve different purposes.

Anyway, Thanks for doing this and I do like it!

Copy link
Contributor

@fjkorf fjkorf left a comment

Choose a reason for hiding this comment

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

These doc strings make sense to me.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 13, 2025
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 13, 2025
Merged via the queue into bevyengine:main with commit 0f1c757 Feb 13, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Docs An addition or correction to our documentation D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants