pub fn copy_assets_folder<T>(source: T)where
    T: AsRef<Path>,
Expand description

Copy media files (images, etc) to your rustdoc output directory.

source is the path to your assets base-folder(i. e. “doc/images”). The path is relative to the location of your crate’s manifest file Cargo.toml.

The default output directory for documentation is target/doc/.

rustdoc supports two ways of changing this output directory: The command line flag --target-dir and the environment variable CARGO_TARGET_DIR. rustdoc-assets cannot know about the runtime command line argument, but it does check the environment variable for changes to the default output directory.

If your package is part of a workspace, create the following file as part of your workspace .cargo/config.toml:

[env]
# points to the current working directory; required for rustdoc-assets
CARGO_WORKSPACE_DIR = { value = "", relative = true }

This will cause copy_assets_folder() to use the workspace directory as base path, instead of your crate root directory.

See the Crate documentation for an example.