eBPF-based security platform
docs: let a literal in a table cell break after punctuation
Daniel Borkmanna7577cf4d517
diff --git a/Documentation/_ext/shirudo_docs.py b/Documentation/_ext/shirudo_docs.pyindex f20d49b4..d192bb15 100644--- a/Documentation/_ext/shirudo_docs.py+++ b/Documentation/_ext/shirudo_docs.py@@ -4,11 +4,13 @@# Sphinx extension for the shirudo documentation: the page type and# reader line under each title, the source and last change in the page# footer, console blocks whose prompts name the role a command runs in,-# :src: links to the files of the repository, and the figures of images/-# written into the page, so that they take the colors of its theme.+# :src: links to the files of the repository, the figures of images/+# written into the page, so that they take the colors of its theme, and+# literals in tables that break after punctuation.import htmlimport os+import refrom docutils import nodesfrom pygments.lexer import RegexLexer, bygroups, default, using@@ -68,6 +70,34 @@ def inline_figures(app, doctree, docname):image.replace_self(nodes.raw("", svg, format="html"))+# The theme keeps every word of a literal on one line, so a path, option+# or setting in a table cell would set the width of its column alone.+# <wbr> adds no character, so a copied literal stays the same.+TABLE_BREAK = re.compile(r"(?<=[^/._\-=,:|\s])[/._\-=,:|]+(?=[^/._\-=,:|\s])")+++def break_table_literals(app, doctree, docname):+ """Let a literal in a table cell break after / . _ - = , : | and+ nowhere else."""+ if app.builder.format != "html":+ return+ for entry in doctree.findall(nodes.entry):+ for literal in list(entry.findall(nodes.literal)):+ if "kbd" in literal["classes"] or literal.get("language"):+ continue+ for text in list(literal.findall(nodes.Text)):+ value = str(text)+ parts = []+ start = 0+ for match in TABLE_BREAK.finditer(value):+ parts.append(nodes.Text(value[start:match.end()]))+ parts.append(nodes.raw("", "<wbr>", format="html"))+ start = match.end()+ if parts:+ parts.append(nodes.Text(value[start:]))+ text.parent.replace(text, parts)++CHANGES = {}@@ -167,6 +197,7 @@ def setup(app):CHANGES.update(last_changes())app.connect("doctree-resolved", meta_line)app.connect("doctree-resolved", inline_figures)+ app.connect("doctree-resolved", break_table_literals)app.connect("html-page-context", page_context)app.connect("build-finished", write_llms)return {"parallel_read_safe": True, "parallel_write_safe": True}diff --git a/Documentation/_themes/shirudo/static/shirudo.css b/Documentation/_themes/shirudo/static/shirudo.cssindex 491758d6..787d4f3c 100644--- a/Documentation/_themes/shirudo/static/shirudo.css+++ b/Documentation/_themes/shirudo/static/shirudo.css@@ -281,7 +281,6 @@ aside.footnote-list { border-top: 1px solid var(--line); margin-top: 2em; paddin.body p.meta[class*="kind-"] { margin: -2px 0 12px; }.body p.rubric { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 8px 0 0; }table.columns td:first-child code { white-space: nowrap; }-table.columns td code { overflow-wrap: anywhere; }table.columns code.codec, table.columns p.default { color: var(--muted); }table.columns p.default { font-size: 12.5px; }table.sizes td:last-child, table.sizes th:last-child { text-align: right; padding-right: 0; }diff --git a/Documentation/contribute/documentation/writing-docs.rst b/Documentation/contribute/documentation/writing-docs.rstindex dc09a748..d7d91c02 100644--- a/Documentation/contribute/documentation/writing-docs.rst+++ b/Documentation/contribute/documentation/writing-docs.rst@@ -222,6 +222,10 @@ Tables and figures------------------- Prefer ``list-table`` for tables, with a header row.+- A literal in a table cell breaks only after ``/ . _ - = , : |``, which+ the build marks, so a long path or option does not set the width of+ its column. A literal with none of them, such as a hex digest, still+ does: give it a line of its own after the table.- Include a figure with ``.. figure:: /images/<name>.svg`` and an``:alt:`` that says what it shows. Number it in the caption ("Figure1.") and refer to it from the text before it appears.