Skip to content

Is multi targets build supposed to be merged into single index.html? #2749

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

Closed
unkcpz opened this issue Feb 26, 2025 · 11 comments
Closed

Is multi targets build supposed to be merged into single index.html? #2749

unkcpz opened this issue Feb 26, 2025 · 11 comments

Comments

@unkcpz
Copy link

unkcpz commented Feb 26, 2025

I set targets = ["x86_64-apple-darwin", "x86_64-pc-windows-msvc"] in order to have docs show for both apple and windows. Both of them are successfully built (I tried locally with docker-compose) but it only shows the docs of x86_64-apple-darwin. If I switch windows one to be the first, only windows docs shows. Here is what I have in the crate:

#[cfg(all(target_os = "macos", feature = "apple-native"))]
#[doc(cfg(all(target_os = "macos")))]
pub mod macos;

#[cfg(all(target_os = "windows", feature = "windows-native"))]
#[doc(cfg(all(target_os = "windows")))]
pub mod windows;

What I expect intuitively when using targets is the docs from different build target will be merged. Is there way to config for it? Otherwise, I don't know what is targets field used for.

I realize there are some tricky issues such as conflicting if I set pub use xxx as default for one target and pub use yyy as default for the other. I assume by combine with rust-lang/rust#43781, it is possible to have fine control on what to show in the combined docs after detecting the conflict?

@syphar
Copy link
Member

syphar commented Feb 26, 2025

I set targets = ["x86_64-apple-darwin", "x86_64-pc-windows-msvc"] i

I assume you mean targets in our docs.rs metadata?

The rustdoc for a specific target is 100% separate from the other targets, so the result of adding targets here is that you have a dropdown:

Image

where your users can select the target they are working on, to find the docs for that target.

@syphar
Copy link
Member

syphar commented Feb 26, 2025

What I expect intuitively when using targets is the docs from different build target will be merged. Is there way to config for it?

I'm not sure I follow, what do you mean my "merged"? do you have a more specific example?

@unkcpz
Copy link
Author

unkcpz commented Feb 26, 2025

where your users can select the target they are working on, to find the docs for that target.

I see, didn't notice it.

What I expect intuitively when using targets is the docs from different build target will be merged. Is there way to config for it?

I'm not sure I follow, what do you mean my "merged"? do you have a more specific example?

Sorry, doesn't matter if the targets config is designed to a dropdown point to different target. What originally in my mind was a single platform agnostic page that have different targets specific docs info with labels aside, such as the combination of following two.

Image

Image

@syphar
Copy link
Member

syphar commented Feb 26, 2025

That would be a change to rustdoc itself, not docs.rs.

Rustdoc requirements are managed on rust-lang/rust.

cc @GuillaumeGomez

@GuillaumeGomez
Copy link
Member

rustdoc generates documentation based on cfg. If you want items not available on the current target, you need to tweak the cfg by using cfg(any(windows, doc)) for example. Closing then.

@unkcpz
Copy link
Author

unkcpz commented Feb 26, 2025

If you want items not available on the current target, you need to tweak the cfg by using cfg(any(windows, doc)) for example. Closing then.

That's true, and I already try to use it. But apparently for some APIs we had it is not possible to build on the different OS because of upstream crate use cfg(all(target_os = "macos". Thanks for the help and it is all clear to me how to proceed!

@unkcpz
Copy link
Author

unkcpz commented Feb 26, 2025

The platform dropdown works fine for me. Just come up with a follow up question: how to properly write in the docstring the link to other platform doc of the crate?
I think using the full url would be hard to maintain and keep the doc always sync with the version. The goal will be to link to URL../my-crate/vx.x.x/aarch64-apple-darwin/keyring/macos/struct.MacCredential.html I can write [MacCredential](aarch64-apple-darwin:::credential::CredentialApi) where the platform is the prefix with three ::: as delimiter.

I'll open an issue if this is a valid request and things are not supported yet. @syphar thanks in advance.

@GuillaumeGomez
Copy link
Member

You need to use plain paths (with /).

@unkcpz
Copy link
Author

unkcpz commented Feb 26, 2025

You mean the plain URL?
If I understand correctly, it follows the markdown format which may not easy to jump to the link of a different parent path. I try to put aarch64-apple-darwin/credential::CredentialApi but the generated link lead to http://localhost:3000/my-crate/3.6.1/x86_64-pc-windows-msvc/my-crate/aarch64-apple-darwin/credential::CredentialApi::as_any.

@GuillaumeGomez
Copy link
Member

It's like when using cd in a terminal. You want to go to the parent, you use ... To child, you have /. So something like ../../../blabla/crate/arch/file.html.

@unkcpz
Copy link
Author

unkcpz commented Feb 26, 2025

Cool, it works. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants