Skip to contentSkip to conversation

RFC: sphinx: adopt kernel readthedoc theme

PATCH Superseded [email protected] 4 participants 5 messages Nov 5, 2020 – Jan 20, 2021

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RFC: sphinx: adopt kernel readthedoc theme

From: Marc-André Lureau <[email protected]>

The default "alabaster" sphinx theme has a couple shortcomings:
- the navbar moves along the page
- the search bar is not always at the same place
- it lacks some contrast and colours

The "rtd" theme from readthedocs.org is a popular third party theme used notably by the kernel, with a custom style sheet. I like it better, perhaps others do too. It also has features that may come handy, such as "Edit on Gitlab".

Tweak the nav header background to match qemu.org style, use the QEMU logo, and favicon.

The html_theme_options['description'] workaround doesn't seem necessary.

---
 docs/conf.py                           |  36 +++----
 docs/devel/conf.py                     |   4 -
 docs/interop/conf.py                   |   4 -
 docs/specs/conf.py                     |   5 -
 docs/sphinx-static/theme_overrides.css | 137 +++++++++++++++++++++++++
 docs/system/conf.py                    |   4 -
 docs/tools/conf.py                     |   5 -
 docs/user/conf.py                      |   4 -
 8 files changed, 155 insertions(+), 44 deletions(-)
 create mode 100644 docs/sphinx-static/theme_overrides.css
docs/conf.py +18 -18
index e584f68393..54c4e1e687 100644
@@ -150,37 +150,37 @@ with open(os.path.join(qemu_docdir, 'defs.rst.inc')) as f:
 # The theme to use for HTML and HTML Help pages.  See the documentation for
 # a list of builtin themes.
 #
-html_theme = 'alabaster'
+try:
+    import sphinx_rtd_theme
+    html_theme = 'sphinx_rtd_theme'
+except ImportError:
+    sys.stderr.write('Warning: The Sphinx \'sphinx_rtd_theme\' HTML theme was not found. Make sure you have the theme installed to produce pretty HTML output. Falling back to the default theme.\n')
 
 # 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.
-# We initialize this to empty here, so the per-manual conf.py can just
-# add individual key/value entries.
 html_theme_options = {
+    "style_nav_header_background": "#802400",
 }
 
+html_logo = os.path.join(qemu_docdir, "../ui/icons/qemu_128x128.png")
+
+html_favicon = os.path.join(qemu_docdir, "../ui/icons/qemu_32x32.png")
+
 # 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".
-# QEMU doesn't yet have any static files, so comment this out so we don't
-# get a warning about a missing directory.
-# If we do ever add this then it would probably be better to call the
-# subdirectory sphinx_static, as the Linux kernel does.
-# html_static_path = ['_static']
+html_static_path = [os.path.join(qemu_docdir, "sphinx-static")]
+
+html_context = {
+    'css_files': [
+        '_static/theme_overrides.css',
+    ],
+}
 
 # Custom sidebar templates, must be a dictionary that maps document names
 # to template names.
-#
-# This is required for the alabaster theme
-# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
-html_sidebars = {
-    '**': [
-        'about.html',
-        'navigation.html',
-        'searchbox.html',
-    ]
-}
+#html_sidebars = {}
 
 # Don't copy the rST source files to the HTML output directory,
 # and don't put links to the sources into the output HTML.
docs/devel/conf.py +0 -4
index 7441f87e7f..f0905b728b 100644
@@ -9,7 +9,3 @@ import os
 qemu_docdir = os.path.abspath("..")
 parent_config = os.path.join(qemu_docdir, "conf.py")
 exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
-
-# This slightly misuses the 'description', but is the best way to get
-# the manual title to appear in the sidebar.
-html_theme_options['description'] = u'Developer''s Guide'
docs/interop/conf.py +0 -4
index 2634ca3410..97d9e8c116 100644
@@ -10,10 +10,6 @@ qemu_docdir = os.path.abspath("..")
 parent_config = os.path.join(qemu_docdir, "conf.py")
 exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
 
-# This slightly misuses the 'description', but is the best way to get
-# the manual title to appear in the sidebar.
-html_theme_options['description'] = u'System Emulation Management and Interoperability Guide'
-
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
docs/specs/conf.py +0 -5
index 4d56f3ae13..1be2d3bd20 100644
@@ -9,8 +9,3 @@ import os
 qemu_docdir = os.path.abspath("..")
 parent_config = os.path.join(qemu_docdir, "conf.py")
 exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
-
-# This slightly misuses the 'description', but is the best way to get
-# the manual title to appear in the sidebar.
-html_theme_options['description'] = \
-    u'System Emulation Guest Hardware Specifications'
docs/sphinx-static/theme_overrides.css new file +137 -0

137 lines not on this page · raw message

docs/system/conf.py +0 -4
index 6251849fef..847cd87fa2 100644
@@ -10,10 +10,6 @@ qemu_docdir = os.path.abspath("..")
 parent_config = os.path.join(qemu_docdir, "conf.py")
 exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
 
-# This slightly misuses the 'description', but is the best way to get
-# the manual title to appear in the sidebar.
-html_theme_options['description'] = u'System Emulation User''s Guide'
-
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
docs/tools/conf.py +0 -5
index 9052d17d6d..a11923a786 100644
@@ -10,11 +10,6 @@ qemu_docdir = os.path.abspath("..")
 parent_config = os.path.join(qemu_docdir, "conf.py")
 exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
 
-# This slightly misuses the 'description', but is the best way to get
-# the manual title to appear in the sidebar.
-html_theme_options['description'] = \
-    u'Tools Guide'
-
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
docs/user/conf.py +0 -4
index 4b09aedd45..7b89273d43 100644
@@ -9,7 +9,3 @@ import os
 qemu_docdir = os.path.abspath("..")
 parent_config = os.path.join(qemu_docdir, "conf.py")
 exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
-
-# This slightly misuses the 'description', but is the best way to get
-# the manual title to appear in the sidebar.
-html_theme_options['description'] = u'User Mode Emulation User''s Guide'
Signature · 1 line
2.29.0
#1 lore raw
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [PATCH] RFC: sphinx: adopt kernel readthedoc theme

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
- [tag update] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
6c91276 RFC: sphinx: adopt kernel readthedoc theme

=== OUTPUT BEGIN ===
ERROR: line over 90 characters
#38: FILE: docs/conf.py:157:
+ sys.stderr.write('Warning: The Sphinx \'sphinx_rtd_theme\' HTML theme was not found. Make sure you have the theme installed to produce pretty HTML output. Falling back to the default theme.\n')

WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #126:
new file mode 100644

total: 1 errors, 1 warnings, 232 lines checked

Commit 6c912763d717 (RFC: sphinx: adopt kernel readthedoc theme) has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#2 lore raw
In reply to [email protected]

Hi,

Quoted 19 lines · On Thu, Nov 5, 2020 at 8:03 PM <[email protected]> wrote:

From: Marc-André Lureau <[email protected]>

The default "alabaster" sphinx theme has a couple shortcomings:
- the navbar moves along the page
- the search bar is not always at the same place
- it lacks some contrast and colours

The "rtd" theme from readthedocs.org is a popular third party theme used notably by the kernel, with a custom style sheet. I like it better, perhaps others do too. It also has features that may come handy, such as "Edit on Gitlab".

Tweak the nav header background to match qemu.org style, use the QEMU logo, and favicon.

The html_theme_options['description'] workaround doesn't seem necessary.

Quoted 12 lines
---
 docs/conf.py                           |  36 +++----
 docs/devel/conf.py                     |   4 -
 docs/interop/conf.py                   |   4 -
 docs/specs/conf.py                     |   5 -
 docs/sphinx-static/theme_overrides.css | 137 +++++++++++++++++++++++++
 docs/system/conf.py                    |   4 -
 docs/tools/conf.py                     |   5 -
 docs/user/conf.py                      |   4 -
 8 files changed, 155 insertions(+), 44 deletions(-)
 create mode 100644 docs/sphinx-static/theme_overrides.css

Am I the only one finding the default sphinx theme inferior to rtd ?

thanks

#3 lore raw
Quoted 35 lines · Marc-André Lureau

Hi,

Quoted 29 lines · On Thu, Nov 5, 2020 at 8:03 PM <[email protected]> wrote:

From: Marc-André Lureau <[email protected]>

The default "alabaster" sphinx theme has a couple shortcomings:
- the navbar moves along the page
- the search bar is not always at the same place
- it lacks some contrast and colours

The "rtd" theme from readthedocs.org is a popular third party theme used notably by the kernel, with a custom style sheet. I like it better, perhaps others do too. It also has features that may come handy, such as "Edit on Gitlab".

Tweak the nav header background to match qemu.org style, use the QEMU logo, and favicon.

The html_theme_options['description'] workaround doesn't seem necessary.

---
  docs/conf.py                           |  36 +++----
  docs/devel/conf.py                     |   4 -
  docs/interop/conf.py                   |   4 -
  docs/specs/conf.py                     |   5 -
  docs/sphinx-static/theme_overrides.css | 137 +++++++++++++++++++++++++
  docs/system/conf.py                    |   4 -
  docs/tools/conf.py                     |   5 -
  docs/user/conf.py                      |   4 -
  8 files changed, 155 insertions(+), 44 deletions(-)
Quoted 2 lines

create mode 100644 docs/sphinx-static/theme_overrides.css

Quoted 5 lines

Am I the only one finding the default sphinx theme inferior to rtd ?

thanks

Probably not, but do you have some screenshots or examples of before/after?

--js

#4 lore raw
In reply to Marc-André Lureau
Quoted 36 lines · Marc-André Lureau

Hi,

Quoted 19 lines · On Thu, Nov 5, 2020 at 8:03 PM <[email protected]> wrote:

From: Marc-André Lureau <[email protected]>

The default "alabaster" sphinx theme has a couple shortcomings:
- the navbar moves along the page
- the search bar is not always at the same place
- it lacks some contrast and colours

The "rtd" theme from readthedocs.org is a popular third party theme used notably by the kernel, with a custom style sheet. I like it better, perhaps others do too. It also has features that may come handy, such as "Edit on Gitlab".

Tweak the nav header background to match qemu.org style, use the QEMU logo, and favicon.

The html_theme_options['description'] workaround doesn't seem necessary.

Quoted 12 lines
---
 docs/conf.py                           |  36 +++----
 docs/devel/conf.py                     |   4 -
 docs/interop/conf.py                   |   4 -
 docs/specs/conf.py                     |   5 -
 docs/sphinx-static/theme_overrides.css | 137 +++++++++++++++++++++++++
 docs/system/conf.py                    |   4 -
 docs/tools/conf.py                     |   5 -
 docs/user/conf.py                      |   4 -
 8 files changed, 155 insertions(+), 44 deletions(-)
 create mode 100644 docs/sphinx-static/theme_overrides.css
Quoted 1 line

Am I the only one finding the default sphinx theme inferior to rtd ?

Of course not!

This patch does not apply on top of current HEAD. Could you please rebase?

Regards,
Bin