Creating Index Pages in Sphinx#

Sphinx has a built-in functionality to create index pages.

What are Index Pages?#

An index page is a page, often found at the end of a book, containing an alphabetically ordered list of terms.

Mechanism#

  • During HTML build time, Sphinx automatically creates genindex.html.

  • You can create links to the index by using :ref:`genindex`.

  • Gathers words from the “index directive” and the “glossary directive” on each rst page and creates an index list.

Tip

If you want to link to the index using toctree, create genindex.rst [1]

Index Directive#

Index Directive:

.. index :: <entries>
  • Used as a marker that is not displayed on the page, but is instead collected in the index.

  • It is possible to associate with indexes of multiple words. ⇒ [2]

Tip

  • All characters are classified according to their first letter, and hiragana, katakana, and kanji are treated as separate characters. It is difficult to use for Japanese.

  • Sphinx拡張の記事 [3] で日本語で柔軟な索引が作れるとの情報。試したが、当サイトが環境事情でPython3.7のためコンパイルが通らず、評価できずにいる。

Glossary Directive#

Glossary Directive:

../ glossary ::

  term 1 : 
  term 2 : 
    Definition of both terms.