I recently published my first crate on crates.io and I am wondering if I can maintain its documentation in an easier way.
Quite a few crates' docs are hosted on GitHub pages, so I thought I would give it a shot. I created a user.github.io repo, generated docs with cargo doc
and pushed them to it. Everything worked just fine, the docs can be viewed from crates.io.
However, updating them is inconvenient; if I modify the crate's documentation, I need to:
cargo doc
I'm pretty sure I'm not doing it right - especially point 3. What can I do to simplify this process? Is there any better way?
For many crates, Docs.rs is a good solution. It describes itself as:
Docs.rs (formerly cratesfyi) is an open source project to host documentation of crates for the Rust Programming Language.
Docs.rs automatically builds crates' documentation released on crates.io using the nightly release of the Rust compiler.
This has tradeoffs:
Some people prefer to have more control over their documentation, or otherwise don't fall into the target audience for Docs.rs. Many of those cases choose to configure their CI infrastructure to generate the documentation and push the result somewhere.
A common implementation of that is to use Travis CI and GitHub Pages as many projects already use these services. Any CI system and HTML hosting service can be used, so long as you are comfortable connecting the two.
The general concept is:
git push https://${GH_TOKEN}@github.com/...
. If this command fails, the token is printed to stderr, exposing it to the world. Other less-obvious cases also expose the token on failure, so check those thoroughly.Some people have published blog posts detailing how they set things up. I have not verified that any of these are sane, but they may contain details to help you configure a specific solution.