10. The Sphinx
10
• Document Builder
• Python project
• install with pip, easy_install
• (But) Don t need any knowledge of Python.
• Write once publish anywere.(with pahdoc)
• write reST (reStructuredText)
or Markdown
• to html, epub, man, TeX, etc...
たぶんすばらしいSphinxの世界
Wednesday, September 11, 13
13. sphinx-quickstart
$ sphinx-quickstart
Welcome to the Sphinx 1.2b1 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 [.]:
13
簡単スタートツール、sphinx-quickstartとの対話を
フルコーラスでご覧ください
Wednesday, September 11, 13
14. 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
14
赤い所が入力箇所!
といっても、ほとんど入力する必要は無いんだけどね。
Wednesday, September 11, 13
15. The project name will occur in several places in the built
documentation.
> Project name: sphinx_sinatra_example
> Author name(s): sawanoboly
15
まだ対話が続くよ、
あと6ページほどやる。
Wednesday, September 11, 13
16. 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: 1.0
> Project release [1.0]:
16
まだ対話が続くよ、
あと5ページほど。
Wednesday, September 11, 13
17. 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]:
17
まだ対話が続くよ、あと4ページほど。
ああ、ここは好みで.txtに変えたりするね。
Wednesday, September 11, 13
18. 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]:
18
まだ対話が続くよ、
あと3ページほど。
Wednesday, September 11, 13
19. Sphinx can also add configuration for epub output:
> Do you want to use the epub builder (y/N) [n]:
19
まだ対話が続くよ、あと2ページほど。
オマケでepub出力ができるよ。kindleに入れようぜ。
Wednesday, September 11, 13
20. Please indicate if you want to use one of the following Sphinx extensions:
> autodoc: automatically insert docstrings from modules (y/N) [n]: y
> 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]: Y
20
まだ対話が続くよ、あと1ページほど。
いろんなモジュールあるけどスルーでOK、viewcodeはアリかな。
Wednesday, September 11, 13
21. 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
21
Makefileを作って終わりです
いざSphinx!
Wednesday, September 11, 13
23. $ make html
sphinx-build -b html -d build/doctrees source build/html
Making output directory...
Running Sphinx v1.2b1
loading pickled environment... not yet created
building [html]: 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.
23
make html
早速ビルドだ、やったぜ!
Wednesday, September 11, 13
29. Rebuild
$ make html
-- snip --
reading sources... [100%] public
-- snip --
writing output... [100%] public
-- snip --
Build finished. The HTML pages are in build/html.
29
さあ、もう一度ビルド!
Wednesday, September 11, 13
32. add index before content
POST /v1/public/*****************
Resets the hogehoge
32
.. index::
single: public/reset
POST /v1/public/******************
Resets the hogehoge
そんなときは索引から飛びたい見出しの前に
すこしおまじないをかけばうまくいくんだ。
Wednesday, September 11, 13
43. $ make html
sphinx-build -b html -d build/1.0/doctrees source build/1.0/
html
-- snip --
Build finished. The HTML pages are in build/1.0/html.
43
一応べつのディレクトリとして出力できるんだけど
Wednesday, September 11, 13