How to generate documentation for a project that has conditional compilation for wasm32-unkown-unknown?

I have a library that loads different modules depending on which target it runs on. Notably, it's usable on both wasm and "more conventional targets".

When running cargo doc, the wasm32 specific modules are not documented. Ideally I would like to see both, with some disambiguation where modules have the same name.

When trying to generate the wasm docs alone, I don't get it to work:

$ cargo doc  --no-deps --all-features --target wasm32-unkown-unkown                      

error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `/home/user/.cargo/bin/sccache rustc - --crate-name ___ --print=file-names --target wasm32-unkown-unkown --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro` (exit code: 1)
--- stderr
error: Error loading target specification: Could not find specification for target "wasm32-unkown-unkown"
  |
  = help: Use `--print target-list` for a list of built-in targets

My default toolchain is nightly (rustc 1.37.0-nightly (2fe7b3383 2019-06-19))

Ideally I would have all this work seamlessly on docs.rs, but if that's impossible, I would like to at least be able to generate wasm target docs separately so I can put them on github pages.

The target name is mispelled here. Could that be why it can't find the target spec?

1 Like

thanks alot, now I can generate the wasm docs at least separately. I must have been tired last night.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.