Created
August 21, 2013 07:03
-
-
Save moqada/6291156 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| """ | |
| *.rstなファイルを監視してSphinxをbuildするタスク | |
| @see http://kshigeru.blogspot.jp/2013/02/sphinx-livereload.html | |
| """ | |
| import logging | |
| from os import path | |
| from subprocess import Popen, PIPE | |
| from livereload.task import Task | |
| def sphinx(): | |
| build_dir = '_build' | |
| argv = [ | |
| 'sphinx-build', '-q', '-b', 'html', '-d', | |
| path.join(build_dir, 'doctrees'), '.', | |
| path.join(build_dir, 'html') | |
| ] | |
| logging.debug('Start to build into %s', build_dir) | |
| p = Popen(argv, stdin=PIPE, stdout=PIPE, stderr=PIPE) | |
| stdout, stderr = p.communicate() | |
| if stderr: | |
| logging.error(stderr) | |
| logging.debug('Finish to build: %s', stdout) | |
| # 階層が違うとマッチしてくれないっぽい | |
| Task.add('*.rst', sphinx) | |
| Task.add('**/*.rst', sphinx) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment