LoginSignup
2
1

More than 5 years have passed since last update.

Sphinx初心者日記 02

Posted at

概要

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

ハンズオン

ディレクトリツリー

以下のような構成にします.

/
 |- index.rst
 |- reports/
     |- study_sphinx00.rst
     |- study_sphinx01.rst

index.rstを以下のように修正します.

サンプルドキュメント
====================
Contents:

.. toctree::
    :maxdepth: 2
    :numbered:
    :glob:

    reports/*

Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

ドキュメントを階層化して管理できます.

セクション

=========================================
Sphinxでの文章の書き方(reStructuredText)(レベル1)
=========================================
セクション(レベル2)
======================
レベル3
--------
レベル4
^^^^^^^^
レベル5
++++++++

目次

.. :depth: 目次に含めるセクションの深さ
.. :local: contents以降を目次に含める、なければページない全て
.. :backlinks: 目次に戻るリンクの動作。
..    entry: 各項目に戻る、top: 目次のタイトルに戻る、none: バックリンクを作らない
.. contents:: 目次
    :depth: 2
    :local:
    :backlinks: entry

強調

*Sphinx*で Sphinx
**Sphinx**で Sphinx
Sphinx *Sphinx* SphinxでSphinx Sphinx Sphinx
` Sphinx `で Sphinx

インデント

前の段落より1段インデントが深い段落は引用になります。

以下インデント

こんにちわ、僕はまちちゃん

改行

改行をそのまま表示したい場合は、| を使用します。

| このように行を
| そのまま出力します。

このように行を
そのまま出力します。

リスト

* 項目1
* 項目2
    * 項目2.1
* 項目3

#. 項目1
#. 項目2
    #. 項目2.1
#. 項目3

コードブロック

| :: 又は, .. code-block:: のあとに1行開けてインデントして書く。

コード::

#include <stdio.h>
int main(int arc, char** argv)
{
    return 0;
}

.. code-block:: c

#include <stdio.h>
int main(int argc, char** argv)
{
    return 0;
}
.. _label:

ラベルと参照

↑こ↓こに

:ref:`label`

を参照

他のドキュメントへの参照

:doc:`study_sphinx01`

リンク

* http://sphinx-doc.org/
* `github <https://github.com>`_
* Sphinx-users.jp_ 

.. _Sphinx-users.jp: http://sphinx-users.jp/

ダウンロード用のリンク

:download:`ダウンロードリンク <study_sphinx01.rst>`

画像

.. image:: lenna.png
    :scale: 50%
    :height: 128px
    :width: 128px

テーブル

テーブル1

======= ====== ======
col1    col2   col3
======= ====== ======
row1    a      b
row2    a      b
row3    a      b
======= ====== ======

テーブル2

+------------------------+------------+----------+----------+
| Header row, column 1   | Header 2   | Header 3 | Header 4 |
| (header rows optional) |            |          |          |
+========================+============+==========+==========+
| body row 1, column 1   | column 2   | column 3 | column 4 |
+------------------------+------------+----------+----------+
| body row 2             | ...        | ...      |          |
+------------------------+------------+----------+----------+

csv-table

.. csv-table:: Frozen Delights!
    :header: "Treat", "Quantity", "Description"
    :widths: 15, 10, 30
    "Albatross", 2.99, "On a stick!"
    "Crunchy Frog", 1.49, "If we took the bones out, it wouldn't be
    crunchy, now would it?"
    "Gannet Ripple", 1.99, "On a stick!"

注釈

.. note::
    これは注釈です!

.. warning::
    これは警告です!

索引

.. index:: Python
.. index::
pair: Python; Sphinx

インクルード

.. include:: include.rst

| 引用としてインクルードする
.. literalinclude:: include.rst
:language: rst
:linenos:

2
1
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
2
1