テーマの変更¶
概要¶
Sphinxには、標準で以下の 10 個のテーマ [1] が用意されています。
alabaster
default
sphinxdoc
scrolls
agogo
nature
pyramid
haiku
traditional
bizstyle
まずは、標準のテーマを他のテーマへ変更する方法を確認しましょう。詳細については公式ドキュメント を参照して下さい。
手順¶
テーマを変更するには、conf.py
の以下の部分を編集します。
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
標準では、html_theme
にはalabaster
が指定されています。
conf.py
のhtml_theme
の値を、組込みテーマから選択して指定すれば、指定したテーマに変更する事が出来ます。以下の例では、sphinxdocテーマを指定しています。
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinxdoc'
conf.py
を書き換えた後、make htmlを実行すれば指定したテーマのhtmlが出力されます。
組み込みテーマの紹介¶
alabaster¶
alabaster
テーマはsphinx-quickstart
コマンドでプロジェクトを生成した直後に設定されている標準のテーマです。
bizstyle¶
conf.pyの書き換え:
html_theme = 'bizstyle' # 下記オプションでバックグラウンドの色を変更する事が可能です。※必須ではありません html_theme_options = {'maincolor' : "#696969"}
default¶
昔の標準テーマです。互換性を残す為に名前がdefaultになっています。
sphinxdoc¶
scrolls¶
agogo¶
nature¶
pyramid¶
haiku¶
traditional¶
サードパーティ製テーマの紹介¶
標準で提供されているテーマの他に、有志によって様々なテーマが公開されています。ここで紹介するサードパーティ製のテーマはPythonのパッケージ管理ツールpipを用いてインストールします。
sphinxjp.themes.dotted¶
http://pypi.python.org/pypi/sphinxjp.themes.dotted/
インストール方法例:
pip install sphinxjp.themes.dotted
conf.pyの書き換え:
html_theme = 'dotted'
sphinxjp.themes.sphinxjp¶
http://pypi.python.org/pypi/sphinxjp.themes.sphinxjp/
インストール方法例:
pip install sphinxjp.themes.sphinxjp
conf.pyの書き換え:
html_theme = 'sphinxjp'
sphinxjp.themes.trstyle¶
http://pypi.python.org/pypi/sphinxjp.themes.trstyle/
インストール方法例:
pip install sphinxjp.themes.trstyle
conf.pyの書き換え:
html_theme = 'trstyle'
sphinxjp.themes.basicstrap¶
https://pypi.python.org/pypi/sphinxjp.themes.basicstrap/
インストール方法例:
pip install sphinxjp.themes.basicstrap
conf.pyの書き換え:
html_theme = 'basicstrap' # 下記オプションで内部テーマを変更する事が可能です。※必須ではありません # また、これ以外にも細かい設定変更が可能です。 html_theme_options = { 'inner_theme': True, 'inner_theme_name': 'bootswatch-amelia', }
また、細かく設定を変更すれば、フォントサイズの変更や Google Web Fonts の利用、 Bootswatch の各種テーマの利用ができます。詳しくは、ドキュメント や作者ブログ記事( 0.2.0リリース / 0.3.0リリース )もご覧ください。
以下、利用できるテーマの一覧です。
bootswatch-amelia |
bootswatch-cerulean |
bootswatch-cosmo |
bootswatch-cyborg |
bootswatch-flatly |
bootswatch-journal |
bootswatch-readable |
bootswatch-simplex |
bootswatch-slate |
bootswatch-spacelab |
bootswatch-united |
|
bootswatch-spruce |
bootswatch-superhero |
geo-bootstrap |
mitsuhiko / flask-sphinx-themes¶
https://github.com/mitsuhiko/flask-sphinx-themes
- インストール方法例
このテーマは手動でインストールが必要です。
githubからソースを取得する:
git clone https://github.com/mitsuhiko/flask-sphinx-themes.git
gitについて良くわからない場合は、githubの「Download ZIP」のボタンからダウンロードしても構いません。
sourceフォルダ直下に「_themes」フォルダを作成し、以下のように配置する。(flask以外にflask_smallもあり):
source/_themes/flask/theme.conf
conf.pyの書き換え:
# 出来るだけ先頭に以下を記述する。 sys.path.append(os.path.abspath('_themes')) html_theme = 'flask' html_theme_path = ['_themes']
詳しくは、githubページのREADMEをご覧ください。
Pylons / pylons_sphinx_theme¶
https://github.com/Pylons/pylons_sphinx_theme
- インストール方法例
このテーマは手動でインストールが必要です。
githubからソースを取得する:
git clone https://github.com/Pylons/pylons_sphinx_theme.git
gitについて良くわからない場合は、githubの「Download ZIP」のボタンからダウンロードしても構いません。
sourceフォルダ直下に「_themes」フォルダを作成し、以下のように配置する。(pylons以外にpylonsfwやpyramidもあり)
source/_themes/pylons/theme.conf
conf.pyの書き換え:
# 出来るだけ先頭に以下を記述する。 sys.path.append(os.path.abspath('_themes')) html_theme = 'pylons' html_theme_path = ['_themes']
詳しくは、githubページのREADMEをご覧ください。
kellycreativetech / proBlue¶
https://github.com/kellycreativetech/proBlue
- インストール方法例
このテーマは手動でインストールが必要です。
githubからソースを取得する:
git clone https://github.com/kellycreativetech/proBlue.git
gitについて良くわからない場合は、githubの「Download ZIP」のボタンからダウンロードしても構いません。
sourceフォルダ直下に「_themes」フォルダを作成し、以下のように配置する。(proBlueフォルダは自分で作る)
source/_themes/proBlue/theme.conf
conf.pyの書き換え:
# 出来るだけ先頭に以下を記述する。 sys.path.append(os.path.abspath('_themes')) html_theme = 'proBlue' html_theme_path = ['_themes']
詳しくは、githubページのREADMEをご覧ください。
脚注