Python を使い初めてから気になっていた Sphinx とやらに手を出してみました。
キッカケはIBMの以下の記事です。
参考記事では省略されていますが、インストールログも貼り付けておきましょう。
$ easy_install sphinx Searching for sphinx Reading http://pypi.python.org/simple/sphinx/ Reading http://sphinx.pocoo.org/ Best match: Sphinx 1.1.2 Downloading http://pypi.python.org/packages/2.6/S/Sphinx/Sphinx-1.1.2-py2.6.egg#md5=d35db7a8ee62dd55522bca523954baa9 Processing Sphinx-1.1.2-py2.6.egg creating /Library/Python/2.6/site-packages/Sphinx-1.1.2-py2.6.egg Extracting Sphinx-1.1.2-py2.6.egg to /Library/Python/2.6/site-packages Adding Sphinx 1.1.2 to easy-install.pth file Installing sphinx-apidoc script to /usr/local/bin Installing sphinx-build script to /usr/local/bin Installing sphinx-quickstart script to /usr/local/bin Installing sphinx-autogen script to /usr/local/bin Installed /Library/Python/2.6/site-packages/Sphinx-1.1.2-py2.6.egg Processing dependencies for sphinx Searching for docutils>=0.7 Reading http://pypi.python.org/simple/docutils/ Reading http://docutils.sourceforge.net/ Best match: docutils 0.8.1 Downloading http://prdownloads.sourceforge.net/docutils/docutils-0.8.1.tar.gz?download Processing docutils-0.8.1.tar.gz Running docutils-0.8.1/setup.py -q bdist_egg --dist-dir /var/folders/Dz/DzW6jNqiGtiIumsBh5FjkE+++TI/-Tmp-/easy_install-LTszvC/docutils-0.8.1/egg-dist-tmp-JHz7c6 warning: no files found matching 'MANIFEST' warning: no previously-included files matching '.cvsignore' found under directory '*' warning: no previously-included files matching '*.pyc' found under directory '*' warning: no previously-included files matching '*~' found under directory '*' warning: no previously-included files matching '.DS_Store' found under directory '*' zip_safe flag not set; analyzing archive contents... docutils.parsers.rst.directives.misc: module references __file__ docutils.writers.html4css1.__init__: module references __file__ docutils.writers.latex2e.__init__: module references __file__ docutils.writers.odf_odt.__init__: module references __file__ docutils.writers.pep_html.__init__: module references __file__ docutils.writers.s5_html.__init__: module references __file__ Adding docutils 0.8.1 to easy-install.pth file Installing rst2html.py script to /usr/local/bin Installing rst2latex.py script to /usr/local/bin Installing rst2man.py script to /usr/local/bin Installing rst2odt.py script to /usr/local/bin Installing rst2odt_prepstyles.py script to /usr/local/bin Installing rst2pseudoxml.py script to /usr/local/bin Installing rst2s5.py script to /usr/local/bin Installing rst2xetex.py script to /usr/local/bin Installing rst2xml.py script to /usr/local/bin Installing rstpep2html.py script to /usr/local/bin Installed /Library/Python/2.6/site-packages/docutils-0.8.1-py2.6.egg Searching for Jinja2>=2.3 Reading http://pypi.python.org/simple/Jinja2/ Reading http://jinja.pocoo.org/ Best match: Jinja2 2.6 Downloading http://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.6.tar.gz#md5=1c49a8825c993bfdcf55bb36897d28a2 Processing Jinja2-2.6.tar.gz Running Jinja2-2.6/setup.py -q bdist_egg --dist-dir /var/folders/Dz/DzW6jNqiGtiIumsBh5FjkE+++TI/-Tmp-/easy_install-4Hm2Li/Jinja2-2.6/egg-dist-tmp-b_7CnZ warning: no previously-included files matching '*' found under directory 'docs/_build' warning: no previously-included files matching '*.pyc' found under directory 'jinja2' warning: no previously-included files matching '*.pyc' found under directory 'docs' warning: no previously-included files matching '*.pyo' found under directory 'jinja2' warning: no previously-included files matching '*.pyo' found under directory 'docs' Adding Jinja2 2.6 to easy-install.pth file Installed /Library/Python/2.6/site-packages/Jinja2-2.6-py2.6.egg Searching for Pygments>=1.2 Reading http://pypi.python.org/simple/Pygments/ Reading http://pygments.org/ Reading http://pygments.pocoo.org/ Best match: Pygments 1.4 Downloading http://pypi.python.org/packages/2.6/P/Pygments/Pygments-1.4-py2.6.egg#md5=306241dd68799753cdb4a2c9ce8e883a Processing Pygments-1.4-py2.6.egg creating /Library/Python/2.6/site-packages/Pygments-1.4-py2.6.egg Extracting Pygments-1.4-py2.6.egg to /Library/Python/2.6/site-packages Adding Pygments 1.4 to easy-install.pth file Installing pygmentize script to /usr/local/bin Installed /Library/Python/2.6/site-packages/Pygments-1.4-py2.6.egg Finished processing dependencies for sphinx $
クイックスタートを実行します。
いろいろ聞かれますが適当に入力してみました。[ ]中がデフォルト値のようなので、何も指定せずにEnterすれば、デフォルト値が採用されるようです。
$ sphinx-quickstart Welcome to the Sphinx 1.1.2 quickstart utility. Please enter values for the following settings (just press Enter to accept a default value, if one is given in brackets). Enter the root path for documentation. > Root path for the documentation [.]: doc/. You have two options for placing the build directory for Sphinx output. Either, you use a directory "_build" within the root path, or you separate "source" and "build" directories within the root path. > Separate source and build directories (y/N) [n]: y Inside the root directory, two more directories will be created; "_templates" for custom HTML templates and "_static" for custom stylesheets and other static files. You can enter another prefix (such as ".") to replace the underscore. > Name prefix for templates and static dir [_]: _ The project name will occur in several places in the built documentation. > Project name: SpinxTest > Author name(s): KUNO, Yusuke Sphinx has the notion of a "version" and a "release" for the software. Each version can have multiple releases. For example, for Python the version is something like 2.5 or 3.0, while the release is something like 2.5.1 or 3.0a1. If you don't need this dual structure, just set both to the same value. > Project version: 0.1 > Project release [0.1]: 0.1 The file name suffix for source files. Commonly, this is either ".txt" or ".rst". Only files with this suffix are considered documents. > Source file suffix [.rst]: One document is special in that it is considered the top node of the "contents tree", that is, it is the root of the hierarchical structure of the documents. Normally, this is "index", but if your "index" document is a custom template, you can also set this to another filename. > Name of your master document (without suffix) [index]: Sphinx can also add configuration for epub output: > Do you want to use the epub builder (y/N) [n]: n Please indicate if you want to use one of the following Sphinx extensions: > autodoc: automatically insert docstrings from modules (y/N) [n]: > doctest: automatically test code snippets in doctest blocks (y/N) [n]: > intersphinx: link between Sphinx documentation of different projects (y/N) [n]: > todo: write "todo" entries that can be shown or hidden on build (y/N) [n]: y > coverage: checks for documentation coverage (y/N) [n]: y > pngmath: include math, rendered as PNG images (y/N) [n]: > mathjax: include math, rendered in the browser by MathJax (y/N) [n]: > ifconfig: conditional inclusion of content based on config values (y/N) [n]: > viewcode: include links to the source code of documented Python objects (y/N) [n]: A Makefile and a Windows command file can be generated for you so that you only have to run e.g. `make html' instead of invoking sphinx-build directly. > Create Makefile? (Y/n) [y]: y > Create Windows command file? (Y/n) [y]: n Creating file doc/./source/conf.py. Creating file doc/./source/index.rst. Creating file doc/./Makefile. Finished: An initial directory structure has been created. You should now populate your master file doc/./source/index.rst and create other documentation source files. Use the Makefile to build the docs, like so: make builder where "builder" is one of the supported builders, e.g. html, latex or linkcheck. $
とりあえずHTMLを作ってみます。
先の設定の際に、doc/.と指定したので、移動してから、、、
$ make html sphinx-build -b html -d build/doctrees source build/html Making output directory... Running Sphinx v1.1.2 loading pickled environment... not yet created building 1: targets for 1 source files that are out of date updating environment: 1 added, 0 changed, 0 removed reading sources... [100%] index looking for now-outdated files... none found pickling environment... done checking consistency... done preparing documents... done writing output... [100%] index writing additional files... genindex search copying static files... done dumping search index... done dumping object inventory... done build succeeded. Build finished. The HTML pages are in build/html. $