使用 Travis 在 gh-pages 上使用 Rustdoc
Rustdoc on gh-pages with Travis
我已经生成了文档 for my project with cargo doc
, and it is made in the target/doc directory. I want to allow users to view this documentation without a local copy, but I cannot figure out how to push this documentation to the gh-pages branch of the repository. Travis CI would help me automatically do this, but I cannot get it to work either. I followed this guide,并设置了一个 .travis.yml 文件和一个 deploy.sh 脚本。根据构建日志,一切正常,但 gh-pages 分支永远不会更新。我的操作系统是 Windows 7.
最好使用travis-cargo,它旨在简化文档的部署,并且还具有其他功能。它的自述文件提供了一个 .travis.yml
文件的示例,尽管最简单的形式可能如下所示:
language: rust
sudo: false
rust:
- nightly
- beta
- stable
before_script:
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
script:
- |
travis-cargo build &&
travis-cargo test &&
travis-cargo --only beta doc
after_success:
- travis-cargo --only beta doc-upload
# needed to forbid travis-cargo to pass `--feature nightly` when building with nightly compiler
env:
global:
- TRAVIS_CARGO_NIGHTLY_FEATURE=""
它具有很强的自我描述性,因此很明显,例如,如果您想使用另一个 Rust 发布序列来构建文档,该怎么做。
为了使上述 .travis.yml
正常工作,您需要以某种方式设置 GH_TOKEN
。基本上有两种方法可以做到这一点:在 .travis.yml
中通过加密字符串,或者通过在 Travis 本身的项目选项中配置它。我更喜欢后一种方式,所以我不需要安装 travis 命令行工具或污染我的 .travis.yml
(因此上面的配置文件不包含 secure
选项),但你可以选择其他方式。
我已经生成了文档 for my project with cargo doc
, and it is made in the target/doc directory. I want to allow users to view this documentation without a local copy, but I cannot figure out how to push this documentation to the gh-pages branch of the repository. Travis CI would help me automatically do this, but I cannot get it to work either. I followed this guide,并设置了一个 .travis.yml 文件和一个 deploy.sh 脚本。根据构建日志,一切正常,但 gh-pages 分支永远不会更新。我的操作系统是 Windows 7.
最好使用travis-cargo,它旨在简化文档的部署,并且还具有其他功能。它的自述文件提供了一个 .travis.yml
文件的示例,尽管最简单的形式可能如下所示:
language: rust
sudo: false
rust:
- nightly
- beta
- stable
before_script:
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH
script:
- |
travis-cargo build &&
travis-cargo test &&
travis-cargo --only beta doc
after_success:
- travis-cargo --only beta doc-upload
# needed to forbid travis-cargo to pass `--feature nightly` when building with nightly compiler
env:
global:
- TRAVIS_CARGO_NIGHTLY_FEATURE=""
它具有很强的自我描述性,因此很明显,例如,如果您想使用另一个 Rust 发布序列来构建文档,该怎么做。
为了使上述 .travis.yml
正常工作,您需要以某种方式设置 GH_TOKEN
。基本上有两种方法可以做到这一点:在 .travis.yml
中通过加密字符串,或者通过在 Travis 本身的项目选项中配置它。我更喜欢后一种方式,所以我不需要安装 travis 命令行工具或污染我的 .travis.yml
(因此上面的配置文件不包含 secure
选项),但你可以选择其他方式。