linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vegard Nossum <vegard.nossum@oracle.com>
To: Jonathan Corbet <corbet@lwn.net>, linux-doc@vger.kernel.org
Cc: Akira Yokosawa <akiyks@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Jani Nikula <jani.nikula@intel.com>
Subject: Re: PDF misery
Date: Sun, 18 Feb 2024 14:07:07 +0100	[thread overview]
Message-ID: <c6817759-62fc-48c8-9446-e985b6234745@oracle.com> (raw)
In-Reply-To: <ec394023-1dc4-4dc9-8f90-77665b297823@oracle.com>

[-- Attachment #1: Type: text/plain, Size: 866 bytes --]


On 18/02/2024 11:08, Vegard Nossum wrote:
> I think the "bug" here is really that Sphinx generated LaTeX code that
> doesn't build -- and that it didn't warn about the problem in other
> modes (maybe it does in newer versions, or maybe we overlooked the
> warnings?).
> 
> If we'd had those warnings then we could have stopped those constructs
> from entering the documentation sources to start with.

With the attached patch I get:

$ make htmldocs SPHINXDIRS=filesystems/xfs
make[3]: Nothing to be done for 'html'.
Using alabaster theme
source directory: filesystems/xfs
WARNING: xfs-online-fsck-design.rst:2096: heading "Case Study: Sorting 
xfarrays" has nesting level 7; consider restructuring

Maybe we can do the same for itemize lists.

I didn't check what impact this potentially has on running time. Also
only tested with Sphinx 4.3.2.

Thoughts?


Vegard

[-- Attachment #2: kvalidate.patch --]
[-- Type: text/x-patch, Size: 1958 bytes --]

diff --git a/Documentation/conf.py b/Documentation/conf.py
index 5830b01c5642..1cfcea4e487d 100644
--- a/Documentation/conf.py
+++ b/Documentation/conf.py
@@ -55,7 +55,8 @@ needs_sphinx = '2.4.4'
 extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include',
               'kfigure', 'sphinx.ext.ifconfig', 'automarkup',
               'maintainers_include', 'sphinx.ext.autosectionlabel',
-              'kernel_abi', 'kernel_feat', 'translations']
+              'kernel_abi', 'kernel_feat', 'translations',
+              'kvalidate']
 
 if major >= 3:
     if (major > 3) or (minor > 0 or patch >= 2):
diff --git a/Documentation/sphinx/kvalidate.py b/Documentation/sphinx/kvalidate.py
new file mode 100644
index 000000000000..3302e936db77
--- /dev/null
+++ b/Documentation/sphinx/kvalidate.py
@@ -0,0 +1,42 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright © 2024, Oracle and/or its affiliates.
+# Author: Vegard Nossum <vegard.nossum@oracle.com>
+#
+# Validate doc tree against kernel-specific rules.
+#
+
+import os
+
+import docutils
+from sphinx.util import logging
+
+logger = logging.getLogger('kerneldoc')
+
+max_heading_levels = 5
+
+def process_doctree(app, doctree):
+    env = app.env
+    srcdir = env.srcdir
+
+    for node in doctree.traverse(docutils.nodes.title):
+        heading_level = 0
+
+        ancestor = node.parent
+        while ancestor is not None:
+            if isinstance(ancestor, docutils.nodes.section):
+                heading_level = heading_level + 1
+
+            ancestor = ancestor.parent
+
+        if heading_level > max_heading_levels:
+            logger.warning("%s:%u: heading \"%s\" has nesting level %u; consider restructuring",
+                os.path.relpath(node.source, srcdir), node.line, node.astext(), heading_level + 1)
+
+def setup(app):
+    app.connect('doctree-read', process_doctree)
+
+    return {
+        'parallel_read_safe': True,
+        'parallel_write_safe': True,
+    }

  reply	other threads:[~2024-02-18 13:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-17 21:29 PDF misery Jonathan Corbet
2024-02-18  0:40 ` Mauro Carvalho Chehab
2024-02-18  9:58 ` Akira Yokosawa
2024-02-18 10:17   ` Mauro Carvalho Chehab
2024-02-19 17:49   ` Jonathan Corbet
2024-02-18 10:08 ` Vegard Nossum
2024-02-18 13:07   ` Vegard Nossum [this message]
2024-02-18 15:49 ` Akira Yokosawa
2024-02-18 19:57   ` Mauro Carvalho Chehab
2024-02-18 22:15   ` Jonathan Corbet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c6817759-62fc-48c8-9446-e985b6234745@oracle.com \
    --to=vegard.nossum@oracle.com \
    --cc=akiyks@gmail.com \
    --cc=corbet@lwn.net \
    --cc=jani.nikula@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).