Mac
Sphinx
python2.7
elcapitan

Sphinxをインストール(Mac OS X El Capitan version 10.11.2)

More than 3 years have passed since last update.


はじめに

前々から、Sphinxをインストールしようとしてやってませんでした。

理由は、エラーが出てたから・・・。

http://sphinx-users.jp/gettingstarted/install_unix.html

ここを見て、インストールを試みました。

$ sudo port install py27-sphinx

すると

Warning: port definitions are more than two weeks old, consider updating them by running 'port selfupdate'.

---> Computing dependencies for py27-sphinx
---> Dependencies to be installed: py27-docutils py27-roman py27-setuptools python27 db46 autoconf m4 perl5 perl5.12 automake db_select libtool libedit python_select sqlite3 py27-jinja2 py27-markupsafe py27-pygments sphinx_select
---> Extracting m4
Error: org.macports.extract for port m4 returned: command execution failed
Error: Failed to install m4
Please see the log file for port m4 for details:
/opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_devel_m4/m4/main.log
Error: The following dependencies were not installed: py27-docutils py27-roman py27-setuptools python27 db46 autoconf m4 perl5 perl5.12 automake db_select libtool libedit python_select sqlite3 py27-jinja2 py27-markupsafe py27-pygments sphinx_select
To report a bug, follow the instructions in the guide:
http://guide.macports.org/#project.tickets
Error: Processing of port py27-sphinx failed

これが出て諦めてました。

が、別のやり方もあるのでは?と思い立ち、別の方法でインストールを再開したので、ログ残し。


インストール

コマンドは、sudo pip install sphinxで、インストール完了。

めっちゃ簡単でした・・・。

条件としては、すでにPython2.7がインストールされてたので、難なく完了。


プロジェクトの作成

あとは、Sphinxでプロジェクトを作成します。

コマンドは、これも簡単。


フォルダ作成と移動

まずは、Sphinxプロジェクト用のディレクトリを作成し、移動します。

$ mkdir sphinx-docs

$ cd sphinx-docs


プロジェクト作成

で、プロジェクト作成コマンドを実行

$ sphinx-quickstart

あとは、Enterキーを連打すればいいみたいですが、一応適当に何か入れてみました。


最初は、ドキュメントのルートパスを聞かれます。ここはEnterキーを。

Welcome to the Sphinx 1.3.3 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 [.]:


次もEnterキーを。

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]:


もう一度Enterキーを。

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 [_]:


プロジェクト名と著者は自由に入れました。


今回は、プロジェクト名に「AreaZDocument」、著者に「areaz」を入れました。

The project name will occur in several places in the built documentation.

> Project name: AreaZDocument
> Author name(s): areaz


プロジェクトバージョンとリリースバージョンは共に、「0.1.0」を入れました。

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.0
> Project release [0.1.0]:


プロジェクトの言語を日本語にしたかったので、「ja」を入れました。

If the documents are to be written in a language other than English,

you can select a language here by its language code. Sphinx will then
translate text that it generates into that language.

For a list of supported codes, see
http://sphinx-doc.org/config.html#confval-language.
> Project language [en]: ja


ここからは、何も入力せずに、Enterキーの連打。

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]:

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]:
> coverage: checks for documentation coverage (y/n) [n]:
> 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]:
> Create Windows command file? (y/n) [y]:

Creating file ./conf.py.
Creating file ./index.rst.
Creating file ./Makefile.
Creating file ./make.bat.

Finished: An initial directory structure has been created.

You should now populate your master file ./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.

これで、見事プロジェクトができました。


この後

ドキュメントを書いて、確認できるところまでをできるだけ早く出していこうかと。