Skip to content

Commit 554d438

Browse files
author
Jonathan Corbet
committed
Merge branch 'alabaster-rb' into docs-mw
For a long time we have rejoiced that our HTML output from Sphinx is far better than what we got from the old DocBook toolchain. But it still leaves a lot to be desired; the following is an attempt to improve the situation somewhat. Sphinx has a theming mechanism for HTML rendering. Since the kernel's adoption of Sphinx, we have been using the "Read The Docs" theme — a choice made in a bit of a hurry to have *something* while figuring out the rest. RTD is OK, but it is not hugely attractive, requires the installation of an extra package, and does not observe all of the Sphinx configuration parameters. Among other things, that makes it hard to put reasonable contents into the left column in the HTML output. The Alabaster theme is the default for Sphinx installations, and is bundled with Sphinx itself. It has (IMO) nicer output and gives us the control that we need. So: switch to Alabaster. Additional patches adjust the documentation and remove the RTD references from scripts/sphinx-pre-install. The penultimate patch changes the way that kerneldoc declarations are rendered to (IMO) improve readability. That requires some changes to kernel-doc to output a new container block and some CSS tweaks to improve things overall. It should be noted that I have a long history of inflicting ugly web designs on the net; this work is a start, but I think we could do far better yet. It would be great if somebody who actually enjoys working with CSS and such would help to improve what we have.
2 parents 9abf231 + 02d33e8 commit 554d438

6 files changed

Lines changed: 93 additions & 220 deletions

File tree

Documentation/conf.py

Lines changed: 27 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,24 @@ def have_command(cmd):
194194
else:
195195
version = release = "unknown version"
196196

197+
#
198+
# HACK: there seems to be no easy way for us to get at the version and
199+
# release information passed in from the makefile...so go pawing through the
200+
# command-line options and find it for ourselves.
201+
#
202+
def get_cline_version():
203+
c_version = c_release = ''
204+
for arg in sys.argv:
205+
if arg.startswith('version='):
206+
c_version = arg[8:]
207+
elif arg.startswith('release='):
208+
c_release = arg[8:]
209+
if c_version:
210+
if c_release:
211+
return c_version + '-' + c_release
212+
return c_version
213+
return version # Whatever we came up with before
214+
197215
# The language for content autogenerated by Sphinx. Refer to documentation
198216
# for a list of supported languages.
199217
#
@@ -247,7 +265,7 @@ def have_command(cmd):
247265
# a list of builtin themes.
248266

249267
# Default theme
250-
html_theme = 'sphinx_rtd_theme'
268+
html_theme = 'alabaster'
251269
html_css_files = []
252270

253271
if "DOCS_THEME" in os.environ:
@@ -279,7 +297,7 @@ def have_command(cmd):
279297
html_css_files.append('theme_rtd_colors.css')
280298

281299
except ImportError:
282-
html_theme = 'classic'
300+
html_theme = 'alabaster'
283301

284302
if "DOCS_CSS" in os.environ:
285303
css = os.environ["DOCS_CSS"].split(" ")
@@ -295,127 +313,28 @@ def have_command(cmd):
295313
for l in html_css_files:
296314
html_context['css_files'].append('_static/' + l)
297315

298-
if html_theme == 'classic':
316+
if html_theme == 'alabaster':
299317
html_theme_options = {
300-
'rightsidebar': False,
301-
'stickysidebar': True,
302-
'collapsiblesidebar': True,
303-
'externalrefs': False,
304-
305-
'footerbgcolor': "white",
306-
'footertextcolor': "white",
307-
'sidebarbgcolor': "white",
308-
'sidebarbtncolor': "black",
309-
'sidebartextcolor': "black",
310-
'sidebarlinkcolor': "#686bff",
311-
'relbarbgcolor': "#133f52",
312-
'relbartextcolor': "white",
313-
'relbarlinkcolor': "white",
314-
'bgcolor': "white",
315-
'textcolor': "black",
316-
'headbgcolor': "#f2f2f2",
317-
'headtextcolor': "#20435c",
318-
'headlinkcolor': "#c60f0f",
319-
'linkcolor': "#355f7c",
320-
'visitedlinkcolor': "#355f7c",
321-
'codebgcolor': "#3f3f3f",
322-
'codetextcolor': "white",
323-
324-
'bodyfont': "serif",
325-
'headfont': "sans-serif",
318+
'description': get_cline_version(),
319+
'font_size': '10pt',
320+
'page_width': '65em',
321+
'sidebar_width': '15em',
326322
}
327323

328324
sys.stderr.write("Using %s theme\n" % html_theme)
329325

330-
# Theme options are theme-specific and customize the look and feel of a theme
331-
# further. For a list of options available for each theme, see the
332-
# documentation.
333-
#html_theme_options = {}
334-
335-
# Add any paths that contain custom themes here, relative to this directory.
336-
#html_theme_path = []
337-
338-
# The name for this set of Sphinx documents. If None, it defaults to
339-
# "<project> v<release> documentation".
340-
#html_title = None
341-
342-
# A shorter title for the navigation bar. Default is the same as html_title.
343-
#html_short_title = None
344-
345-
# The name of an image file (relative to this directory) to place at the top
346-
# of the sidebar.
347-
#html_logo = None
348-
349-
# The name of an image file (within the static path) to use as favicon of the
350-
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
351-
# pixels large.
352-
#html_favicon = None
353-
354326
# Add any paths that contain custom static files (such as style sheets) here,
355327
# relative to this directory. They are copied after the builtin static files,
356328
# so a file named "default.css" will overwrite the builtin "default.css".
357329
html_static_path = ['sphinx-static']
358330

359-
# Add any extra paths that contain custom files (such as robots.txt or
360-
# .htaccess) here, relative to this directory. These files are copied
361-
# directly to the root of the documentation.
362-
#html_extra_path = []
363-
364-
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
365-
# using the given strftime format.
366-
#html_last_updated_fmt = '%b %d, %Y'
367-
368331
# If true, SmartyPants will be used to convert quotes and dashes to
369332
# typographically correct entities.
370333
html_use_smartypants = False
371334

372335
# Custom sidebar templates, maps document names to template names.
373-
# Note that the RTD theme ignores this.
374-
html_sidebars = { '**': ['searchbox.html', 'localtoc.html', 'sourcelink.html']}
375-
376-
# Additional templates that should be rendered to pages, maps page names to
377-
# template names.
378-
#html_additional_pages = {}
379-
380-
# If false, no module index is generated.
381-
#html_domain_indices = True
382-
383-
# If false, no index is generated.
384-
#html_use_index = True
385-
386-
# If true, the index is split into individual pages for each letter.
387-
#html_split_index = False
388-
389-
# If true, links to the reST sources are added to the pages.
390-
#html_show_sourcelink = True
391-
392-
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
393-
#html_show_sphinx = True
394-
395-
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
396-
#html_show_copyright = True
397-
398-
# If true, an OpenSearch description file will be output, and all pages will
399-
# contain a <link> tag referring to it. The value of this option must be the
400-
# base URL from which the finished HTML is served.
401-
#html_use_opensearch = ''
402-
403-
# This is the file name suffix for HTML files (e.g. ".xhtml").
404-
#html_file_suffix = None
405-
406-
# Language to be used for generating the HTML full-text search index.
407-
# Sphinx supports the following languages:
408-
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
409-
# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
410-
#html_search_language = 'en'
411-
412-
# A dictionary with options for the search language support, empty by default.
413-
# Now only 'ja' uses this config value
414-
#html_search_options = {'type': 'default'}
415-
416-
# The name of a javascript file (relative to the configuration directory) that
417-
# implements a search results scorer. If empty, the default will be used.
418-
#html_search_scorer = 'scorer.js'
336+
# Note that the RTD theme ignores this
337+
html_sidebars = { '**': ["about.html", 'searchbox.html', 'localtoc.html', 'sourcelink.html']}
419338

420339
# Output file base name for HTML help builder.
421340
htmlhelp_basename = 'TheLinuxKerneldoc'
@@ -558,19 +477,6 @@ def have_command(cmd):
558477
'Miscellaneous'),
559478
]
560479

561-
# Documents to append as an appendix to all manuals.
562-
#texinfo_appendices = []
563-
564-
# If false, no module index is generated.
565-
#texinfo_domain_indices = True
566-
567-
# How to display URL addresses: 'footnote', 'no', or 'inline'.
568-
#texinfo_show_urls = 'footnote'
569-
570-
# If true, do not generate a @detailmenu in the "Top" node's menu.
571-
#texinfo_no_detailmenu = False
572-
573-
574480
# -- Options for Epub output ----------------------------------------------
575481

576482
# Bibliographic Dublin Core info.
@@ -579,67 +485,9 @@ def have_command(cmd):
579485
epub_publisher = author
580486
epub_copyright = copyright
581487

582-
# The basename for the epub file. It defaults to the project name.
583-
#epub_basename = project
584-
585-
# The HTML theme for the epub output. Since the default themes are not
586-
# optimized for small screen space, using the same theme for HTML and epub
587-
# output is usually not wise. This defaults to 'epub', a theme designed to save
588-
# visual space.
589-
#epub_theme = 'epub'
590-
591-
# The language of the text. It defaults to the language option
592-
# or 'en' if the language is not set.
593-
#epub_language = ''
594-
595-
# The scheme of the identifier. Typical schemes are ISBN or URL.
596-
#epub_scheme = ''
597-
598-
# The unique identifier of the text. This can be a ISBN number
599-
# or the project homepage.
600-
#epub_identifier = ''
601-
602-
# A unique identification for the text.
603-
#epub_uid = ''
604-
605-
# A tuple containing the cover image and cover page html template filenames.
606-
#epub_cover = ()
607-
608-
# A sequence of (type, uri, title) tuples for the guide element of content.opf.
609-
#epub_guide = ()
610-
611-
# HTML files that should be inserted before the pages created by sphinx.
612-
# The format is a list of tuples containing the path and title.
613-
#epub_pre_files = []
614-
615-
# HTML files that should be inserted after the pages created by sphinx.
616-
# The format is a list of tuples containing the path and title.
617-
#epub_post_files = []
618-
619488
# A list of files that should not be packed into the epub file.
620489
epub_exclude_files = ['search.html']
621490

622-
# The depth of the table of contents in toc.ncx.
623-
#epub_tocdepth = 3
624-
625-
# Allow duplicate toc entries.
626-
#epub_tocdup = True
627-
628-
# Choose between 'default' and 'includehidden'.
629-
#epub_tocscope = 'default'
630-
631-
# Fix unsupported image types using the Pillow.
632-
#epub_fix_images = False
633-
634-
# Scale large images.
635-
#epub_max_image_width = 0
636-
637-
# How to display URL addresses: 'footnote', 'no', or 'inline'.
638-
#epub_show_urls = 'inline'
639-
640-
# If false, no index is generated.
641-
#epub_use_index = True
642-
643491
#=======
644492
# rst2pdf
645493
#

Documentation/doc-guide/sphinx.rst

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,9 @@ section of ``make help``. The generated documentation is placed in
147147
format-specific subdirectories under ``Documentation/output``.
148148

149149
To generate documentation, Sphinx (``sphinx-build``) must obviously be
150-
installed. For prettier HTML output, the Read the Docs Sphinx theme
151-
(``sphinx_rtd_theme``) is used if available. For PDF output you'll also need
152-
``XeLaTeX`` and ``convert(1)`` from ImageMagick
153-
(https://www.imagemagick.org).\ [#ink]_
154-
All of these are widely available and packaged in distributions.
150+
installed. For PDF output you'll also need ``XeLaTeX`` and ``convert(1)``
151+
from ImageMagick (https://www.imagemagick.org).\ [#ink]_ All of these are
152+
widely available and packaged in distributions.
155153

156154
To pass extra options to Sphinx, you can use the ``SPHINXOPTS`` make
157155
variable. For example, use ``make SPHINXOPTS=-v htmldocs`` to get more verbose
@@ -160,12 +158,8 @@ output.
160158
It is also possible to pass an extra DOCS_CSS overlay file, in order to customize
161159
the html layout, by using the ``DOCS_CSS`` make variable.
162160

163-
By default, the build will try to use the Read the Docs sphinx theme:
164-
165-
https://github.com/readthedocs/sphinx_rtd_theme
166-
167-
If the theme is not available, it will fall-back to the classic one.
168-
161+
By default, the "Alabaster" theme is used to build the HTML documentation;
162+
this theme is bundled with Sphinx and need not be installed separately.
169163
The Sphinx theme can be overridden by using the ``DOCS_THEME`` make variable.
170164

171165
There is another make variable ``SPHINXDIRS``, which is useful when test
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* CSS tweaks for the Alabaster theme
4+
*/
5+
6+
/* Shrink the headers a bit */
7+
div.body h1 { font-size: 180%; }
8+
div.body h2 { font-size: 150%; }
9+
div.body h3 { font-size: 130%; }
10+
11+
/* Tighten up the layout slightly */
12+
div.body { padding: 0 15px 0 10px; }
13+
div.sphinxsidebarwrapper { padding: 1em 0.4em; }
14+
/* Tweak document margins and don't force width */
15+
div.document {
16+
margin: 20px 10px 0 10px;
17+
width: auto;
18+
}
19+
20+
/*
21+
* Parameters for the display of function prototypes and such included
22+
* from C source files.
23+
*/
24+
dl.function, dl.struct, dl.enum { margin-top: 2em; background-color: #ecf0f3; }
25+
/* indent lines 2+ of multi-line function prototypes */
26+
dl.function dt { margin-left: 10em; text-indent: -10em; }
27+
dt.sig-object { font-size: larger; }
28+
div.kernelindent { margin-left: 2em; margin-right: 4em; }
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# jinja2>=3.1 is not compatible with Sphinx<4.0
22
jinja2<3.1
3-
sphinx_rtd_theme
43
Sphinx==2.4.4

0 commit comments

Comments
 (0)