You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when running cargo doc on a native platform, documentation for WASM-specific functionality is not included. (This is the case on docs.rs as well.)
Rework the inline documentation of WASM-specific items using #[cfg(doc)] declarations, so that cargo doc generates documentation for WASM-specific functionality as well.
The text was updated successfully, but these errors were encountered:
The generation of multi-target documentation in a single run of cargo doc is a long-standing problem; for context, see rust-lang/rust#1998 and rust-lang/rust#43348.
Recent builds of rustdoc pass a special cfg target setting, doc, that can be detected during documentation generation. We can change our current #[cfg(target_arch = "wasm32")] declarations to #[cfg(any(doc, target_arch = "wasm32"))] to have those functions included in our documentation builds.
Certain types that are imported only when compiling to WASM - items from the js_sys and wasm_bindgen crates, for instance - must be available when generating documentation as well. Ideally, applying the doc target to Cargo.toml would automatically include the items we need, but this does not work; probably those crates are entirely wrapped with WASM-specific declarations, so even if we include them successfully with Cargo.toml, they are not exposed except when building on WASM. After thinking about it for a while, I decided the simplest solution was to create empty dummy structs like so:
#[cfg(doc)]structJsValue;
This is sufficient for the call to cargo doc to succeed, which is all that we need.
Currently, when running
cargo doc
on a native platform, documentation for WASM-specific functionality is not included. (This is the case on docs.rs as well.)Rework the inline documentation of WASM-specific items using
#[cfg(doc)]
declarations, so thatcargo doc
generates documentation for WASM-specific functionality as well.The text was updated successfully, but these errors were encountered: