「テーマ」を変更する


「テーマ」とは

Sphinx で作成した文書の「見た目」を決めるものが「テーマ」です。この「テーマ」を変更すると「見た目」も変更になります。 Sphinx で作成した文書の「見た目」は「テーマ」で決まります。

../_images/2020-03-01_13h35_38.png

テーマごとに名前が付いており、上図のテーマ名は「 alabaster 」です。 Sphinx が用意しているテーマ(ビルトインテーマ)は次の 10 種類です。いくつかのテーマは「見た目」以外に、複数のオプションを設定できます。

注釈

ビルトインテーマの詳細は次のページを参照ください。

alabaster ← デフォルトのテーマ

../_images/2020-03-01_13h35_38.png

classic

../_images/2020-03-01_13h36_12.png

sphinxdoc

../_images/2020-03-01_13h40_36.png

scrolls

../_images/2020-03-01_13h41_10.png

agogo

../_images/2020-03-01_13h42_14.png

traditional

../_images/2020-03-01_13h42_39.png

nature

../_images/2020-03-01_13h43_05.png

haiku

../_images/2020-03-01_13h43_35.png

pyramid

../_images/2020-03-01_13h44_13.png

bizstyle

../_images/2020-03-01_13h44_41.png

「テーマ」の変更方法

"conf.py" ファイル内の html_theme で使用するテーマを指定します。

../_images/2020-03-01_15h55_35.png

"alabaster" から "classic" にするには次のように変更・保存します。必要に応じて、テーマのオプション設定を行います。

../_images/2020-03-01_16h20_24.png

その後、" make html "を実行して HTML を再作成します。

../_images/2020-03-01_16h24_27.png

Sphinx Themes

Sphinx Themes に多くのテーマが掲載されています。

../_images/2020-03-01_16h55_27.png

各テーマには 3 つのリンクが設定されています。

sample

サンプル表示を確認できます。

pypi

インストール方法などの説明が記載されています。

conf.py

"conf.py" ファイルの設定サンプルが記載されています。

導入手順

今回は "sphinx_rtd_theme" の導入を例に説明します。

../_images/2020-03-01_18h34_11.png
  1. pypi をクリックして導入方法を確認

    ../_images/2020-03-01_18h36_16.png

  2. "Anaconda Powershell Prompt(Miniconda3)" でインストールコマンドを実行

    pip install sphinx-rtd-theme

    ../_images/2020-03-01_18h39_01.png ../_images/2020-03-01_18h39_19.png

  3. "conf.py" ファイルの html_theme を変更

    ../_images/2020-03-01_18h41_41.png

  4. " make html "を実行して HTML を作り直し

    ../_images/2020-03-01_18h43_35.png

  5. "index.html" ファイルを開いて結果確認

    ../_images/2020-03-01_18h45_32.png

    ../_images/2020-03-01_18h46_19.png