How to use readthedocs

New project hosted by github

Creat a new sphinx project

私はMathJaxはenabledにしてみました。 設定は後からconf.pyから変更可能です。

  • .gitignore設定

    echo docs/\_build/* > .gitignore
    

sphinx-quickstartの時点でbuildとsourceを別々にする設定にすると、_buildディレクトリにならないので注意。

  • ファイルをgithubにpushしておく

    git add -A
    git commit -m'<comment>'
    git push origin <branch>
    
  • localでhtmlを確認

    make html
    

で_build以下にhtmlファイルができるが、readthedocsではsphinx rds templateが適用されるので見た目違うものになる。

Use readthedocs template

Settings of Readthedocs

githubのアドレスを指定する

  • Admin -> Repository URLでdocumentが入っているレポジトリを指定

buildに失敗する

数式サポート

  • conf.pyのextensionsに’sphinx.ext.mathbase’を追加

    .. math::
        \sum \infty
    
  • こうなる→

\[\sum \infty\]

Google analytics

  • Admin -> Advanced settingにトラックコードを追加