rust - How to conveniently host a crate's up-to-date documentation? -
i published first crate on crates.io , wondering if can maintain documentation in easier way.
quite few crates' docs hosted on github pages, thought give shot. created user.github.io repo, generated docs cargo doc , pushed them it. worked fine, docs can viewed crates.io.
however, updating them inconvenient; if modify crate's documentation, need to:
- push these changes crate's repo
- generate updated docs via
cargo doc - move docs' files github page's folder
- push docs documentation's repo
i'm pretty sure i'm not doing right - point 3. can simplify process? there better way?
for many crates, docs.rs solution. describes itself as:
docs.rs (formerly cratesfyi) open source project host documentation of crates rust programming language.
docs.rs automatically builds crates' documentation released on crates.io using nightly release of rust compiler.
this has tradeoffs:
- documentation automatically generated , hosted you, don't have opt-in.
- documentation each version of crate available.
- if have platform-specific conditional compilation, documentation different platforms can shown.
- only released versions of crates documented. can't publish typo in docs without new release.
- you beholden third-party entity continue providing service.
- you cannot (currently?) control feature flags used.
some people prefer have more control on documentation, or otherwise don't fall target audience docs.rs. many of cases choose configure ci infrastructure generate documentation , push result somewhere.
a common implementation of use travis ci , github pages many projects use these services. ci system , html hosting service can used, long comfortable connecting two.
the general concept is:
- add step build documentation in ci.
- when type of build detected, push generated documentation hosting service.
- possible choices type of build: branch; master branch; tag; etc.
- be careful avoid exposing credentials. common mistake (that have made myself) use command
git push https://${gh_token}@github.com/.... if command fails, token printed stderr, exposing world. other less-obvious cases expose token on failure, check thoroughly.
some people have published blog posts detailing how set things up. have not verified of these sane, may contain details configure specific solution.
Comments
Post a Comment