Relm4: Builds on docs.rs are broken

Open tasks

Why is this important?

Whenever a crate is published on crates.io, its documentation is automatically built and linked. Since you added a documentation attribute to the Cargo.toml files, the default link to docs.rs is replaced by that link. I am sure you had some reasons to do that but I am not a fan of it. I know that all gtk crates do that too, so maybe that was the idea. The downside of this is that the documentation is only available in the current version. If I use an older version, I can’t have a look at its documentation (or it is not obvious how to do that). Luckily it is always possible to just go to docs.rs/crate/CrateName and view the documentation there. On docs.rs it is possible to look at all previous versions. This is why there is value in having working builds on docs.rs.

What is the issue?

Unfortunately the build of the current version is broken. I had a similar problem with one of my crates and I believe the reason is that the dependencies are not available. This should be possible to be fixed by adding something along the lines of

[package.metadata.docs.rs]
features = ["dox"]

[features]
dox = ["gtk/dox", "adw/dox"]

to the Cargo.toml file. The same also applies to relm-components. relm-macros builds fine. It is possible to test the build locally by following this guide: https://github.com/rust-lang/docs.rs/blob/master/README.md#build-subcommand

Explanation of the proposed solution

Here is my understanding of how this fixes the error:

[package.metadata.docs.rs]
features = ["dox"]

This tells docs.rs to activate the feature dox.

[features]
dox = ["gtk/dox", "adw/dox"]

If the feature dox is active, it activates it in the crates gtk4 and libadwaita too. This features allows building the docs without the dependencies.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 30 (30 by maintainers)

Most upvoted comments

Yes, I created a Gitlab account and will create a PR today. After that is accepted, I can do the same thing for libpanel and then we should be good. It might be the case that we can only do this for the 0.5 version though. Not sure if they will publish a new patch version for previous minor versions. This here remains an issue though: https://github.com/Relm4/Relm4/pull/298

Okay, I can work on that. I’ll start with the backport since that is the easiest way to see if it actually fixes the builds

I love the new 0.5 version by the way. Feels so much easier 👍 🥇