gitBook 寫技術文件

timger發表於2014-09-06

gitbook 是一個基於 git 和 github 的靜態站點寫作工具他們有一個官網上有不少好的書
參見https://www.gitbook.io/

下面介紹下 gitbook 寫書的一些記錄

介面編輯

下載編輯器 https://github.com/GitbookIO/editor

命令列

下面只記錄了主要的命令列使用流程,文章編輯功能就沒寫啦
http://segmentfault.com/ 貼圖片太麻煩

安裝

npm -g install gitbook
npm -g install gitbook-plugin
npm install gitbook-plugin-disqus
npm install gitbook-plugin-ga

命令引數

timgerdeMac-mini:PythonToScala_Zh timger$ gitbook 

  Usage: gitbook [options] [command]

  Commands:

    build [options] [source_dir] Build a gitbook from a directory
    serve [options] [source_dir] Build then serve a gitbook from a directory
    pdf [options] [source_dir] Build a gitbook as a PDF
    epub [options] [source_dir] Build a gitbook as a ePub book
    mobi [options] [source_dir] Build a gitbook as a Mobi book
    init [source_dir]      Create files and folders based on contents of SUMMARY.md
    publish [source_dir]   Publish content to the associated gitbook.io book
    git:remote [source_dir] [book_id] Adds a git remote to a book repository

  Options:

    -h, --help     output usage information
    -V, --version  output the version number


config

timgerdeMac-mini:PythonToScala_Zh timger$ cat book.json
{
    "plugins": ["ga", "disqus"]
    "pluginsConfig": {
        "ga": {
            "token": "UA-29124639-6"
        },
    "disqus": {
            "shortName": "yishenggudou"
        }
    }
}

build

gitbook build  ./ -o ./build --config=book.json

釋出

cp -vrf ../PythonToScala_Zh/build/* ./
git add -f ./*
. ~/.bashrc
. ~/.bash_profile
git_commit_msg "pub"
push_auto_branch 

線上地址

http://www.timger.info/PythonToScala/index.html

打包 pdf

timgerdeMac-mini:PythonToScala_Zh timger$ gitbook pdf  ./ -o ./python2scala.pdf --config=book.json
Starting build ...
Successfully built!

相關文章