/dev/null

(◞‸◟)

SublimeText2でSphinx-Build

ドキュメント書くのにSphinxを使い始めましたが書いたテキストをプレビューするにはmake htmlしたりする必要があります。

毎度コンソールから叩くのが面倒です。どうせならSublimeTextなどでbuildしたいです。

ということでSublimeTextにBuildコマンドを登録します。(for Mac)

SublimeTextの[Tools]→[Build System]→[New Build System]で新しいbuildコマンドを作ります。

{
    "cmd": ["make", "html"],
    "working_dir": "${project_path:${folder}}"
}

中身は上記に変更。

それをsphinxとか名前にして保存。

rstファイルを開いて

[Tools]→ [Build System]→[sphinx]にして⌘+Bでbuildが実行出来ます。

が、自分の環境ではコレではダメでエラー出ました。

Makefile:12: *** The 'sphinx-build' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the 'sphinx-build' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/.  Stop.
[Finished in 0.1s with exit code 2]

sphinx-buildのコマンドパスが見つからないエラー。

SublimeのPATHは⌘+,で


    "build_env":
    {
        "PATH": "/usr/local/bin:/usr/local/sbin:/usr/local/share:/usr/bin"
    }

を設定。

そうすると

sphinx-build -b html -d _build/doctrees   . _build/html
Running Sphinx v1.2.2
loading pickled environment... done
building [html]: targets for 0 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed
looking for now-outdated files... none found
no targets are out of date.
make: echo: No such file or directory
make: *** [html] Error 1
[Finished in 0.6s with exit code 2]

これもまたエラー。

中途半端にエラーになってて辛いのでドキュメントフォルダにあるMakefileを編集して

  4 # You can set these variables from the command line.
  5 SPHINXOPTS    =
  6 SPHINXBUILD   = sphinx-build
  7 PAPER         =
  8 BUILDDIR      = _build

の6行目を/usr/local/bin/sphinx-buildに変更しておくとbuildが通る。