From c2fd77cbbc3675ca785d0ec6735d33e61adcb4f5 Mon Sep 17 00:00:00 2001 From: Vanessa Valderrama Date: Thu, 20 Mar 2025 12:19:17 -0500 Subject: [PATCH] feat: Add sticky table-column This commit introduces a feature to add a sticky first column to tables generated from the list-table directive in Sphinx. The first column now remains fixed during horizontal scrolling, enhancing the user experience and improving readability, especially for long tables such as the one in infra/inventory.rst. The implementation uses CSS with `position: sticky`. The CSS is added to _static/css/sticky-table-column.css and included in the Sphinx build via conf.py. Change-Id: Ie68a3524bc34c38149e85c86ed4ea0d8a5f09ffe Signed-off-by: Vanessa Valderrama --- docs/_static/css/sticky-table-column.css | 13 +++++++++++++ docs/conf.py | 1 + 2 files changed, 14 insertions(+) create mode 100644 docs/_static/css/sticky-table-column.css diff --git a/docs/_static/css/sticky-table-column.css b/docs/_static/css/sticky-table-column.css new file mode 100644 index 0000000..0304371 --- /dev/null +++ b/docs/_static/css/sticky-table-column.css @@ -0,0 +1,13 @@ +.rst-content .list-table table td:nth-child(1) { + position: sticky; + left: 0; + background-color: white; + z-index: 1; +} + +.rst-content .list-table table th:nth-child(1) { + position: sticky; + left: 0; + background-color: white; + z-index: 2; +} diff --git a/docs/conf.py b/docs/conf.py index 1070d7f..c68a23b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -48,3 +48,4 @@ sphinx_tabs_valid_builders = ["linkcheck"] def setup(app): """Injects the report issue ribbon.""" app.add_css_file("css/ribbon.css") + app.add_css_file("css/sticky-table-column.css") -- 2.16.6