Ric*_*all 6 python continuous-integration travis-ci mkdocs
我如何在Travis CI中自动部署我的Mkdocs文档?
Ric*_*all 13
以下是自动部署mkdocs文档的方法.请按照以下3个步骤操作.
只需将以下代码段插入.travis.yml配置文件中各自的位置即可:
language: python # Set the build language to Python
python: 3.6 # Set the version of Python to use
branches: master # Set the branch to build from
install:
- pip install mkdocs # Install the required dependencies
script: true # Skip script (Don't use this if one already exists)
before_deploy:
- mkdocs build --verbose --clean --strict # Build a local version of the docs
deploy: # Deploy documentation to Github in the gh_pages branch
provider: pages
skip_cleanup: true
github_token: $github_token
local_dir: site
on:
branch: master
Run Code Online (Sandbox Code Playgroud)
如果您使用的是mkdocs的主题,没有mkdocs或readthedocs然后按照下面的步骤进行安装:
场景1:主题可以通过pip安装(例如mkdocs-material)
pip install mkdocs您需要安装的其他软件包,例如mkdocs-material它pip install mkdocs mkdocs-material pymdown-extensions pygments方案2:主题是不经由PIP安装(如docskimmer)
删除--strict参数mkdocs build --verbose --clean --strict以禁止使用不能通过pip安装的主题的可能错误.
在before_deploy上面的部分中添加设置主题所需的代码mkdocs build --verbose --clean
before_deploy对于docskimmer,该部分中的代码如下所示:
before_deploy:
- git clone https://github.com/hfagerlund/mkdocs-docskimmer.git # Clone the repo hosting the code
- cp -r $PWD/mkdocs-docskimmer/mkdocs_docskimmer . # Copy the required code to the repo root
- cp -r $PWD/mkdocs-docskimmer/mkdocs_docskimmer/. ./docs # Copy the required code to the docs folder
- mkdocs build --verbose --clean # Build a local version of the docs
Run Code Online (Sandbox Code Playgroud)
通过点不提供的主题安装可能会有所不同.
在最后一步是告诉特拉维斯CI登录到您的帐户GitHub的推变化所需的凭据:
public_repo范围设置了个人访问令牌,请跳至11Token description,为您的令牌选择一个名称 - 它可以是任何东西; 我给它命名就像Travis CI你可以将令牌重用于任意数量的存储库一样.public_repo范围/权限Generate token页面底部github_token<THE TOKEN YOU JUST GENERATED>Noadd你完成了!请随时在评论中问我任何问题.
此外,如果该方法停止工作或不起作用,请在评论中告诉我,我会尽快解决它.
| 归档时间: |
|
| 查看次数: |
718 次 |
| 最近记录: |