slate+github 优化你的在线文档

1,519 阅读1分钟

起因

最近接了个需求,要为广大开发者提供API文档。我习惯性的使用markdown,因为是一种轻量级标记语言,语法简单,使用方便,阅读起来也非常的人性化。

刚开始想写到github的README中,后来觉得对开发者不够友好,于是在网上搜索有没有相关的在线API框架,要求简单、易操作。后来发现了slate,下面我的使用教程。

fork slate代码

github地址:github.com/slatedocs/s…

image

下载fork之后的代码(你自己的代码)

image

编辑index.html.md

找到 slate/source/index.html.md下

image

我写的demo(github.com/Timmy-Cai/s…),

具体都是什么含义,可以参考slate 的wiki(github.com/slatedocs/s…)

部署到github.io

  1. 到本地slate项目下运行./deploy会提示你
Could not find concurrent-ruby-1.1.7 in any of the sources
Run `bundle install` to install missing gems.

如果提示 bundle commod not found ,则需要安装bundle

如果想在本地调试,可以参考 github.com/slatedocs/s…

  1. 更换bundle源
gem sources -r https://rubygems.org/ -a https://gems.ruby-china.com/
bundle config mirror.https://rubygems.org https://gems.ruby-china.com
  1. 运行 bundle install image

  2. 出现以下内容说明安装结束 image

  3. 运行./deploy,此时,在slate项目中会生产build文件夹,里面会有静态的文件。如果你用浏览器打开index.html的话会发现你写的API文档。

最后一步

到你的github的slate项目下->setting,向下滑,找到GitHub Pages ,选择分支gh-pages(因为静态文件就在这个分支下),然后选/(root),最后save。最后你的slate地址就在 https://xxx/github.com/slate,可参加下图

image

最后的最后

slate还有非常多的配置,需要的时候再看,如果你觉得有用,不要忘记为原作者点个星哦~