0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Sphinxのテーマ"Read the Docs"のカスタマイズ

Posted at

目的

  • sphinx_rtd_themeの横幅を広げる(など)
  • property属性が1行に詰め込まれてレイアウトされるのを防ぐ

仕掛け

docs/source/_static/css/custom_sphinx_rtd_theme.css
/*
 * 「Sphinx の sphinx_rtd_theme をカスタマイズする」
 * https://kuttsun.blogspot.com/2016/11/sphinx-sphinxrtdtheme.html
 */

.wy-nav-content {
    max-width: 1600px;
}

h1,h2,h3,h4,h5,h6 {
    border-bottom: 1px solid #ccc;
}

.wy-table-responsive table td, .wy-table-responsive table th {
    white-space: normal;
}

colgroup {
    display: none;
}
docs/source/_static/css/fix-layout-pyproperty.css
/*
 * py:property's stacking on a single line on larger screen widths.
 * https://github.com/readthedocs/sphinx_rtd_theme/issues/1301
 *
 * > Problem
 * > Multiple properties I defined in the docs are all stacking on a single line.
 * > (ドキュメントで定義した複数のプロパティがすべて1行に重なっている)
 *
 * https://github.com/readthedocs/sphinx_rtd_theme/issues/1301#issuecomment-1219961515
 * https://gist.github.com/nocarryr/846301fd5c9083e2243346d19e55b5a3#file-override-css
 */

dl.py.property {
    display: block !important;
}
  • sphinx-apidoc -Fコマンドで生成されるconf.pyに以下を設定
docs/source/conf.py
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
html_css_files = ['css/custom_sphinx_rtd_theme.css', 'css/fix-layout-pyproperty.css']

参考URL

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?