Skip to content

[DRAFT] deny(missing_docs) for bevy_asset #19739

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/bevy_asset/src/io/embedded/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! TODO

#[cfg(feature = "embedded_watcher")]
mod embedded_watcher;

Expand Down Expand Up @@ -139,6 +141,7 @@ impl EmbeddedAssetRegistry {
///
/// [`load_embedded_asset!`]: crate::load_embedded_asset
pub trait GetAssetServer {
/// TODO
fn get_asset_server(&self) -> &AssetServer;
}
impl GetAssetServer for App {
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_asset/src/io/file/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! TODO

#[cfg(feature = "file_watcher")]
mod file_watcher;

Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_asset/src/io/gated.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! TODO
//!
use crate::io::{AssetReader, AssetReaderError, PathStream, Reader};
use alloc::{boxed::Box, sync::Arc};
use bevy_platform::collections::HashMap;
Expand Down
15 changes: 15 additions & 0 deletions crates/bevy_asset/src/io/memory.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! TODO

use crate::io::{AssetReader, AssetReaderError, PathStream, Reader};
use alloc::{borrow::ToOwned, boxed::Box, sync::Arc, vec::Vec};
use bevy_platform::collections::HashMap;
Expand Down Expand Up @@ -31,14 +33,17 @@ impl Dir {
})))
}

/// TODO
pub fn insert_asset_text(&self, path: &Path, asset: &str) {
self.insert_asset(path, asset.as_bytes().to_vec());
}

/// TODO
pub fn insert_meta_text(&self, path: &Path, asset: &str) {
self.insert_meta(path, asset.as_bytes().to_vec());
}

/// TODO
pub fn insert_asset(&self, path: &Path, value: impl Into<Value>) {
let mut dir = self.clone();
if let Some(parent) = path.parent() {
Expand All @@ -63,6 +68,7 @@ impl Dir {
dir.0.write().assets.remove(&key)
}

/// TODO
pub fn insert_meta(&self, path: &Path, value: impl Into<Value>) {
let mut dir = self.clone();
if let Some(parent) = path.parent() {
Expand All @@ -77,6 +83,7 @@ impl Dir {
);
}

/// TODO
pub fn get_or_insert_dir(&self, path: &Path) -> Dir {
let mut dir = self.clone();
let mut full_path = PathBuf::new();
Expand All @@ -94,6 +101,7 @@ impl Dir {
dir
}

/// TODO
pub fn get_dir(&self, path: &Path) -> Option<Dir> {
let mut dir = self.clone();
for p in path.components() {
Expand All @@ -104,6 +112,7 @@ impl Dir {
Some(dir)
}

/// TODO
pub fn get_asset(&self, path: &Path) -> Option<Data> {
let mut dir = self.clone();
if let Some(parent) = path.parent() {
Expand All @@ -114,6 +123,7 @@ impl Dir {
.and_then(|f| dir.0.read().assets.get(f.to_str().unwrap()).cloned())
}

/// TODO
pub fn get_metadata(&self, path: &Path) -> Option<Data> {
let mut dir = self.clone();
if let Some(parent) = path.parent() {
Expand All @@ -124,11 +134,13 @@ impl Dir {
.and_then(|f| dir.0.read().metadata.get(f.to_str().unwrap()).cloned())
}

/// TODO
pub fn path(&self) -> PathBuf {
self.0.read().path.to_owned()
}
}

/// TODO
pub struct DirStream {
dir: Dir,
index: usize,
Expand Down Expand Up @@ -176,6 +188,7 @@ impl Stream for DirStream {
/// This is primarily intended for unit tests.
#[derive(Default, Clone)]
pub struct MemoryAssetReader {
/// TODO
pub root: Dir,
}

Expand All @@ -189,7 +202,9 @@ pub struct Data {
/// Stores either an allocated vec of bytes or a static array of bytes.
#[derive(Clone, Debug)]
pub enum Value {
/// TODO
Vec(Arc<Vec<u8>>),
/// TODO
Static(&'static [u8]),
}

Expand Down
27 changes: 24 additions & 3 deletions crates/bevy_asset/src/io/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! TODO

#[cfg(all(feature = "file_watcher", target_arch = "wasm32"))]
compile_error!(
"The \"file_watcher\" feature for hot reloading does not work \
Expand Down Expand Up @@ -135,6 +137,7 @@ pub trait AsyncSeekForwardExt: AsyncSeekForward {

impl<R: AsyncSeekForward + ?Sized> AsyncSeekForwardExt for R {}

/// TODO
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct SeekForwardFuture<'a, S: Unpin + ?Sized> {
Expand Down Expand Up @@ -188,6 +191,7 @@ impl Reader for Box<dyn Reader + '_> {
pub trait AssetReaderFuture:
ConditionalSendFuture<Output = Result<Self::Value, AssetReaderError>>
{
/// TODO
type Value;
}

Expand Down Expand Up @@ -326,8 +330,10 @@ impl<T: AssetReader> ErasedAssetReader for T {
}
}

/// TODO
pub type Writer = dyn AsyncWrite + Unpin + Send + Sync;

/// TODO
pub type PathStream = dyn Stream<Item = PathBuf> + Unpin + Send;

/// Errors that occur while loading assets.
Expand Down Expand Up @@ -583,21 +589,36 @@ pub enum AssetSourceEvent {
/// An asset at this path was removed.
RemovedAsset(PathBuf),
/// An asset at this path was renamed.
RenamedAsset { old: PathBuf, new: PathBuf },
RenamedAsset {
/// TODO
old: PathBuf,
/// TODO
new: PathBuf
},
/// Asset metadata at this path was added.
AddedMeta(PathBuf),
/// Asset metadata at this path was modified.
ModifiedMeta(PathBuf),
/// Asset metadata at this path was removed.
RemovedMeta(PathBuf),
/// Asset metadata at this path was renamed.
RenamedMeta { old: PathBuf, new: PathBuf },
RenamedMeta {
/// TODO
old: PathBuf,
/// TODO
new: PathBuf
},
/// A folder at the given path was added.
AddedFolder(PathBuf),
/// A folder at the given path was removed.
RemovedFolder(PathBuf),
/// A folder at the given path was renamed.
RenamedFolder { old: PathBuf, new: PathBuf },
RenamedFolder {
/// TODO
old: PathBuf,
/// TODO
new: PathBuf
},
/// Something of unknown type was removed. It is the job of the event handler to determine the type.
/// This exists because notify-rs produces "untyped" rename events without destination paths for unwatched folders, so we can't determine the type of
/// the rename.
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_asset/src/io/processor_gated.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! TODO

use crate::{
io::{AssetReader, AssetReaderError, AssetSourceId, PathStream, Reader},
processor::{AssetProcessorData, ProcessStatus},
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@
//! If you want to save your assets back to disk, you should implement [`AssetSaver`](saver::AssetSaver) as well.
//! This trait mirrors [`AssetLoader`] in structure, and works in tandem with [`AssetWriter`](io::AssetWriter), which mirrors [`AssetReader`](io::AssetReader).

#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(
html_logo_url = "https://bevy.org/assets/icon.png",
Expand Down Expand Up @@ -455,6 +454,7 @@ pub trait AsAssetId: Component {
///
/// Note that this trait is automatically implemented when deriving [`Asset`].
pub trait VisitAssetDependencies {
/// TODO
fn visit_dependencies(&self, visit: &mut impl FnMut(UntypedAssetId));
}

Expand Down
15 changes: 15 additions & 0 deletions crates/bevy_asset/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ impl ErasedLoadedAsset {

/// A type erased container for an [`Asset`] value that is capable of inserting the [`Asset`] into a [`World`]'s [`Assets`] collection.
pub trait AssetContainer: Downcast + Any + Send + Sync + 'static {
/// TODO
fn insert(self: Box<Self>, id: UntypedAssetId, world: &mut World);
/// TODO
fn asset_type_name(&self) -> &'static str;
}

Expand All @@ -291,20 +293,26 @@ impl<A: Asset> AssetContainer for A {
/// [immediately]: crate::Immediate
#[derive(Error, Debug)]
pub enum LoadDirectError {
/// TODO
#[error("Requested to load an asset path ({0:?}) with a subasset, but this is unsupported. See issue #18291")]
RequestedSubasset(AssetPath<'static>),
/// TODO
#[error("Failed to load dependency {dependency:?} {error}")]
LoadError {
/// TODO
dependency: AssetPath<'static>,
/// TODO
error: AssetLoadError,
},
}

/// An error that occurs while deserializing [`AssetMeta`].
#[derive(Error, Debug, Clone, PartialEq, Eq)]
pub enum DeserializeMetaError {
/// TODO
#[error("Failed to deserialize asset meta: {0:?}")]
DeserializeSettings(#[from] SpannedError),
/// TODO
#[error("Failed to deserialize minimal asset meta: {0:?}")]
DeserializeMinimal(SpannedError),
}
Expand Down Expand Up @@ -568,20 +576,27 @@ impl<'a> LoadContext<'a> {
/// An error produced when calling [`LoadContext::read_asset_bytes`]
#[derive(Error, Debug)]
pub enum ReadAssetBytesError {
/// TODO
#[error(transparent)]
DeserializeMetaError(#[from] DeserializeMetaError),
/// TODO
#[error(transparent)]
AssetReaderError(#[from] AssetReaderError),
/// TODO
#[error(transparent)]
MissingAssetSourceError(#[from] MissingAssetSourceError),
/// TODO
#[error(transparent)]
MissingProcessedAssetReaderError(#[from] MissingProcessedAssetReaderError),
/// Encountered an I/O error while loading an asset.
#[error("Encountered an io error while loading asset at `{}`: {source}", path.display())]
Io {
/// TODO
path: PathBuf,
/// TODO
source: std::io::Error,
},
/// TODO
#[error("The LoadContext for this read_asset_bytes call requires hash metadata, but it was not provided. This is likely an internal implementation error.")]
MissingAssetHash,
}
28 changes: 26 additions & 2 deletions crates/bevy_asset/src/meta.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! TODO

use alloc::{
boxed::Box,
string::{String, ToString},
Expand All @@ -13,7 +15,10 @@ use ron::ser::PrettyConfig;
use serde::{Deserialize, Serialize};
use tracing::error;

/// TODO
pub const META_FORMAT_VERSION: &str = "1.0";

/// TODO
pub type MetaTransform = Box<dyn Fn(&mut dyn AssetMetaDyn) + Send + Sync>;

/// Asset metadata that informs how an [`Asset`] should be handled by the asset system.
Expand All @@ -36,6 +41,7 @@ pub struct AssetMeta<L: AssetLoader, P: Process> {
}

impl<L: AssetLoader, P: Process> AssetMeta<L, P> {
/// TODO
pub fn new(asset: AssetAction<L::Settings, P::Settings>) -> Self {
Self {
meta_format_version: META_FORMAT_VERSION.to_string(),
Expand All @@ -56,15 +62,19 @@ pub enum AssetAction<LoaderSettings, ProcessSettings> {
/// Load the asset with the given loader and settings
/// See [`AssetLoader`].
Load {
/// TODO
loader: String,
/// TODO
settings: LoaderSettings,
},
/// Process the asset with the given processor and settings.
/// See [`Process`] and [`AssetProcessor`].
///
/// [`AssetProcessor`]: crate::processor::AssetProcessor
Process {
/// TODO
processor: String,
/// TODO
settings: ProcessSettings,
},
/// Do nothing with the asset
Expand All @@ -89,7 +99,9 @@ pub struct ProcessedInfo {
/// has changed.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ProcessDependencyInfo {
/// TODO
pub full_hash: AssetHash,
/// TODO
pub path: AssetPath<'static>,
}

Expand All @@ -101,22 +113,33 @@ pub struct ProcessDependencyInfo {
// using a type registry.
#[derive(Serialize, Deserialize)]
pub struct AssetMetaMinimal {
/// TODO
pub asset: AssetActionMinimal,
}

/// This is a minimal counterpart to [`AssetAction`] that exists to speed up (or enable) serialization in cases where the whole [`AssetAction`]
/// isn't necessary.
#[derive(Serialize, Deserialize)]
pub enum AssetActionMinimal {
Load { loader: String },
Process { processor: String },
/// TODO
Load {
/// TODO
loader: String
},
/// TODO
Process {
/// TODO
processor: String
},
/// TODO
Ignore,
}

/// This is a minimal counterpart to [`ProcessedInfo`] that exists to speed up serialization in cases where the whole [`ProcessedInfo`] isn't
/// necessary.
#[derive(Serialize, Deserialize)]
pub struct ProcessedInfoMinimal {
/// TODO
pub processed_info: Option<ProcessedInfo>,
}

Expand Down Expand Up @@ -238,6 +261,7 @@ pub(crate) fn loader_settings_meta_transform<S: Settings>(
Box::new(move |meta| meta_transform_settings(meta, &settings))
}

/// TODO
pub type AssetHash = [u8; 32];

/// NOTE: changing the hashing logic here is a _breaking change_ that requires a [`META_FORMAT_VERSION`] bump.
Expand Down
Loading
Loading