Skip to contentSkip to conversation

docs: examples of pages affected by table overflow

PATCH In review Rito Rhymes 3 participants 9 messages Mar 21 – Apr 4

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover docs: examples of pages affected by table overflow

Examples of affected pages this patch improves:
kernel-hacking/locking.html
arch/arc/features.html
arch/arm/memory.html
arch/arm/omap/dss.html
arch/mips/features.html
arch/nios2/features.html
arch/openrisc/features.html
arch/parisc/features.html
arch/powerpc/features.html
arch/riscv/features.html
arch/s390/features.html
arch/sparc/features.html
arch/x86/boot.html
arch/x86/zero-page.html
arch/x86/pat.html
arch/x86/amd-hfi.html
arch/x86/tsx_async_abort.html
arch/x86/features.html
driver-api/parport-lowlevel.html

Rito Rhymes (1):
docs: wrap generated tables to contain small-screen overflow

 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
Signature · 1 line
2.51.0
#1 lore raw

PATCH 1/1 docs: wrap generated tables to contain small-screen overflow

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.

---
 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
Documentation/conf.py +1 -0
index 679861503..51756d779 100644
@@ -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
Documentation/sphinx-static/custom.css +16 -0
index db24f4344..d7c8c4f18 100644
@@ -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 {
Documentation/sphinx/table_wrapper.py new file +30 -0
new file mode 100644
index 000000000..dfe8c139b
@@ -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,
+    )
Signature · 1 line
2.51.0
reviewer Tested-by on v1 1/1
#2 lore raw

Re: [PATCH 1/1] docs: wrap generated tables to contain small-screen overflow

Quoted 11 lines · Rito Rhymes

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.

Yes, I can (did) observe that happening (horizontal slider bar).

Thanks.

Quoted 7 lines
---
 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
Signature · 1 line
~Randy
#3 lore raw

v2 cover docs: examples of pages affected by table overflow

In reply to Rito Rhymes

Examples of affected pages this patch improves:
kernel-hacking/locking.html
arch/arc/features.html
arch/arm/memory.html
arch/arm/omap/dss.html
arch/mips/features.html
arch/nios2/features.html
arch/openrisc/features.html
arch/parisc/features.html
arch/powerpc/features.html
arch/riscv/features.html
arch/s390/features.html
arch/sparc/features.html
arch/x86/boot.html
arch/x86/zero-page.html
arch/x86/pat.html
arch/x86/amd-hfi.html
arch/x86/tsx_async_abort.html
arch/x86/features.html
driver-api/parport-lowlevel.html

Rito Rhymes (1):
docs: wrap generated tables to contain small-screen overflow

 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
Signature · 1 line
2.51.0
#4 lore raw

PATCH v2 1/1 docs: wrap generated tables to contain small-screen overflow

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.

Assisted-by Codex:GPT-5.4

---
v2: add Assisted-by attribution

 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
Documentation/conf.py +1 -0
index 679861503..51756d779 100644
@@ -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
Documentation/sphinx-static/custom.css +16 -0
index db24f4344..d7c8c4f18 100644
@@ -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 {
Documentation/sphinx/table_wrapper.py new file +30 -0
new file mode 100644
index 000000000..dfe8c139b
@@ -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,
+    )
Signature · 1 line
2.51.0
#5 lore raw

PATCH v3 1/1 docs: wrap generated tables to contain small-screen overflow

In reply to Rito Rhymes

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

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
Documentation/conf.py +1 -0
index 679861503..51756d779 100644
@@ -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
Documentation/sphinx-static/custom.css +16 -0
index db24f4344..d7c8c4f18 100644
@@ -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 {
Documentation/sphinx/table_wrapper.py new file +30 -0
new file mode 100644
index 000000000..dfe8c139b
@@ -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,
+    )
Signature · 1 line
2.51.0
maintainer
#6 lore raw

Re: [PATCH v3] docs: wrap generated tables to contain small-screen overflow

Quoted 18 lines · Rito Rhymes

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

Assisted-by Codex:GPT-5.4

[...]

Quoted 22 lines
Documentation/sphinx-static/custom.css +7 -0
index db24f4344..d7c8c4f18 100644
@@ -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; }
 }
 

Documentation/sphinx-static/custom.css input.kernel-toc-toggle { display: none; } · line 115

Quoted 10 lines
Documentation/sphinx-static/custom.css +9 -0
+@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 */

So this CSS perhaps makes sense, but..

Quoted 27 lines
Documentation/sphinx-static/custom.css +0 -0
 div.admonition {
Documentation/sphinx/table_wrapper.py new file +20 -0
new file mode 100644
index 000000000..dfe8c139b
@@ -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")
+

Documentation/sphinx/table_wrapper.py line 30

Quoted 10 lines
Documentation/sphinx/table_wrapper.py new file +10 -0
+
+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,
+    )

But why do you need to inject another <div>, creating a whole new extension to do so, rather than just applying the CSS directly to the <table> elements? I just gave that a try, and it would appear to work just fine.

Thanks,

jon

#7 lore raw

Re: [PATCH v3] docs: wrap generated tables to contain small-screen overflow

Quoted 5 lines

So this CSS perhaps makes sense, but..
But why do you need to inject another <div>, creating a whole new extension to do so, rather than just applying the CSS directly to the <table> elements? I just gave that a try, and it would appear to work just fine.

I did try applying it directly to the <table> elements.

That works on some pages, but in my testing it introduces regressions on others that do not happen with the wrapper approach.

For example, on /bpf/standardization/instruction-set.html at 400px viewport width, applying CSS scrollability directly to the table creates an extra outer border with an awkward gap and, more importantly, causes cell content to wrap much more aggressively as the viewport narrows. Instead of letting the table remain a readable horizontally scrollable unit, the text gets squeezed into very narrow stacked lines that are harder to read.

Screenshots:
Double border with gap issue highlighted -
https://github.com/user-attachments/assets/0ddacc4e-edce-4c14-b129-0940e8014d3f
Text wrapping issue highlighted -
https://github.com/user-attachments/assets/c172e126-7a4c-4b3c-a01c-fd4c8f08bda6

On /arch/arc/features.html, the wrapping issue is not present and it scrolls fine, but I still see the double-border issue there. In that case there is no gap, so it mainly looks like a thicker border.

The reason for the wrapper is that it gives one consistent overflow treatment across the existing table cases without changing the table element's layout behavior directly. In my testing, applying the scrollability to the <table> itself works for some pages but regresses others, while the wrapper approach avoids needing targeted CSS rules for different rendered table cases.

If helpful, you're welcome to add any screenshots as a comment on this GitHub issue:
https://github.com/ritovision/linux-kernel-docs/issues/1

Rito

#8 lore raw

Re: [PATCH v3] docs: wrap generated tables to contain small-screen overflow

Jon,

Following up on this point:

Quoted 4 lines

So this CSS perhaps makes sense, but.. But why do you need to inject another <div>, creating a whole new extension to do so, rather than just applying the CSS directly to the <table> elements? I just gave that a try, and it would appear to work just fine.

In my previous reply I outlined the regressions I saw when applying the CSS directly to the <table> elements, and why that led me to the wrapper-based approach instead.

Given the regressions and rationale I already outlined, is the wrapper-based approach acceptable?

Thanks,
Rito