Skip to content

Fix doc link import style to avoid unused_imports #15337

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
Sep 21, 2024
Merged
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
41 changes: 19 additions & 22 deletions crates/bevy_asset/src/io/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ use thiserror::Error;

use super::{ErasedAssetReader, ErasedAssetWriter};

#[allow(unused_imports, reason = "Needed for documentation links.")]
use crate::io::{AssetReader, AssetWriter};

/// A reference to an "asset source", which maps to an [`AssetReader`] and/or [`AssetWriter`].
/// A reference to an "asset source", which maps to an [`AssetReader`](crate::io::AssetReader) and/or [`AssetWriter`](crate::io::AssetWriter).
///
/// * [`AssetSourceId::Default`] corresponds to "default asset paths" that don't specify a source: `/path/to/asset.png`
/// * [`AssetSourceId::Name`] corresponds to asset paths that _do_ specify a source: `remote://path/to/asset.png`, where `remote` is the name.
Expand Down Expand Up @@ -126,7 +123,7 @@ impl<'a> PartialEq for AssetSourceId<'a> {
}
}

/// Metadata about an "asset source", such as how to construct the [`AssetReader`] and [`AssetWriter`] for the source,
/// Metadata about an "asset source", such as how to construct the [`AssetReader`](crate::io::AssetReader) and [`AssetWriter`](crate::io::AssetWriter) for the source,
/// and whether or not the source is processed.
#[derive(Default)]
pub struct AssetSourceBuilder {
Expand Down Expand Up @@ -209,7 +206,7 @@ impl AssetSourceBuilder {
Some(source)
}

/// Will use the given `reader` function to construct unprocessed [`AssetReader`] instances.
/// Will use the given `reader` function to construct unprocessed [`AssetReader`](crate::io::AssetReader) instances.
pub fn with_reader(
mut self,
reader: impl FnMut() -> Box<dyn ErasedAssetReader> + Send + Sync + 'static,
Expand All @@ -218,7 +215,7 @@ impl AssetSourceBuilder {
self
}

/// Will use the given `writer` function to construct unprocessed [`AssetWriter`] instances.
/// Will use the given `writer` function to construct unprocessed [`AssetWriter`](crate::io::AssetWriter) instances.
pub fn with_writer(
mut self,
writer: impl FnMut(bool) -> Option<Box<dyn ErasedAssetWriter>> + Send + Sync + 'static,
Expand All @@ -239,7 +236,7 @@ impl AssetSourceBuilder {
self
}

/// Will use the given `reader` function to construct processed [`AssetReader`] instances.
/// Will use the given `reader` function to construct processed [`AssetReader`](crate::io::AssetReader) instances.
pub fn with_processed_reader(
mut self,
reader: impl FnMut() -> Box<dyn ErasedAssetReader> + Send + Sync + 'static,
Expand All @@ -248,7 +245,7 @@ impl AssetSourceBuilder {
self
}

/// Will use the given `writer` function to construct processed [`AssetWriter`] instances.
/// Will use the given `writer` function to construct processed [`AssetWriter`](crate::io::AssetWriter) instances.
pub fn with_processed_writer(
mut self,
writer: impl FnMut(bool) -> Option<Box<dyn ErasedAssetWriter>> + Send + Sync + 'static,
Expand Down Expand Up @@ -308,7 +305,7 @@ impl AssetSourceBuilder {
}
}

/// A [`Resource`] that hold (repeatable) functions capable of producing new [`AssetReader`] and [`AssetWriter`] instances
/// A [`Resource`] that hold (repeatable) functions capable of producing new [`AssetReader`](crate::io::AssetReader) and [`AssetWriter`](crate::io::AssetWriter) instances
/// for a given asset source.
#[derive(Resource, Default)]
pub struct AssetSourceBuilders {
Expand Down Expand Up @@ -371,7 +368,7 @@ impl AssetSourceBuilders {
}
}

/// A collection of unprocessed and processed [`AssetReader`], [`AssetWriter`], and [`AssetWatcher`] instances
/// A collection of unprocessed and processed [`AssetReader`](crate::io::AssetReader), [`AssetWriter`](crate::io::AssetWriter), and [`AssetWatcher`] instances
/// for a specific asset source, identified by an [`AssetSourceId`].
pub struct AssetSource {
id: AssetSourceId<'static>,
Expand All @@ -397,21 +394,21 @@ impl AssetSource {
self.id.clone()
}

/// Return's this source's unprocessed [`AssetReader`].
/// Return's this source's unprocessed [`AssetReader`](crate::io::AssetReader).
#[inline]
pub fn reader(&self) -> &dyn ErasedAssetReader {
&*self.reader
}

/// Return's this source's unprocessed [`AssetWriter`], if it exists.
/// Return's this source's unprocessed [`AssetWriter`](crate::io::AssetWriter), if it exists.
#[inline]
pub fn writer(&self) -> Result<&dyn ErasedAssetWriter, MissingAssetWriterError> {
self.writer
.as_deref()
.ok_or_else(|| MissingAssetWriterError(self.id.clone_owned()))
}

/// Return's this source's processed [`AssetReader`], if it exists.
/// Return's this source's processed [`AssetReader`](crate::io::AssetReader), if it exists.
#[inline]
pub fn processed_reader(
&self,
Expand All @@ -421,7 +418,7 @@ impl AssetSource {
.ok_or_else(|| MissingProcessedAssetReaderError(self.id.clone_owned()))
}

/// Return's this source's processed [`AssetWriter`], if it exists.
/// Return's this source's processed [`AssetWriter`](crate::io::AssetWriter), if it exists.
#[inline]
pub fn processed_writer(
&self,
Expand Down Expand Up @@ -451,7 +448,7 @@ impl AssetSource {
self.processed_writer.is_some()
}

/// Returns a builder function for this platform's default [`AssetReader`]. `path` is the relative path to
/// Returns a builder function for this platform's default [`AssetReader`](crate::io::AssetReader). `path` is the relative path to
/// the asset root.
pub fn get_default_reader(
_path: String,
Expand All @@ -466,7 +463,7 @@ impl AssetSource {
}
}

/// Returns a builder function for this platform's default [`AssetWriter`]. `path` is the relative path to
/// Returns a builder function for this platform's default [`AssetWriter`](crate::io::AssetWriter). `path` is the relative path to
/// the asset root. This will return [`None`] if this platform does not support writing assets by default.
pub fn get_default_writer(
_path: String,
Expand Down Expand Up @@ -557,7 +554,7 @@ impl AssetSource {
}
}

/// This will cause processed [`AssetReader`] futures (such as [`AssetReader::read`]) to wait until
/// This will cause processed [`AssetReader`](crate::io::AssetReader) futures (such as [`AssetReader::read`](crate::io::AssetReader::read)) to wait until
/// the [`AssetProcessor`](crate::AssetProcessor) has finished processing the requested asset.
pub fn gate_on_processor(&mut self, processor_data: Arc<AssetProcessorData>) {
if let Some(reader) = self.processed_reader.take() {
Expand Down Expand Up @@ -619,7 +616,7 @@ impl AssetSources {
.chain(Some(AssetSourceId::Default))
}

/// This will cause processed [`AssetReader`] futures (such as [`AssetReader::read`]) to wait until
/// This will cause processed [`AssetReader`](crate::io::AssetReader) futures (such as [`AssetReader::read`](crate::io::AssetReader::read)) to wait until
/// the [`AssetProcessor`](crate::AssetProcessor) has finished processing the requested asset.
pub fn gate_on_processor(&mut self, processor_data: Arc<AssetProcessorData>) {
for source in self.iter_processed_mut() {
Expand All @@ -633,17 +630,17 @@ impl AssetSources {
#[error("Asset Source '{0}' does not exist")]
pub struct MissingAssetSourceError(AssetSourceId<'static>);

/// An error returned when an [`AssetWriter`] does not exist for a given id.
/// An error returned when an [`AssetWriter`](crate::io::AssetWriter) does not exist for a given id.
#[derive(Error, Debug, Clone)]
#[error("Asset Source '{0}' does not have an AssetWriter.")]
pub struct MissingAssetWriterError(AssetSourceId<'static>);

/// An error returned when a processed [`AssetReader`] does not exist for a given id.
/// An error returned when a processed [`AssetReader`](crate::io::AssetReader) does not exist for a given id.
#[derive(Error, Debug, Clone, PartialEq, Eq)]
#[error("Asset Source '{0}' does not have a processed AssetReader.")]
pub struct MissingProcessedAssetReaderError(AssetSourceId<'static>);

/// An error returned when a processed [`AssetWriter`] does not exist for a given id.
/// An error returned when a processed [`AssetWriter`](crate::io::AssetWriter) does not exist for a given id.
#[derive(Error, Debug, Clone)]
#[error("Asset Source '{0}' does not have a processed AssetWriter.")]
pub struct MissingProcessedAssetWriterError(AssetSourceId<'static>);
Expand Down
12 changes: 4 additions & 8 deletions crates/bevy_asset/src/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ use std::{
};
use thiserror::Error;

// Needed for doc strings
#[allow(unused_imports, reason = "Needed for documentation links.")]
use crate::io::{AssetReader, AssetWriter};

/// A "background" asset processor that reads asset values from a source [`AssetSource`] (which corresponds to an [`AssetReader`] / [`AssetWriter`] pair),
/// A "background" asset processor that reads asset values from a source [`AssetSource`] (which corresponds to an [`AssetReader`](crate::io::AssetReader) / [`AssetWriter`](crate::io::AssetWriter) pair),
/// processes them in some way, and writes them to a destination [`AssetSource`].
///
/// This will create .meta files (a human-editable serialized form of [`AssetMeta`]) in the source [`AssetSource`] for assets that
Expand Down Expand Up @@ -212,9 +208,9 @@ impl AssetProcessor {
/// Processes all assets. This will:
/// * For each "processed [`AssetSource`]:
/// * Scan the [`ProcessorTransactionLog`] and recover from any failures detected
/// * Scan the processed [`AssetReader`] to build the current view of already processed assets.
/// * Scan the unprocessed [`AssetReader`] and remove any final processed assets that are invalid or no longer exist.
/// * For each asset in the unprocessed [`AssetReader`], kick off a new "process job", which will process the asset
/// * Scan the processed [`AssetReader`](crate::io::AssetReader) to build the current view of already processed assets.
/// * Scan the unprocessed [`AssetReader`](crate::io::AssetReader) and remove any final processed assets that are invalid or no longer exist.
/// * For each asset in the unprocessed [`AssetReader`](crate::io::AssetReader), kick off a new "process job", which will process the asset
/// (if the latest version of the asset has not been processed).
#[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))]
pub fn process_assets(&self) {
Expand Down
9 changes: 3 additions & 6 deletions crates/bevy_asset/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ use std::{any::TypeId, path::Path, sync::Arc};
use std::{future::Future, panic::AssertUnwindSafe};
use thiserror::Error;

#[allow(unused_imports, reason = "Needed for documentation links.")]
use crate::io::{AssetReader, AssetWriter};

/// Loads and tracks the state of [`Asset`] values from a configured [`AssetReader`]. This can be used to kick off new asset loads and
/// Loads and tracks the state of [`Asset`] values from a configured [`AssetReader`](crate::io::AssetReader). This can be used to kick off new asset loads and
/// retrieve their current load states.
///
/// The general process to load an asset is:
Expand Down Expand Up @@ -75,7 +72,7 @@ pub enum AssetServerMode {
}

impl AssetServer {
/// Create a new instance of [`AssetServer`]. If `watch_for_changes` is true, the [`AssetReader`] storage will watch for changes to
/// Create a new instance of [`AssetServer`]. If `watch_for_changes` is true, the [`AssetReader`](crate::io::AssetReader) storage will watch for changes to
/// asset sources and hot-reload them.
pub fn new(sources: AssetSources, mode: AssetServerMode, watching_for_changes: bool) -> Self {
Self::new_with_loaders(
Expand All @@ -87,7 +84,7 @@ impl AssetServer {
)
}

/// Create a new instance of [`AssetServer`]. If `watch_for_changes` is true, the [`AssetReader`] storage will watch for changes to
/// Create a new instance of [`AssetServer`]. If `watch_for_changes` is true, the [`AssetReader`](crate::io::AssetReader) storage will watch for changes to
/// asset sources and hot-reload them.
pub fn new_with_meta_check(
sources: AssetSources,
Expand Down