LoginSignup
1
0

More than 5 years have passed since last update.

Sphinx初心者日記 01

Last updated at Posted at 2018-09-26

概要

SphinxはPython上で動作するドキュメント作成ツールです.

インストール

pip install Sphinx

最低限のドキュメント

ハンズオン

先に全部読んでもいいですが, 兎にも角にも手を動かします.
ハンズオン:勉強会レポートを作成しよう

プロジェクト作成

コマンドラインでプロジェクトを作成します.

> sphinx-quickstart
Welcome to the Sphinx 1.8.1 quickstart utility.

Please enter values for the following settings (just press Enter to
accept a default value, if one is given in brackets).

Selected root path: .

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

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: sample
> Author name(s): taqu
> Project release []:

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 en

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]:
Indicate which of the following Sphinx extensions should be enabled:
> 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]:
> imgmath: include math, rendered as PNG or SVG 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]:
> githubpages: create .nojekyll file to publish the document on GitHub pages (y/n) [n]:

index.rstを編集します. コメントアウトするには, 先頭に".. "を追加すればいいようです.
セクションの追加は, 文字の上下に同じ長さの記号を書くとセクションになると説明されていますので, =を重ねることを形式にしてみます.
記号を後の行に重ねることでサブセクションを表現できるそうです.
このあたりは, clearlyにこうすべしと決められた方が運用上楽です, "このチームではこういうルールです"ということがなくなりますから.

行頭にひとつ以上のスペースを入れて文章を書くことで 引用文

スペース4個を引用文と決めます.

============
Sphinx勉強会
============

開催情報
========
* 日時: 2018/09/27 13:00-17:00
* 場所: CoCoDe
* 参加者: planset, ...

#. 日時: 2018/09/27 13:00-17:00
#. 場所: CoCoDe
#. 参加者: planset, ...

1. 日時: 2018/09/27 13:00-17:00
2. 場所: CoCoDe
3. 参加者: planset, ...

勉強会の内容
============
Sphinxの勉強会に参加してきました.

勉強会では, 勉強会のレポートを書きながらSphinxについて学びました.

Sphinxとは次のようなツールです.
    Sphinxは, reStructuredTex記法で書かれたテキストファイルをHTML, PDFやepubに変換するためのツールです.

    Pythonの公式ドキュメントはSphinxを使って書かれています.
    また, Python以外の多くプロジェクトでもSphinxが利用されています.

Sphinxを利用するために必要なこと

* テキストエディタ
* Sphinxの環境
    * Python
        * pip
        * virtualenv
        * Sphinx
* コマンドラインツールへの多少の慣れ

資料
====

とりあえずビルドします. [build directory]/html以下に出力されます.

// makeスクリプト経由でビルドする.
make html

// -bは出力形式を指定, [source directory] [output directory]を指定する.
>sphinx-build -b html . html

感想

ハンズオンのドキュメントを検索に行きつくまで30分ぐらい時間を使いました.
よく知らなくとも手順通りに手を動かせば, それなりの成果物が得られるチュートリアルの存在は大切だと思いました.
その他, 同意語は統一します, 大文字・小文字など書き方は統一します, 列挙の場合は体現止めなど書き方を統一します.

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0