History log of /linux-master/Documentation/conf.py
Revision Date Author Comments
# ca7e324e 27-Mar-2024 Alexander Lobakin <aleksander.lobakin@intel.com>

compiler_types: add Endianness-dependent __counted_by_{le,be}

Some structures contain flexible arrays at the end and the counter for
them, but the counter has explicit Endianness and thus __counted_by()
can't be used directly.

To increase test coverage for potential problems without breaking
anything, introduce __counted_by_{le,be}() defined depending on
platform's Endianness to either __counted_by() when applicable or noop
otherwise.
Maybe it would be a good idea to introduce such attributes on compiler
level if possible, but for now let's stop on what we have.

Acked-by: Kees Cook <keescook@chromium.org>
Acked-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Link: https://lore.kernel.org/r/20240327142241.1745989-2-aleksander.lobakin@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>


# fe256258 25-Feb-2024 Akira Yokosawa <akiyks@gmail.com>

docs: Restore "smart quotes" for quotes

Commit eaae75754d81 ("docs: turn off "smart quotes" in the HTML build")
disabled conversion of quote marks along with that of dashes.
Despite the short summary, the change affects not only HTML build
but also other build targets including PDF.

However, as "smart quotes" had been enabled for more than half a
decade already, quite a few readers of HTML pages are likely expecting
conversions of "foo" -> “foo” and 'bar' -> ‘bar’.

Furthermore, in LaTeX typesetting convention, it is common to use
distinct marks for opening and closing quote marks.

To satisfy such readers' expectation, restore conversion of quotes
only by setting smartquotes_action [1].

Link: [1] https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-smartquotes_action
Cc: stable@vger.kernel.org # v6.4
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20240225094600.65628-1-akiyks@gmail.com


# 0df8669f 19-Feb-2024 Jonathan Corbet <corbet@lwn.net>

docs: Instruct LaTeX to cope with deeper nesting

The addition of the XFS online fsck documentation starting with
commit a8f6c2e54ddc ("xfs: document the motivation for online fsck design")
added a deeper level of nesting than LaTeX is prepared to deal with. That
caused a pdfdocs build failure with the helpful "Too deeply nested" error
message buried deeply in Documentation/output/filesystems.log.

Increase the "maxlistdepth" parameter to instruct LaTeX that it needs to
deal with the deeper nesting whether it wants to or not.

Suggested-by: Akira Yokosawa <akiyks@gmail.com>
Tested-by: Akira Yokosawa <akiyks@gmail.com>
Cc: stable@vger.kernel.org # v6.4+
Link: https://lore.kernel.org/linux-doc/67f6ac60-7957-4b92-9d72-a08fbad0e028@gmail.com/
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 7418ec5b 15-Dec-2023 Vegard Nossum <vegard.nossum@oracle.com>

docs: translations: add translations links when they exist

Add a new Sphinx extension that knows about the translations of kernel
documentation and can insert links to the translations at the top of
the document.

It basically works like this:

1. Register a new node type, LanguagesNode.

2. Register a new transform, TranslationsTransform, that inserts a new
LanguageNode at the top of every document. The LanguageNode contains
"pending references" to translations of the document. The key here
is that these are pending (i.e. unresolved) references that may or
may not actually exist.

3. Register a 'doctree-resolved' event that iterates over all the
LanguageNode nodes. Any unresolved references are filtered out; the
list of resolved references is passed to the 'translations.html'
template and rendered as an HTML node (if HTML output is selected).

Testing: make htmldocs, make latexdocs with Sphinx v4.3.2 and Firefox.

v2:
- changed bar into a drop-down menu
- fixed language labels
- fixed hysteresis reported by Akira Yokosawa

Cc: Federico Vaga <federico.vaga@vaga.pv.it>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Akira Yokosawa <akiyks@gmail.com>
Cc: Yanteng Si <siyanteng@loongson.cn>
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20231215123701.2712807-1-vegard.nossum@oracle.com


# eeddfa5b 14-Dec-2023 Kees Cook <keescook@chromium.org>

docs: conf.py: Ignore __counted_by attribute

It seems that Sphinx is confused by the __counted_by attribute on struct
members. Add it to the list of known attributes.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202312150614.kOx8xUkr-lkp@intel.com/
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: linux-doc@vger.kernel.org
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20231215001347.work.151-kees@kernel.org


# 3e893e16 08-Dec-2023 Jonathan Corbet <corbet@lwn.net>

docs: Raise the minimum Sphinx requirement to 2.4.4

Commit 31abfdda6527 (docs: Deprecate use of Sphinx < 2.4.x) in 6.2 added a
warning that support for older versions of Sphinx would be going away.
There have been no complaints, so the time has come. Raise the minimum
Sphinx version to 2.4.4 and clean out some compatibility code that we no
longer need.

Reviewed-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Link: https://lore.kernel.org/r/874jgs47fq.fsf@meer.lwn.net
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# d49af114 29-Oct-2023 Vegard Nossum <vegard.nossum@oracle.com>

Documentation: add tux logo

We already have the logo, let's use it.

Testing: make htmldocs

Cc: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20231029074207.297663-1-vegard.nossum@oracle.com


# 34d9f62e 09-May-2023 James Seo <james@equiv.tech>

Documentation: conf.py: Add __force to c_id_attributes

Fixes the following error in the docs build that occurs with recent
versions of Sphinx when parsing kerneldocs for a function with the
'__force' macro in its signature:

./include/linux/err.h:51: WARNING: Error in declarator or parameters
Error in declarator or parameters
Invalid C declaration: Expected identifier, got keyword: void [error at 35]
void * ERR_CAST (__force const void *ptr)
-----------------------------------^

Currently, almost all of the few in-signature occurrences of '__force'
are in the error pointer functions. Of those, ERR_CAST() is the only
one with kerneldocs, but the kerneldocs aren't even being used to
generate documentation. This change will allow all the error pointer
functions to be properly documented.

In addition to '__force', <linux/compiler_types.h> also defines
'__nocast', '__safe', and '__private'. These are not currently used in
any function signatures and do not need to be added to the docs config.

Signed-off-by: James Seo <james@equiv.tech>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20230509175543.2065835-2-james@equiv.tech


# eaae7575 20-Apr-2023 Jonathan Corbet <corbet@lwn.net>

docs: turn off "smart quotes" in the HTML build

We have long disabled the "html_use_smartypants" option to prevent Sphinx
from mangling "--" sequences (among others). Unfortunately, Sphinx changed
that option to "smartquotes" in the 1.6.6 release, and seemingly didn't see
fit to warn about the use of the obsolete option, resulting in the
aforementioned mangling returning. Disable this behavior again and hope
that the option name stays stable for a while.

Reported-by: Zipeng Zhang <zhangzipeng0@foxmail.com>
Link: https://lore.kernel.org/lkml/tencent_CB1A298D31FD221496FF657CD7EF406E6605@qq.com
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# c404f5d4 19-Jan-2023 Jonathan Corbet <corbet@lwn.net>

docs: Add more information to the HTML sidebar

Add a new sidebar template that creates a more RTD-like "fisheye" view of
the current place in the document hierarchy. It is far from ideal, but
some readers may find it better for navigating through the documentation as
a whole.

Add some CSS trickery as well to make the table of contents less intrusive
when viewing the pages on a small screen.

Reviewed-by: Akira Yokosawa <akiyks@gmail.com>
Reviewed-by: David Gow <davidgow@google.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 98e6ab7a 01-Feb-2023 David Vernet <void@manifault.com>

bpf: Document usage of the new __bpf_kfunc macro

Now that the __bpf_kfunc macro has been added to linux/btf.h, include a
blurb about it in the kfuncs.rst file. In order for the macro to
successfully render with .. kernel-doc, we'll also need to add it to the
c_id_attributes array.

Signed-off-by: David Vernet <void@manifault.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/bpf/20230201173016.342758-3-void@manifault.com


# a33ae832 10-Jan-2023 Akira Yokosawa <akiyks@gmail.com>

docs/conf.py: Use about.html only in sidebar of alabaster theme

"about.html" is available only for the alabaster theme [1].
Unconditionally putting it to html_sidebars prevents us from
using other themes which respect html_sidebars.

Remove about.html from the initialization and insert it at the
front for the alabaster theme.

Link: [1] https://alabaster.readthedocs.io/en/latest/installation.html#sidebars
Fixes: d5389d3145ef ("docs: Switch the default HTML theme to alabaster")
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Link: https://lore.kernel.org/r/4b162dbe-2a7f-1710-93e0-754cf8680aae@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 31abfdda 04-Jan-2023 Jonathan Corbet <corbet@lwn.net>

docs: Deprecate use of Sphinx < 2.4.x

The Sphinx 2.4 release is three years old, and it is becoming increasingly
difficult to even find a system with an sufficiently archaic Python
installation that can run versions older than that. I can no longer test
changes against anything prior to 2.4.x.

Move toward raising our minimum Sphinx requirement to 2.4.x so we can
delete some older support code and claim to support a range of versions
that we can actually test.

In the absence of screams, the actual removal of support can happen later
in 2023.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# e17f2260 07-Nov-2022 Daniel Vetter <daniel.vetter@ffwll.ch>

docs/sphinx: More depth in the rtd sidebar toc

We love to nest our documenation for good structure, but that means
the table of contents needs to keep up or you can't navigate them.

Realized this trying to find the drm property documentation, which
with some shuffling around disappeared. Why I didn't realize we can do
this earlier, no idea.

Since the relevant parts of the toc are only loaded if you're in the
right .html file there's no harm in going all the way to unlimited.

Note that this has no impact on the alabaster theme (which has a much
simpler sidebar toc which doesn't show the entire hierarchy, only
what's in the local rendered file) nor on the various :toctree:
rendered inline in the output.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org
Link: https://lore.kernel.org/r/20221108115707.1232621-1-daniel.vetter@ffwll.ch
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# bd5d1cc8 31-Oct-2022 Jonathan Corbet <corbet@lwn.net>

docs: Don't wire font sizes for HTML output

The alabaster theme likes to provide explicit sizes for fonts, which
overrides the users's own browser settings and is guaranteed to displease
folks. Set the font size to "inherit" so that the users browser settings
control the font size they get. We can use the font_size configuration
option for the main body font (changing the size I'd already put there),
but the sidebar size can only be set via custom CSS.

Reported-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 02d33e86 11-Oct-2022 Jonathan Corbet <corbet@lwn.net>

docs: decruft Documentation/conf.py

Remove the ancient support for the Sphinx "classic" theme; everybody will
have alabaster, so that fallback is no longer needed.

While in the neighborhood: get rid of lots of useless comment lines. They
describe the state of Sphinx options when we first created that file and
are just clutter now.

Suggested-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 2056b920 26-Sep-2022 Jonathan Corbet <corbet@lwn.net>

docs: tweak some Alabaster style parameters

This is just the beginning: tighten up the layout a bit to improve the
information density in the browser. Also reconfigure the page width in
terms of character units (em) rather than pixels, making it more
display-independent. To that end, add a custom.css file to
tweak Alabaster CSS settings.

Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# d5389d31 23-Sep-2022 Jonathan Corbet <corbet@lwn.net>

docs: Switch the default HTML theme to alabaster

The read-the-docs theme is not entirely attractive and doesn't give us
control over the left column. "Alabaster" is deemed the default Sphinx
theme, it is currently maintained and shipped bundled with Sphinx itself,
so there is no need to install it separately. Switch over to this theme as
the default for building kernel documentation; the DOCS_THEME environment
variable can still be used to select a different theme.

Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 3aa024e4 27-Sep-2022 Jonathan Corbet <corbet@lwn.net>

docs: reconfigure the HTML left column

Use the html_sidebars directive to get a more useful set of links in the
left column.

Unfortunately, this is a no-op with the default RTD theme, but others
observe it.

Reviewed-by: David Vernet <void@manifault.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20220927160559.97154-4-corbet@lwn.net
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 3b384e95 26-Aug-2022 Akira Yokosawa <akiyks@gmail.com>

docs/conf.py: Respect env variable SPHINX_IMGMATH

On some distros with coarse-grained packaging policy, dvipng is
installed along with latex. In such cases, math rendering will
use imgmath by default. It is possible to override the choice by
specifying the option string of "-D html_math_renderer='mathjax'"
to sphinx-build (Sphinx >= 1.8).

To provide developers an easier-to-use knob, add code for an env
variable "SPHINX_IMGMATH" which overrides the automatic choice
of math renderer for html docs.

SPHINX_IMGMATH=yes : Load imgmath even if dvipng is not found
SPHINX_IMGMATH=no : Don't load imgmath (fall back to mathjax)

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Link: https://lore.kernel.org/r/5a582b2b-d51c-a062-36b2-19479cf68fab@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 6b0d3e7c 26-Aug-2022 Akira Yokosawa <akiyks@gmail.com>

docs/conf.py: Treat mathjax as fallback math renderer

Currently, math expressions using the "math::" directive or
the ":math:" role of Sphinx need the imgmath extension for proper
rendering in html and epub builds.
imgmath requires dvipng (and latex).
Otherwise, "make htmldocs" will complain of missing commands.

As a matter of fact, the mathjax extension is loaded by default since
Sphinx v1.8 and it is good enough for html docs without any dependency
on texlive packages.

Stop loading the imgmath extension for html docs unless requirements
for imgmath are met.

To find out whether required commands are available, add a helper
find_command(), which is a wrapper of shutil.which().

For epub docs, keep the same behavior of always loading imgmath.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Link: https://lore.kernel.org/r/a6a877fc-dc93-2bda-a6d3-37001d99942a@gmail.com
[jc: Took out the writing of the math_renderer decision]
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 5479d6d4 26-Aug-2022 Menglong Dong <imagedong@tencent.com>

docs/conf.py: add function attribute '__fix_address' to conf.py

Stephen Rothwell reported htmldocs warning when merging net-next:

Documentation/networking/kapi:26: net/core/skbuff.c:780: WARNING: Error in declarator or parameters
Invalid C declaration: Expecting "(" in parameters. [error at 19]
void __fix_address kfree_skb_reason (struct sk_buff *skb, enum skb_drop_reason reason)
-------------------^

Add __fix_address keyword to c_id_attributes array in conf.py to fix
the warning.

Link: https://lore.kernel.org/linux-next/20220825154105.534d78ab@canb.auug.org.au/
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 627f01ea 01-Jun-2022 Akira Yokosawa <akiyks@gmail.com>

docs/conf.py: Cope with removal of language=None in Sphinx 5.0.0

One of the changes in Sphinx 5.0.0 [1] says [sic]:

5.0.0 final

- #10474: language does not accept None as it value.
The default value of language becomes to 'en' now.

[1]: https://www.sphinx-doc.org/en/master/changes.html#release-5-0-0-released-may-30-2022

It results in a new warning from Sphinx 5.0.0 [sic]:

WARNING: Invalid configuration value found: 'language = None'.
Update your configuration to a valid langauge code. Falling
back to 'en' (English).

Silence the warning by using 'en'.
It works with all the Sphinx versions required for building
kernel documentation (1.7.9 or later).

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Link: https://lore.kernel.org/r/bd0c2ddc-2401-03cb-4526-79ca664e1cbe@gmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 398f7abd 18-Feb-2022 Akira Yokosawa <akiyks@gmail.com>

docs: pdfdocs: Pull LaTeX preamble part out of conf.py

Quote from Jon's remark [1]:

I do notice that Documentation/conf.py is getting large and
unapproachable. At some future point, it might be nice to pull
all of the latex stuff out into a separate file where it won't
scare people who stumble into it by accident.

Pull LaTeX preamble settings added since commit 3b4c963243b1 ("docs:
conf.py: adjust the LaTeX document output") out into
sphinx/kerneldoc-preamble.sty.

It will be copied to the build directory by the added
"latex_additional_files" setting in conf.py.

As a bonus, LaTeX/TeX code can be maintained without escaping backslashes.

To compensate the loss of change history in sphinx/kerneldoc-preamble.sty,
here is a list of changes made in conf.py:

- f7ebe6b76940 ("docs: Activate exCJK only in CJK chapters")
- 0afd4df0d16a ("docs: pdfdocs: Prevent column squeezing by tabulary")
- 659653c9e546 ("docs: pdfdocs: Refactor config for CJK document")
- e291ff6f5a03 ("docs: pdfdocs: Add CJK-language-specific font settings")
- 7eb368cc319b ("docs: pdfdocs: Choose Serif font as CJK mainfont if possible")
- 35382965bdd2 ("docs: pdfdocs: Preserve inter-phrase space in Korean translations")
- 77abc2c230b1 ("docs: pdfdocs: One-half spacing for CJK translations")
- 788d28a25799 ("docs: pdfdocs: Permit AutoFakeSlant for CJK fonts")
- 29ac9822358f ("docs: pdfdocs: Teach xeCJK about character classes of quotation marks")
- 7c5c18bdb656 ("docs: pdfdocs: Fix typo in CJK-language specific font settings")
- aa872e0647dc ("docs: pdfdocs: Adjust \headheight for fancyhdr")
- 8716ef413aa5 ("docs: pdfdocs: Tweak width params of TOC")
- 66939df53948 ("docs: pdfdocs: Switch default CJK font to KR variants")
- 7b686a2ea1e4 ("docs: pdfdocs: Enable CJKspace in TOC for Korean titles")
- 5d9158e3c762 ("docs/translations: Skip CJK contents if suitable fonts not found")
- b774cc46313b ("docs: pdfdocs: Move CJK monospace font setting to main conf.py")

[1]: https://lore.kernel.org/all/87zgmr66cn.fsf@meer.lwn.net/

Suggested-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Link: https://lore.kernel.org/r/aaa9dca1-27c0-c414-77f3-c5587db0cc5b@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# b774cc46 31-Jan-2022 Akira Yokosawa <akiyks@gmail.com>

docs: pdfdocs: Move CJK monospace font setting to main conf.py

As LaTeX macros for CJK font settings can have Latin-script font
settings as well, settings under Documentation/translations/ can
be moved to the main conf.py.

By this change, translations.pdf built by top-level "make pdfdocs"
can have properly aligned ascii-art diagrams except for Korean
ones.

For the reason of remaining misalignment in Korean diagrams, see
changelog of commit a90dad8f610a ("docs: pdfdocs: Add conf.py
local to translations for ascii-art alignment").

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/eb87790a-03f4-9f29-c8a3-ef2c3e78ca18@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 5d9158e3 31-Jan-2022 Akira Yokosawa <akiyks@gmail.com>

docs/translations: Skip CJK contents if suitable fonts not found

On systems without "Noto Sans CJK" fonts, CJK chapters in
translations.pdf are full of "TOFU" boxes, with a long build time and
a large log file containing lots of missing-font warnings.

Avoid such waste of time and resources by skipping CJK chapters when
CJK fonts are not available.

To skip whole chapters, change the definition of
\kerneldocBegin{SC|TC|KR|JP} commands so that they can have an argument
to be ignored.
This works as far as the argument (#1) is not used in the command.
In place of skipped contents, put a note on skipped contents at the
beginning of the PDF.

Change the call sites in index.rst of CJK translations accordingly.

When CJK fonts are available, existing command definitions with
no argument just work. LaTeX engine will see additional pairs of
"{" and "}", which add a level of grouping without having any effect
on typesetting.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/3359ca41-b81d-b2c7-e437-7618efbe241d@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 7b686a2e 31-Jan-2022 Akira Yokosawa <akiyks@gmail.com>

docs: pdfdocs: Enable CJKspace in TOC for Korean titles

Korean (Hangul) titles in Table of Contents of translations.pdf
don't have inter-phrase spaces.

This is because the CJKspace option of xeCJK is disabled by
default.

Restore the spaces by enabling the option at the beginning of every
document and disable it in the \kerneldocBegin{SC|TC|JP} commands.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/19141b3e-01d9-1f6d-5020-42fbda784831@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 66939df5 31-Jan-2022 Akira Yokosawa <akiyks@gmail.com>

docs: pdfdocs: Switch default CJK font to KR variants

xeCJK is enabled in Table of Contents (TOC) so that translations.pdf
built by top-level "make pdfdocs" can have its TOC typeset properly.

This causes quotation marks and apostrophe symbols appear too wide in
Latin-script docs.
This is because (1) Sphinx converts ASCII symbols into multi-byte
UTF-8 ones in LaTeX and (2) in the SC variant of "Noto CJK" font
families, those UTF-8 symbols have full-width glyph.

The KR variant of the font families has half-width glyph for those
symbols and TOC pages should look nicer when it is used instead.

Switch the default CJK font families to the KR variant and teach
xeCJK of those symbols' widths.
To compensate the switch, teach xeCJK of the width in the SC and
TC variants.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/0c8ea878-0a6f-ea01-ab45-4e66c5facee9@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 8716ef41 31-Jan-2022 Akira Yokosawa <akiyks@gmail.com>

docs: pdfdocs: Tweak width params of TOC

Sphinx has its own set of width parameters of Table of Contents (TOC)
for LaTeX defined in its class definition of sphinxmanual.cls.
It also inherits parameters for chapter entries from report.cls of
original LaTeX base.

However, they are optimized assuming small documents with tens of
pages and chapters/sections of less than 10.

To cope with some of kernel-doc documents with more than 1000
pages and several tens of chapters/sections, definitions of those
parameters need to be adjusted.

Unfortunately, those parameters are hard coded in the class
definitions and need low-level LaTeX coding tricks to redefine.

As Sphinx 1.7.9 does not have \sphinxtableofcontentshook,
which defines those parameters in later Sphinx versions,
for compatibility with both pre-1.8 and later Sphinx versions,
empty the hook altogether and redefine \@pnumwidth, \l@chapter,
\l@section, and \@subsection commands originally defined in
report.cls.

Summary of parameter changes:

Width of page number (\@pnumwidth): 1.55em -> 2.7em
Width of chapter number: 1.5em -> 1.8em
Indent of section number: 1.5em -> 1.8em
Width of section number: 2.6em -> 3.2em
Indent of subsection number: 4.1em -> 5em
Width of subsection number: 3.5em -> 4.3em

Notes:
1. Parameters for subsection become relevant only when
":maxdepth: 3" is specified under "toctree::" (e.g., RCU/index.rst).
They can hold subsection numbers up to 5 digits such as "18.7.13"
(in RCU.pdf).

2. Number of chapters in driver-api.pdf is getting closer to 100.
When it reaches 100, another set of tweaks will be necessary.

3. The low-level LaTeX trick is mentioned in "Unofficial LaTeX2e
reference manual" at:
http://latexref.xyz/Table-of-contents-etc_002e.html

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/e52b4718-7909-25be-fbc1-76800aa62ae3@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# a6fb8b5a 07-Dec-2021 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

docs: add support for RTD dark mode

This is actually an overlay on the top of the RTD theme, which
requires to include first the RTD theme.

It should be noticed that, when the dark theme is used, the
DOCS_CSS files won't be the last CSS themes. So, it won't
override the dark.css style by default. So, it is needed
to force the them override with "!important".

This small script, for instance, produces a nice output with
the RTD dark theme:

DOCS_THEME=sphinx_rtd_dark_mode
cat << EOF > dark_override.css
html body {
font-family: arial,helvetica,sans-serif;
}
html[data-theme='dark'] body {
color: white !important;
}
html[data-theme='dark'] .sig-name {
color: green !important;
}
html[data-theme='dark'] .wy-menu-vertical a {
color: #ffcc00 !important;
}
html[data-theme="dark"] h1, html[data-theme="dark"] h2, html[data-theme="dark"] h3 {
color: #ffcc00 !important;
}
html[data-theme="dark"] h4, html[data-theme="dark"] h5, html[data-theme="dark"] h6 {
color: #ffcc00 !important;
}
html[data-theme="dark"] h7, html[data-theme="dark"] h8, html[data-theme="dark"] h9 {
color: #ffcc00 !important;
}
html[data-theme="dark"] .wy-nav-content a, html[data-theme="dark"] .wy-nav-content a:visited {
color: #ffcc00 !important;
}
EOF

make DOCS_CSS=dark_override.css DOCS_THEME=sphinx_rtd_dark_mode htmldocs

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/90d316e055ef7f4c9021b9eada8f8d3b2e750a66.1638870323.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# ffc901b4 07-Dec-2021 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

docs: set format for the classic mode

When RTD is not installed or when THEME=classic is used, the
produced docs contain some weird selections. As this theme has
several variables to customize it, set them, in order to produce
a nicer output.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/8889380606681a2b7033f73bed9717250302be2a.1638870323.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 135707d3 07-Dec-2021 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

docs: allow to pass extra DOCS_CSS themes via make

Specially when the RTD theme is not used, it makes sense to
allow specifying extra CSS files via a make variable.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/03d09bf41ad39aa0abfe2ea3c879b09aa3a0948d.1638870323.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# fca7216b 07-Dec-2021 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

docs: allow selecting a Sphinx theme

Instead of having RTD as an almost mandatory theme, allow the
user to select other themes via DOCS_THEME environment var.

There's a catch, though: as the current theme override logic is
dependent of the RTD theme, we need to move the code which
adds the CSS overrides to be inside the RTD theme logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/bd20adabfd428fd3cd0e69c2cf146aa354932936.1638870323.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# d69dab7d 27-Nov-2021 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

docs: conf.py: fix support for Readthedocs v 1.0.0

As described at:
https://stackoverflow.com/questions/23211695/modifying-content-width-of-the-sphinx-theme-read-the-docs

since Sphinx 1.8, the standard way to setup a custom theme is
to use html_css_files. While using html_context is OK with RTD
0.5.2, it doesn't work with 1.0.0, causing the theme to not load,
producing a very weird html.

Tested with:
- Sphinx 1.7.9 + sphinx-rtd-theme 0.5.2
- Sphinx 2.4.4 + sphinx-rtd-theme 0.5.2
- Sphinx 2.4.4 + sphinx-rtd-theme 1.0.0
- Sphinx 4.3.0 + sphinx-rtd-theme 1.0.0

Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
Tested-by: Hans Verkuil <hverkuil@xs4all.nl>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tested-by: Akira Yokosawa <akiyks@gmail.com>
Link: https://lore.kernel.org/r/80009f0d17ea0840d81e7e16fff6e7677919fdfc.1638004294.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# aa872e06 10-Oct-2021 Akira Yokosawa <akiyks@gmail.com>

docs: pdfdocs: Adjust \headheight for fancyhdr

Fancyhdr prior to v4.0 outputs a message per document as follows:

Package Fancyhdr Warning: \headheight is too small (12.0pt):
Make it at least 13.59999pt.
We now make it that large for the rest of the document.
This may cause the page layout to be inconsistent, however.

Fancyhdr v4.0 complains (once a page!) as follows:

Package fancyhdr Warning: \headheight is too small (12.0pt):
(fancyhdr) Make it at least 13.59999pt, for example:
(fancyhdr) \setlength{\headheight}{13.59999pt}.
(fancyhdr) You might also make \topmargin smaller to compensate:

(fancyhdr) \addtolength{\topmargin}{-1.59999pt}.

Related item in fancyhdr v4.0 announcement on 2021-01-04 [1]:

Backward incompatible changes:
- Eliminate adjustments of \headheight or \footskip, when the
header or footer is too high.

[1]: https://www.ctan.org/ctan-ann/id/mailman.2685.1609863692.2532.ctan-ann@ctan.org

Silence the warnings by adding a couple of \addtolength commands in
the preamble.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Link: https://lore.kernel.org/r/c5a5577e-5de8-9cd4-9253-956ccc748417@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 7c5c18bd 28-Aug-2021 Akira Yokosawa <akiyks@gmail.com>

docs: pdfdocs: Fix typo in CJK-language specific font settings

There were typos in the fallback definitions of dummy LaTeX macros
for systems without CJK fonts.
They cause build errors in "make pdfdocs" on such systems.
Fix them.

Fixes: e291ff6f5a03 ("docs: pdfdocs: Add CJK-language-specific font settings")
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Link: https://lore.kernel.org/r/ad7615a5-f8fa-2bc3-de6b-7ed49d458964@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 29ac9822 08-Aug-2021 Akira Yokosawa <akiyks@gmail.com>

docs: pdfdocs: Teach xeCJK about character classes of quotation marks

Quotation marks in "KR" and "JP" variants of Noto CJK fonts are half
width.
xeCJK assumes they are full width by default and does excessive kerning
around them in Korean and Japanese translations.

Give xeCJK proper hints by the \xeCJKDeclareCharClass command.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Link: https://lore.kernel.org/r/0da9e3c5-2716-f576-1df5-2f28ea69f0e8@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 788d28a2 08-Aug-2021 Akira Yokosawa <akiyks@gmail.com>

docs: pdfdocs: Permit AutoFakeSlant for CJK fonts

Noto CJK fonts don't provide italic shapes.
The AutoFakeSlant option of fontspec and xeCJK packages can be used as
a workaround.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Link: https://lore.kernel.org/r/502335cc-9a95-3c2a-7744-6cc56ecaf628@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 77abc2c2 08-Aug-2021 Akira Yokosawa <akiyks@gmail.com>

docs: pdfdocs: One-half spacing for CJK translations

CJK documents are much easier to read with a wider baseline stretch.
Applying onehalfspacing option of "setspace" package looks reasonable.

Note: \usepackage{setspace} needs to be before that of hyperref in the
preamble.
The 'extrapackages' key (available since Sphinx 2.3) is for this purpose.
For systems with Sphinx < 2.3, dummy commands of \onehalfspacing and
\singlespacing are provided instead.
One-half spacing is not effective in LaTeX sources generated by such
revisions of Sphinx.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Link: https://lore.kernel.org/r/547a1f1c-0bb5-20a7-ea0e-951bfc3c3925@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 35382965 08-Aug-2021 Akira Yokosawa <akiyks@gmail.com>

docs: pdfdocs: Preserve inter-phrase space in Korean translations

In Korean typesetting, inter-phrase spaces in Hangul text have
a similar role as the the inter-word spaces in Latin text.
They can be preserved by the \xeCJKsetup{CJKspace=true} option.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Link: https://lore.kernel.org/r/68de2e52-e6d1-3f01-c097-15ba7b28a319@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 7eb368cc 08-Aug-2021 Akira Yokosawa <akiyks@gmail.com>

docs: pdfdocs: Choose Serif font as CJK mainfont if possible

"Noto Serif CJK SC" and its variants suit better with the roman font
of Latin letters.

On some distros such as Fedora, it is possible to partially install
"Noto Sans CJK" fonts.
So, if the Serif fonts are not found on the system, fall back to the
Sans fonts.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Link: https://lore.kernel.org/r/5e454140-5d0c-35d4-8c31-3ffb2420793a@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# e291ff6f 08-Aug-2021 Akira Yokosawa <akiyks@gmail.com>

docs: pdfdocs: Add CJK-language-specific font settings

zh_TW, ko_KR, and ja_JP translations have their preferred glyph sets
different from that of zh_CN.

To switch CJK font in the middle of the translations, introduce custom
LaTeX macros listed below:

\kerneldocBeginSC
\kerneldocEndSC
\kerneldocBeginTC
\kerneldocEndTC
\kerneldocBeginKR
\kerneldocEndKR
\kerneldocBeginJP
\kerneldocEndJP

, and embed a pair of macros in each language's index.rst.

NOTE 1: Update of zh_TW/index.rst is deferred to a follow-up change.

NOTE 2: Custom macros added here do not imply \kerneldocCJK(on|off).
This is intentional. For example, \kerneldocCJKoff needs to be
at the top of Italian translations' index.rst for the footer of
final zh_TW page to be properly typeset.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Link: https://lore.kernel.org/r/31906baf-7490-68cd-7153-4e4d320fb9b0@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 659653c9 08-Aug-2021 Akira Yokosawa <akiyks@gmail.com>

docs: pdfdocs: Refactor config for CJK document

To make generated LaTeX code portable across systems with different sets
of available fonts, convert font-availability check in python code to
LaTeX code by using a conditional command provided by the "fontspec"
package.

This will help those who run Sphinx on one machine/container and run
latexmk on other machines/containers.

Remove import of check_output as it is unused any more.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Link: https://lore.kernel.org/r/4baf88af-316d-8aee-240f-6ccbc20907d7@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 102caec1 14-Jun-2021 Jonathan Corbet <corbet@lwn.net>

docs: Take a little noise out of the build process

Sphinx 3.0 works at this point (albeit slowly) so stop scaring people
with a loud warning. We also don't need to babble about CJK support in the
LaTeX build.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 0afd4df0 29-May-2021 Akira Yokosawa <akiyks@gmail.com>

docs: pdfdocs: Prevent column squeezing by tabulary

Setting a reasonable width to \tymin prevents column squeezing
by tabulary.
Width of 20em works well in almost all the tables still in the
ascii-art format.

Excerpt from tabulary package documentation at [1]:

To stop very narrow columns being too 'squeezed' by this process
any columns that are narrower than \tymin are set to their natural
width.

[1]: https://mirrors.ctan.org/macros/latex/contrib/tabulary/tabulary.pdf

Note: Sphinx has its own default value of \tymin set in
sphinxlatextables.sty (Sphinx 4.0.2) and sphinxmulticell.sty
(Sphinx 2.4.4) as follows:

\setlength{\tymin}{3\fontcharwd\font`0 }

, which is not sufficient for kernel-doc.

Tested against Sphinx versions 2.4.4 and 4.0.2.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Link: https://lore.kernel.org/r/277d68fa-c96a-0ccb-6ce0-4d314851d9fe@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# f7ebe6b7 25-May-2021 Akira Yokosawa <akiyks@gmail.com>

docs: Activate exCJK only in CJK chapters

Activating xeCJK in English and Italian-translation documents
results in sub-optimal typesetting with wide-looking apostrophes
and quotation marks.

The xeCJK package provides macros for enabling and disabling its
effect in the middle of a document, namely \makexeCJKactive and
\makexeCJKinactive.

So the goal of this change is to activate xeCJK in the relevant
chapters in translations.

To do this:

o Define custom macros in the preamble depending on the
availability of the "Noto Sans CJK" font so that those
macros can be used regardless of the use of xeCJK package.

o Patch \sphinxtableofcontents so that xeCJK is inactivated
after table of contents.

o Embed those custom macros in each language's index.rst file
as a ".. raw:: latex" construct.

Note: A CJK chapter needs \kerneldocCJKon in front of its chapter
heading, while a non-CJK chapter should have \kerneldocCJKoff
below its chapter heading.

This is to make sure the CJK font is available to CJK chapter's
heading and ending page's footer.

Tested against Sphinx versions 2.4.4 and 4.0.2.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Tested-by: Wu XiangCheng <bobwxc@email.cn>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/lkml/2061da0a-6ab1-35f3-99c1-dbc415444f37@gmail.com
Link: https://lore.kernel.org/r/83208ddc-5de9-b283-3fd6-92c635348ca0@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 3b4c9632 03-Mar-2021 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

docs: conf.py: adjust the LaTeX document output

Changeset f546ff0c0c07 ("Move our minimum Sphinx version to 1.7")
cleaned up some compatibility issues with previous Sphinx
versions, but it also dropped the PDF margin sets.

Without that, the media documentation won't build fine, as
the margins are too wide to display texts with monospaced
fonts.

While here, align the "latex_elements = {" values, and add
a few other sphinxsetup configs in order to allow Sphinx to
wrap long lines on literal blocks.

Fixes: f546ff0c0c07 ("Move our minimum Sphinx version to 1.7")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Documentation/conf.py | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
Link: https://lore.kernel.org/r/911fbac185dd09c7df715cf4153361b81f04b7ad.1614787053.git.mchehab+huawei@kernel.org

Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 36d8900d 15-Feb-2021 Matthew Wilcox <willy@infradead.org>

Fix unaesthetic indentation

The current documentation build looks like this:

$ make htmldocs
SPHINX htmldocs --> file:///home/willy/kernel/linux-next/Documentation/output
make[2]: Nothing to be done for 'html'.
WARNING: The kernel documentation build process
support for Sphinx v3.0 and above is brand new. Be prepared for
possible issues in the generated output.
$

That extra indentation before my next prompt isn't pretty. This patch
fixes it, but I'm not a pythonista, and maybe there's a better way.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://lore.kernel.org/r/20210215161757.GD2858050@casper.infradead.org
[jc: tweaked for the "better way"]
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# f546ff0c 01-Feb-2021 Jonathan Corbet <corbet@lwn.net>

Move our minimum Sphinx version to 1.7

As promised, drop support for some ancient sphinx releases, along with a
lot of the cruft that was required to make that support work.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 13fef8ef 30-Nov-2020 Jonathan Corbet <corbet@lwn.net>

docs: Note that sphinx 1.7 will be required soon

The time has come to drop support for some truly ancient versions of
sphinx; put in a warning now.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 63fdc462 30-Nov-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

docs: admin-guide: add a features list

Add a feature list matrix at the admin-guide.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/f6c1e366fbc7ce1c9c94c7dc6c7852c6377cc0be.1606748711.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# a7ee04b3 30-Oct-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

docs: add ABI documentation to the admin-guide book

As we don't want a generic Sphinx extension to execute commands,
change the one proposed to Markus to call the abi_book.pl
script.

Use a script to parse the Documentation/ABI directory and output
it at the admin-guide.

Acked-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/5651482b06500e69a1acdf92152f90a203e6521d.1604042072.git.mchehab+huawei@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d29f34c0 27-Oct-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

sphinx: conf.py: properly handle Sphinx 4.0

One of the checks for Sphinx 3+ is broken, causing some
C warnings to return back with Sphinx 4.0.x.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/d5abc30056dafeec0778a46263a45401bdc7f11e.1603791716.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 14059a38 30-Sep-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

docs: conf.py: change the Sphinx 3.x+ text

After the build fix patches, it is believed that the output
with Sphinx 3.x won't be a problem. Still, the C domain
support was re-written, and this can have caused hidden
issues.

So, let's keep the warning, changing it to a lighter
warning text.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# b34b86d7 28-Sep-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

docs: conf.py: fix c:function support with Sphinx 3.x

Sphinx C parser for the C domain is now more pedantic when
trying to identify the function types. That prevents scope
macros to be used as type defines.

Yet, since 3.0.2, it is possible to provide it a list of
such macros. Add them, in order to solve several Sphinx 3.x
warnings.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


# afde706a 04-Sep-2020 Jonathan Corbet <corbet@lwn.net>

Make the docs build "work" with Sphinx 3.x

The Sphinx 3.x upgrade broke a number of things in our special "cdomain"
module that are not easy to fix. For now, just disable that module for the
3.x build and put out a warning that the build will not be perfect.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 93431e06 26-May-2020 Alexander A. Klimov <grandmaster@al2klimov.de>

Replace HTTP links with HTTPS ones: documentation

Rationale:
Reduces attack surface on kernel devs opening the links for MITM
as HTTPS traffic is much harder to manipulate.

Deterministic algorithm:
For each file:
For each line:
If doesn't contain `\bxmlns\b`:
For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
If both the HTTP and HTTPS versions
return 200 OK and serve the same content:
Replace HTTP with HTTPS.

Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
Link: https://lore.kernel.org/r/20200526060544.25127-1-grandmaster@al2klimov.de
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 25813cae 14-Apr-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

docs: LaTeX/PDF: drop list of documents

The building system can auto-generate a list of documents since
commit: 9d42afbe6bd4 ("docs: pdf: add all Documentation/*/index.rst to PDF output").

The added logic there allows keeping the existing list, but
there's not real reason to keep it. Now, the media document
has gone (it was split into tree).

So, it sounds about time to get rid of the manual entries,
and let the script to generate it automatically instead.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/9345dba7164497dbf28578f6ec271e479379610c.1586881715.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 4658b0eb 20-Mar-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

docs: conf.py: avoid thousands of duplicate label warning on Sphinx

The autosectionlabel extension is nice, as it allows to refer to
a section by its name without requiring any extra tag to create
a reference name.

However, on its default, it has two serious problems:

1) the namespace is global. So, two files with different
"introduction" section would create a label with the
same name. This is easily solvable by forcing the extension
to prepend the file name with:

autosectionlabel_prefix_document = True

2) It doesn't work hierarchically. So, if there are two level 1
sessions (let's say, one labeled "open" and another one "ioctl")
and both have a level 2 "synopsis" label, both section 2 will
have the same identical name.

Currently, there's no way to tell Sphinx to create an
hierarchical reference like:

open / synopsis
ioctl / synopsis

This causes around 800 warnings. So, the fix should be to
not let autosectionlabel to produce references for anything
that it is not at a chapter level within any doc, with:

autosectionlabel_maxdepth = 2

Fixes: 58ad30cf91f0 ("docs: fix reference to core-api/namespaces.rst")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/74f4d8d91c648d7101c45b4b99cc93532f4dadc6.1584716446.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 58ad30cf 19-Mar-2020 Jonathan Corbet <corbet@lwn.net>

docs: fix reference to core-api/namespaces.rst

Fix a couple of dangling links to core-api/namespaces.rst by turning them
into proper references. Enable the autosection extension (available since
Sphinx 1.4) to make this work.

Co-developed-by: Federico Vaga <federico.vaga@vaga.pv.it>
Fixes: fcfacb9f8374 ("doc: move namespaces.rst from kbuild/ to core-api/")
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# aa204855 01-Oct-2019 Kees Cook <keescook@chromium.org>

doc-rst: Programmatically render MAINTAINERS into ReST

In order to have the MAINTAINERS file visible in the rendered ReST
output, this makes some small changes to the existing MAINTAINERS file
to allow for better machine processing, and adds a new Sphinx directive
"maintainers-include" to perform the rendering.

Features include:
- Per-subsystem reference links: subsystem maintainer entries can be
trivially linked to both internally and external. For example:
https://www.kernel.org/doc/html/latest/process/maintainers.html#secure-computing

- Internally referenced .rst files are linked so they can be followed
when browsing the resulting rendering. This allows, for example, the
future addition of maintainer profiles to be automatically linked.

- Field name expansion: instead of the short fields (e.g. "M", "F",
"K"), use the indicated inline "full names" for the fields (which are
marked with "*"s in MAINTAINERS) so that a rendered subsystem entry
is more human readable. Email lists are additionally comma-separated.
For example:

SECURE COMPUTING
Mail: Kees Cook <keescook@chromium.org>
Reviewer: Andy Lutomirski <luto@amacapital.net>,
Will Drewry <wad@chromium.org>
SCM: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git seccomp
Status: Supported
Files: kernel/seccomp.c include/uapi/linux/seccomp.h
include/linux/seccomp.h tools/testing/selftests/seccomp/*
tools/testing/selftests/kselftest_harness.h
userspace-api/seccomp_filter
Content regex: \bsecure_computing \bTIF_SECCOMP\b

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# e0de2b59 14-Jul-2019 Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

docs: conf.py: only use CJK if the font is available

If we try to build a book with asian characters with XeLaTeX
and the font is not available, it will produce an error.

So, instead, add a logic at conf.py to detect if the proper
font is installed.

This will avoid an error while building the document, although
the result may not be readable.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 24889dad 09-Jul-2019 Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

docs: conf.py: add CJK package needed by translations

In order to be able to output Asian symbols with XeLaTeX, we
need the xeCJK package, and a default font for CJK symbols.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 9d42afbe 09-Jul-2019 Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

docs: pdf: add all Documentation/*/index.rst to PDF output

Currently, all index files should be manually added to the
latex_documents array at conf.py.

While this allows fine-tuning some LaTeX specific things, like
the name of the output file and the name of the document, it
is not uncommon to forget adding new documents there.

So, add a logic that will seek for all Documentation/*/index.rst.
If the index is not yet at latex_documents, it includes using
a reasonable default.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


# 7282a93f 28-Jun-2019 Stephen Kitt <steve@sk2.org>

Disable Sphinx SmartyPants in HTML output

The handling of dashes in particular results in confusing
documentation in a number of instances, since "--" becomes an
en-dash. This disables SmartyPants wholesale, losing smart quotes
along with smart dashes.

With Sphinx 1.6 we could fine-tune the conversion, using the new
smartquotes and smartquotes_action settings.

Signed-off-by: Stephen Kitt <steve@sk2.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# d74b0d31 25-Apr-2019 Jonathan Corbet <corbet@lwn.net>

Docs: An initial automarkup extension for sphinx

Rather than fill our text files with :c:func:`function()` syntax, just do
the markup via a hook into the sphinx build process.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 3bc80884 22-May-2019 Jonathan Corbet <corbet@lwn.net>

docs: Fix conf.py for Sphinx 2.0

Our version check in Documentation/conf.py never envisioned a world where
Sphinx moved beyond 1.x. Now that the unthinkable has happened, fix our
version check to handle higher version numbers correctly.

Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 44ba0bb4 04-Oct-2018 Darrick J. Wong <darrick.wong@oracle.com>

docs: improve readability for people with poorer eyesight

My eyesight is not in good shape, which means that I have difficulty
reading the online Linux documentation. Specifically, body text is
oddly small compared to list items and the contrast of various text
elements is too low for me to be able to see easily.

Therefore, alter the HTML theme overrides to make the text larger and
increase the contrast for better visibility, and trust the typeface
choices of the reader's browser.

For the PDF output, increase the text size, use a sans-serif typeface
for sans-serif text, and use a serif typeface for "roman" serif text.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 8a98ec7c 05-Oct-2018 Darrick J. Wong <darrick.wong@oracle.com>

docs: promote the ext4 data structures book to top level

Move the ext4 data structures book to Documentation/filesystems/ext4/
since the administrative information moved elsewhere.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>


# d3091215 05-Oct-2018 Darrick J. Wong <darrick.wong@oracle.com>

docs: move ext4 administrative docs to admin-guide/

Move the ext4 mount option and other administrative stuff to the Linux
administrator's guide.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>


# e5f09261 02-Oct-2018 Darrick J. Wong <darrick.wong@oracle.com>

docs: generate a separate ext4 pdf file from the documentation

The documentation build scripts won't build a pdf for the ext4
documentation unless explicitly called for, so ask for a separate
ext4.pdf to be generated with all the documentation.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>


# b4becd48 29-Jul-2018 Darrick J. Wong <darrick.wong@oracle.com>

ext4: import inode data fork chapter from wiki page

Import the chapter about inode data fork from the on-disk format wiki
page into the kernel documentation.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>


# 2a7c7cba 11-Dec-2017 Jonathan Corbet <corbet@lwn.net>

docs: Remove "could not extract kernel version" warning

This warning will happen for every normal kernel docs build and doesn't
carry any useful information. Should anybody actually depend on this
"version" variable (which isn't clear to me), the "unknown version" value
will be clue enough.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 54d6d73f 26-Aug-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: don't require adjustbox anymore

Only the media PDF book was requiring adjustbox, in order to
scale big tables. That worked pretty good with Sphinx versions
1.4 and 1.5, but Spinx 1.6 changed the way tables are produced,
by introducing some weird macros before tabulary.
That causes adjustbox to fail. So, it can't be used anymore,
and its usage was removed from the media book.

So, let's remove it from conf.py and sphinx-pre-install.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 9fdcd6af 03-Sep-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: conf.py: only setup notice box colors if Sphinx < 1.6

Sphinx 1.5 added a new way to change backward colors for note
boxes, but kept backward compatibility with 1.4. On Sphinx 1.6,
the old way stopped working, in favor of a new less hackish
way.

Unfortunately, this is currently too buggy to be used, and
the old way doesn't work anymore. So, we have no option but
to stick with boring notice boxes.

One example of such bug is the notice that it is inside
struct v4l2_plane, at the "bytesused" field.

At least, add a notice about how to use, as maybe some day
the bug will vanish.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# c4b326e1 03-Sep-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: conf.py: remove lscape from LaTeX preamble

Only the media book used this extension in the past, but
it is not required anymore.

Cleanup patch only.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 646056ec 26-Aug-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: fix verbatim font size on tables

On Sphinx 1.6, fancy boxes are used for verbatim. The sphinx.sty
sets verbatim font is always \small. That causes a problem
inside tables that use smaller fonts, as it can be too big for
the box.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 0e4c2b75 14-Aug-2017 Markus Heiser <markus.heiser@darmarit.de>

docs: fix minimal sphinx version in conf.py

according to what Documentation/doc-guide/sphinx.rst says::

The ReST markups currently used by the Documentation/ files
are meant to be built with ``Sphinx`` version 1.3 or upper.

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 5148e6ab 23-Aug-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: pdf: use same vertical margin on all Sphinx versions

Currently, on Sphinx up to version 1.4, pdf output uses a vertical
margin of 1 inch. For upper versions, it uses a margin of 0.5 inches.

That causes both page headers and footers to be very close to the margin
of the sheet. Not all printers support writing like that.

Also, there's no reason why the layout for newer versions would be
different than for previous ones.

So, standardize it, by always setting to 1 inch.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 633d612b 19-Jun-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

Docs: Fix breakage with Sphinx 1.5 and upper

Commit 85c21e5c3ee7 (docs-rst: better adjust margins and font size) added a
\usepackage{geometry} that conflicts with another inclusion deep within the
dependencies with newer versions of Sphinx, causing the the PDF build to fail
with a "conflicting parameters" error.

Detect the Sphinx version, using sphinxsetup for Sphinx versions 1.5 and
upper.

Fixes: 85c21e5c3ee74fb75d690c57f7066bae7e2dca55
[jc: Tweaked logic to exclude 1.5.x for x < 3 ]
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# cc110221 18-Jun-2017 Jonathan Corbet <corbet@lwn.net>

Docs: Include the Latex "ifthen" package

Otherwise we get PDF build failures when LaTeX refused to acknowledge the
existence of \ifthenelse

Fixes: 41cff161fe99d1c6a773becc2250a1dc3ac035ff
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# bffac837 13-May-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: convert sh book to ReST

Use pandoc to convert documentation to ReST by calling
Documentation/sphinx/tmplcvt script.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 05e0f3b9 12-May-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: convert networking book to ReST

Use pandoc to convert documentation to ReST by calling
Documentation/sphinx/tmplcvt script.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 90f9f118 12-May-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: convert filesystems book to ReST

Use pandoc to convert documentation to ReST by calling
Documentation/sphinx/tmplcvt script.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 6bb33768 12-May-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: add userspace API book to pdf output

The userspace API book was added without the bits required to
generate PDF output. Add them.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# f3377977 12-May-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: add sound book to pdf output

The sound subsystem book was added without the bits required to
generate PDF output. Add them.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 81e11d49 12-May-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: add dev-tools book to pdf output

The dev-tools API book was added without the bits required to
generate PDF output at the main conf.py. Add them.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 8db0b75f 12-May-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: add crypto API book to pdf output

The crypto API book was added without the bits required to
generate PDF output. Add them.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 1d8c4e1f 12-May-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: conf.py: remove kernel-documentation from LaTeX

There's no kernel-documentation.rst file at Documentation/
anymore. So, remove it from the list of LaTeX-generated
documents.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# c2b563d8 12-May-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: conf.py: sort LaTeX documents in alphabetical order

As we add more documents, it makes more sense to sort the
entries there in alphabetical order, as it makes easier to
check if something is not there.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 2a054b51 11-May-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

conf.py: define a color for important markup on PDF output

As kdbg.rst uses the ".. important::" annotation, let's define a
color for PDF output.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# c4fcd7ca 11-May-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: convert kernel-hacking to ReST

Use pandoc to convert documentation to ReST by calling
Documentation/sphinx/tmplcvt script.

- Manually adjusted to use ..note and ..warning
- Minor fixes for it to be parsed without errors
- Use **bold** for emphasis.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# e2ba5731 04-Apr-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

Input: create a book with Linux Input documentation

Now that all files under Documentation/input follows the ReST markup
language, rename them to *.rst and create a book for the Linux Input
subsystem.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# c46988ae 20-Mar-2017 Rémy Léone <remy.leone@gmail.com>

Use sphinx.version_info directly instead of parsing

Using the development version of sphinx caused the parsing of the
version to fail.

Signed-off-by: Rémy Léone <remy.leone@gmail.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# db6ccf23 06-Mar-2017 Markus Heiser <markus.heiser@darmarit.de>

docs-rst: automatically convert Graphviz and SVG images

This patch brings scalable figure, image handling and a concept to
embed *render* markups:

* DOT (http://www.graphviz.org)
* SVG

For image handling use the 'image' replacement::

.. kernel-image:: svg_image.svg
:alt: simple SVG image

For figure handling use the 'figure' replacement::

.. kernel-figure:: svg_image.svg
:alt: simple SVG image

SVG image example

Embed *render* markups (or languages) like Graphviz's **DOT** is
provided by the *render* directive.::

.. kernel-render:: DOT
:alt: foobar digraph
:caption: Embedded **DOT** (Graphviz) code.

digraph foo {
"bar" -> "baz";
}

The *render* directive is a concept to integrate *render* markups and
languages, yet supported markups:

* DOT: render embedded Graphviz's **DOT**
* SVG: render embedded Scalable Vector Graphics (**SVG**)

Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Tested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> (v2 - v5)
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de> (v1, v6)
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# fd5d6669 02-Mar-2017 John Keeping <john@metanate.com>

Documentation/sphinx: fix primary_domain configuration

With Sphinx 1.5.3 I get the warning:

WARNING: primary_domain 'C' not found, ignored.

It seems that domain names in Sphinx are case-sensitive and for the C
domain the name must be lower case.

Signed-off-by: John Keeping <john@metanate.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# dc36143f 06-Feb-2017 Jonathan Corbet <corbet@lwn.net>

docs: Remove the copyright year from conf.py

It had gone stale, of course, as it would every year, a single date doesn't
really cover things, and the date isn't really needed anyway.


# 1dc4bbf0 17-Nov-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: doc-guide: split the kernel-documentation.rst contents

Having the kernel-documentation at the topmost level doesn't
allow generating a separate PDF file for it. Also, makes harder
to add extra contents. So, place it on a sub-dir.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 22917b99 16-Nov-2016 Jonathan Corbet <corbet@lwn.net>

docs: Add more manuals to the PDF build

There were a few manuals that weren't being built in PDF format, but
there's no reason not to...

Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# e2a91f4f 14-Nov-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: fix LaTeX \DURole renewcommand with Sphinx 1.3+

PDF build on Kernel 4.9-rc? returns an error with Sphinx 1.3.x
and Sphinx 1.4.x, when trying to solve some cross-references.

The solution is to redefine the \DURole macro.

However, this is redefined too late. Move such redefinition to
LaTeX preamble and bind it to just the Sphinx versions where the
error is known to be present.

Tested by building the documentation on interactive mode:
make PDFLATEX=xelatex -C Documentation/output/./latex

Fixes: e61a39baf74d ("[media] index.rst: Fix LaTeX error in interactive mode on Sphinx 1.4.x")
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# b459106e 03-Nov-2016 Jani Nikula <jani.nikula@intel.com>

Documentation/sphinx: set literal block highlight language to none

Set the default highlight language to "none", i.e. do not try to guess
the language and do automatic syntax highlighting on literal blocks.

Eyeballing around the generated documentation, we don't seem to actually
have a lot of literal blocks that would benefit from syntax
highlighting. The C code blocks we do have are typically very short, and
most of the literal blocks are things that shouldn't be highlighted (or,
do not have a pygments lexer). This seems to be true for literal blocks
both in the rst source files and in source code comments.

Not highlighting code is never wrong, but guessing the language wrong
almost invariably leads to silly or confusing highlighting.

At the time of writing, admin-guide/oops-tracing.rst and
admin-guide/ramoops.rst contain good examples of 1) a small C code
snippet not highlighted, 2) a hex dump highligted as who knows what, 3)
device tree block highlighted as C or maybe Python, 4) a terminal
interaction highlighted as code in some language, and finally, 5) some C
code snippets correctly identified as C. I think we're better off
disabling language guessing, and going by explicitly identified
languages for longer code blocks.

It is still possible to enable highlighting on an rst source file basis
using the highlight directive:

.. higlight:: language

and on a literal block basis using the code-block directive:

.. code-block:: language

See http://www.sphinx-doc.org/en/latest/markup/code.html for details.

Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Cc: Markus Heiser <markus.heiser@darmarit.de>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>


# 8d26d90b 02-Nov-2016 Jani Nikula <jani.nikula@intel.com>

Documentation/sphinx: include admin-guide in the latex/pdf build

Fix the warning:

WARNING: "latex_documents" config value references unknown document
user/index

Reviewed-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>


# 9d85025b 21-Sep-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: create an user's manual book

Place README, REPORTING-BUGS, SecurityBugs and kernel-parameters
on an user's manual book.

As we'll be numbering the user's manual, remove the manual
numbering from SecurityBugs.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 0e4f07a6 18-Oct-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

docs: rename development-process/ to process/

As we'll type this a lot, after adding CodingStyle & friends,
let's rename the directory name to a shorter one.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 58af04df 19-Oct-2016 Jani Nikula <jani.nikula@intel.com>

Documentation/sphinx: rename kernel-doc.py to kerneldoc.py

Python module names should not have hyphens per [PEP 8]. Drop the hyphen
from kernel-doc.py. The extension directive remains unchanged.

[PEP 8] https://www.python.org/dev/peps/pep-0008/#package-and-module-names

Reported-by: Markus Heiser <markus.heiser@darmarit.de>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# f0ddda3e 19-Sep-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: create a book for the development process

Now that the files at Documentation/development-process/
were converted to ReST, make create a book at Sphinx.

As we'll have other books related to the development process,
we'll add it as a sub-book.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 0d1c7d60 16-Aug-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: add media documentation to PDF output

Now that the build of PDF output on media got fixed, re-add it
to the Sphinx PDF build.

Partially reverts 3eb6cd6834c3 ('Documentation: exclude
media documentation from pdf generation').

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# ca7bfe2c 22-Aug-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: add package adjustbox

We need adjustbox to allow adjusting the size of tables that
are bigger than the line width. There are quite a few of them
at the media books.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# ba1377fb 21-Aug-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: Fix an warning when in interactive mode

When XeLaTeX is in interactive mode, it complains that
py@noticelength already exists. Rename it and declare it
only once to avoid such messages.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 41cff161 21-Aug-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: Use better colors for note/warning/attention boxes

Instead of painting the box with gray, let's use a colored
box. IMHO, that makes easier to warn users about some issue
pointed by the Sphinx. It also matches to what we do already
with the HTML output.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# aa4e37a3 19-Aug-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: conf.py: adjust the size of .. note:: tag

While the current implementation works well when using as a
paragraph, it doesn't work properly if inside a table. As we
have quite a few such cases, fix the logic to take the column
size into account.

PS.: I took the logic there from the latest version of Sphinx.sty

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# e8f5c617 22-Aug-2016 Markus Heiser <markus.heiser@darmarit.de>

doc-rst: add boilerplate to customize c-domain

Add a sphinx-extension to customize the sphinx c-domain. No functional
changes right yet, just the boilerplate code.

Signed-off-by: Markus Heiser <markus.heiser@darmarIT.de>
[ jc: coding-style tweak ]
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# d4fe7e14 16-Aug-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: enable the Sphinx math extension

This extension will be used by the media books.

The name of the math image extension changed on Sphinx 1.4.x,
according with:
http://www.sphinx-doc.org/en/stable/ext/math.html#module-sphinx.ext.imgmath

Let's autodetect, to keep building with versions < 1.4.

Suggested-by: Markus Heiser <markus.heiser@darmarit.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 85c21e5c 16-Aug-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: better adjust margins and font size

As we have big tables, reduce the left/right margins and decrease
the point size to 8pt. Visually, it is still good enough, and
now less tables are too big to be displayed.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# a682ec4b 16-Aug-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: Don't mangle with UTF-8 chars on LaTeX/PDF output

pdflatex doesn't accept using some UTF-8 chars, like
"equal or less than" or "equal or greater than" chars. However,
the media documents use them. So, we need to use XeLaTeX for
conversion, and a font that accepts such characters.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 60459774 16-Aug-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: improve output for .. notes:: on LaTeX

The output for those notes are bad in pdf, as they're not
in a box with a different color. Also, it causes the output
to not build if the note is inside a table.

Change its implementation to avoid the above troubles.

The logic there came from:
https://stackoverflow.com/questions/606746/how-to-customize-an-existing-latex-environment-without-interfering-with-other-en

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# caee5cde 16-Aug-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: allow generating some LaTeX pages in landscape

Portrait is too small for some tables used at the media docs.
So, allow documents to tell Sphinx to generate some pages
in landscape by using:

.. raw:: latex

\begin{landscape}

<some stuff>

.. raw:: latex

\end{landscape}

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# a69ab108 16-Aug-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

docs-rst: remove a rst2pdf left over code

The usage of rst2pdf was replaced by pdflatex on a previous
patch. Remove the left-over code at conf.py.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 606b9ac8 13-Aug-2016 Markus Heiser <markus.heiser@darmarIT.de>

doc-rst: generic way to build only sphinx sub-folders

Add a generic way to build only a reST sub-folder with or
without a individual *build-theme*.

* control *sub-folders* by environment SPHINXDIRS
* control *build-theme* by environment SPHINX_CONF

Folders with a conf.py file, matching $(srctree)/Documentation/*/conf.py
can be build and distributed *stand-alone*. E.g. to compile only the
html of 'media' and 'gpu' folder use::

make SPHINXDIRS="media gpu" htmldocs

To use an additional sphinx-build configuration (*build-theme*) set the
name of the configuration file to SPHINX_CONF. E.g. to compile only the
html of 'media' with the *nit-picking* build use::

make SPHINXDIRS=media SPHINX_CONF=conf_nitpick.py htmldocs

With this, the Documentation/conf.py is read first and updated with the
configuration values from the Documentation/media/conf_nitpick.py.

Signed-off-by: Markus Heiser <markus.heiser@darmarIT.de>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 3eb6cd68 10-Aug-2016 Jani Nikula <jani.nikula@intel.com>

Documentation: exclude media documentation from pdf generation

Although pdflatex is more robust than rst2pdf, building media
documentation pdf still fails. Exclude media documentation from pdf
generation for now.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Acked-by: Markus Heiser <markus.heiser@darmarit.de>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# a7a0729c 12-Aug-2016 Jonathan Corbet <corbet@lwn.net>

docs: Set the Sphinx default highlight language to "guess"

This should eliminate a whole class of markup warnings, at the cost of
occasionally amusing markup choices; we'll have to see if it works out.

Suggested-by: Markus Heiser <markus.heiser@darmarIT.de>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 29310a50 20-Jul-2016 Jonathan Corbet <corbet@lwn.net>

Revert "doc/sphinx: Enable keep_warnings"

This reverts commit 47d6d752b9e20dbe8a2acd22e887be81a6f39de9.

Commit f42ddca7bebc (doc-rst: kernel-doc directive, fix state machine
reporter) from Marcus Heiser provides a better fix, so this configuration
change is no longer needed.


# 47d6d752 19-Jul-2016 Daniel Vetter <daniel.vetter@ffwll.ch>

doc/sphinx: Enable keep_warnings

Unfortunately warnings generated after parsing in sphinx can end up
with entirely bogus files and line numbers as sources. Strangely for
outright errors this is not a problem. Trying to convert warnings to
errors also doesn't fix it.

The only way to get useful output out of sphinx to be able to root
cause the error seems to be enabling keep_warnings, which inserts
a System Message into the actual output. Not pretty at all, but I
don't really want to fix up core rst/sphinx code, and this gets the job
done meanwhile.

Cc: Markus Heiser <markus.heiser@darmarit.de>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# 520a2477 15-Jul-2016 Mauro Carvalho Chehab <mchehab@kernel.org>

doc-rst: Fix compilation of the pdf docbook

The rst2pdf tool is a very broken toolchain, with is not capable
of parsing complex documents. As such, it doesn't build the
media book, failing with:

[ERROR] pdfbuilder.py:130 too many values to unpack

(using rst2pdf version 0.93.dev-r0 and Sphinx version 1.4.5)

So, make it build only the books we know that are safe to build.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

--

Btw, with the standard Sphinx version shipped on Fedora 24 (Sphinx
1.3.1), rst2pdf doesn't build even the simple kernel-documentation,
failing with this error:
writing Kernel... [ERROR] pdfbuilder.py:130 list index out of range

This is a known bug:
https://github.com/sphinx-doc/sphinx/issues/1844

So, maybe we should just disable pdf generation from RST for good,
as I suspect that maintaining it with a broken toolchain will be a
big headache.


# 627e32df 08-Jul-2016 Markus Heiser <markus.heiser@darmarIT.de>

doc-rst: linux_tv/Makefile: Honor quiet make O=dir

To honor the:

make O=dir [targets] Locate all output files in "dir"

* activate kernel-include directive
* export BUILDDIR=$(BUILDDIR)
* linux_tv: replace '.. include::' with '.. kernel-include:: $BUILDDIR/<foo.h.rst>'

Signed-off-by: Markus Heiser <markus.heiser@darmarIT.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# bc214671 03-Jul-2016 Markus Heiser <markus.heiser@darmarIT.de>

doc-rst: boilerplate HTML theme customization

Implements the minimal boilerplate for Sphinx HTML theme customization.

Signed-off-by: Markus Heiser <markus.heiser@darmarIT.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 0249a764 30-Jun-2016 Markus Heiser <markus.heiser@darmarIT.de>

doc-rst: flat-table directive - initial implementation

Implements the reST flat-table directive.

The ``flat-table`` is a double-stage list similar to the ``list-table`` with
some additional features:

* column-span: with the role ``cspan`` a cell can be extended through
additional columns

* row-span: with the role ``rspan`` a cell can be extended through
additional rows

* auto span rightmost cell of a table row over the missing cells on the right
side of that table-row. With Option ``:fill-cells:`` this behavior can
changed from *auto span* to *auto fill*, which automaticly inserts (empty)

list tables

The *list tables* formats are double stage lists. Compared to the
ASCII-art they migth be less comfortable for readers of the
text-files. Their advantage is, that they are easy to create/modify
and that the diff of a modification is much more meaningfull, because
it is limited to the modified content.

The initial implementation was taken from the sphkerneldoc project [1]

[1] https://github.com/return42/sphkerneldoc/commits/master/scripts/site-python/linuxdoc/rstFlatTable.py

Signed-off-by: Markus Heiser <markus.heiser@darmarIT.de>
[jc: fixed typos and misspellings in the docs]
Signed-off-by: Jonathan Corbet <corbet@lwn.net>


# c13ce448 28-May-2016 Jani Nikula <jani.nikula@intel.com>

Documentation/sphinx: set version and release properly

Read the version and release from the top level Makefile (for use when
Sphinx is invoked directly, by e.g. Read the Docs), but override them
via Sphinx command line arguments in a normal documentation build.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>


# 24dcdeb2 20-May-2016 Jani Nikula <jani.nikula@intel.com>

Documentation/sphinx: configure the kernel-doc extension

Tell Sphinx where to find the extension, and pass on the kernel src tree
and kernel-doc paths to the extension.

With this, any .rst files under Documentation may contain the kernel-doc
rst directive to include kernel-doc documentation from any source file.

While building, it may be handy to pass kernel-doc extension
configuration on the command line. For example, 'make SPHINXOPTS="-D
kerneldoc_verbosity=0" htmldocs' silences all stderr output from
kernel-doc when the kernel-doc exit code is 0. (The stderr will be
logged unconditionally when the exit code is non-zero.)

Signed-off-by: Jani Nikula <jani.nikula@intel.com>


# 22cba31b 19-May-2016 Jani Nikula <jani.nikula@intel.com>

Documentation/sphinx: add basic working Sphinx configuration and build

Add basic configuration and makefile to build documentation from any
.rst files under Documentation using Sphinx. For starters, there's just
the placeholder index.rst.

At the top level Makefile, hook Sphinx documentation targets alongside
(but independent of) the DocBook toolchain, having both be run on the
various 'make *docs' targets.

All Sphinx processing is placed into Documentation/Makefile.sphinx. Both
that and the Documentation/DocBook/Makefile are now expected to handle
all the documentation targets, explicitly ignoring them if they're not
relevant for that particular toolchain. The changes to the existing
DocBook Makefile are kept minimal.

There is graceful handling of missing Sphinx and rst2pdf (which is
needed for pdf output) by checking for the tool and python module,
respectively, with informative messages to the user.

If the Read the Docs theme (sphinx_rtd_theme) is available, use it, but
otherwise gracefully fall back to the Sphinx default theme, with an
informative message to the user, and slightly less pretty HTML output.

Sphinx can now handle htmldocs, pdfdocs (if rst2pdf is available),
epubdocs and xmldocs targets. The output documents are written into per
output type subdirectories under Documentation/output.

Finally, you can pass options to sphinx-build using the SPHINXBUILD make
variable. For example, 'make SPHINXOPTS=-v htmldocs' for more verbose
output from Sphinx.

This is based on the original work by Jonathan Corbet, but he probably
wouldn't recognize this as his own anymore.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>