Documentation/conf.py | 1 + Documentation/sphinx-static/custom.css | 16 ++++++++++++++ Documentation/sphinx/table_wrapper.py | 30 ++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 Documentation/sphinx/table_wrapper.py
Some documentation tables exceed the fixed-width main content column.
On desktop this is usually acceptable because they can overflow the
800px body without harming readability, but on smaller screens the
same tables create page-wide horizontal scroll overflow that breaks the
layout.
Wrap generated HTML tables in a dedicated container. Above
Alabaster's existing 65em breakpoint, the wrapper uses
`display: contents` to preserve current desktop rendering. At and
below that width, it becomes a horizontal scroll container so table
overflow is contained locally instead of breaking page layout.
Examples:
https://docs.kernel.org/6.15/kernel-hacking/locking.html
https://docs.kernel.org/6.15/arch/arc/features.html
Signed-off-by: Rito Rhymes <rito@ritovision.com>
Assisted-by: Codex:GPT-5.4
---
v3: add latest public versioned URL examples to the patchlog
Documentation/conf.py | 1 +
Documentation/sphinx-static/custom.css | 16 ++++++++++++++
Documentation/sphinx/table_wrapper.py | 30 ++++++++++++++++++++++++++
3 files changed, 47 insertions(+)
create mode 100644 Documentation/sphinx/table_wrapper.py
diff --git a/Documentation/conf.py b/Documentation/conf.py
index 679861503..51756d779 100644
--- a/Documentation/conf.py
+++ b/Documentation/conf.py
@@ -159,6 +159,7 @@ extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosectionlabel",
"sphinx.ext.ifconfig",
+ "table_wrapper",
"translations",
]
# Since Sphinx version 3, the C function parser is more pedantic with regards
diff --git a/Documentation/sphinx-static/custom.css b/Documentation/sphinx-static/custom.css
index db24f4344..d7c8c4f18 100644
--- a/Documentation/sphinx-static/custom.css
+++ b/Documentation/sphinx-static/custom.css
@@ -23,6 +23,13 @@ div.document {
margin: 20px 10px 0 10px;
width: auto;
}
+/*
+ * Wrap generated tables in a container that preserves desktop overflow
+ * while allowing contained scrolling on smaller screens.
+ */
+div.body div.table-overflow {
+ display: contents;
+}
/* Size the logo appropriately */
img.logo {
@@ -96,6 +103,15 @@ input.kernel-toc-toggle { display: none; }
div.kerneltoc a { color: black; }
}
+@media screen and (max-width: 65em) {
+ div.body div.table-overflow {
+ display: block;
+ max-width: 100%;
+ overflow-x: auto;
+ overflow-y: hidden;
+ }
+}
+
/* Language selection menu */
div.admonition {
diff --git a/Documentation/sphinx/table_wrapper.py b/Documentation/sphinx/table_wrapper.py
new file mode 100644
index 000000000..dfe8c139b
--- /dev/null
+++ b/Documentation/sphinx/table_wrapper.py
@@ -0,0 +1,30 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+"""Wrap generated HTML tables in a responsive overflow container."""
+
+from sphinx.writers.html5 import HTML5Translator
+
+__version__ = "1.0"
+
+
+class TableWrapperHTMLTranslator(HTML5Translator):
+ """Add a wrapper around tables so CSS can control overflow behavior."""
+
+ def visit_table(self, node):
+ self.body.append('<div class="table-overflow">\n')
+ super().visit_table(node)
+
+ def depart_table(self, node):
+ super().depart_table(node)
+ self.body.append("</div>\n")
+
+
+def setup(app):
+ for builder in ("html", "dirhtml", "singlehtml"):
+ app.set_translator(builder, TableWrapperHTMLTranslator, override=True)
+
+ return dict(
+ version=__version__,
+ parallel_read_safe=True,
+ parallel_write_safe=True,
+ )
--
2.51.0
© 2016 - 2026 Red Hat, Inc.