click_extra.sphinx.tables moduleΒΆ
Style the two-axis tables of a Sphinx build.
A table whose top-left cell names both of its axes, as
corner_header() spells them, is read down its first
column and across its headers. On a narrow screen, a browser wraps that first
column wherever it can, including after the hyphen of click-extra or of a
date, which splits every label over several lines. The labels of such a table
are short, so this module keeps each one whole: the table scrolls sideways
instead, inside the table-wrapper Furo puts around every table.
A compatibility matrix is such a table, and each of its cells holds the glyph of
a state (see click_extra.sphinx.matrix). This module tints those cells
green, red or grey by state, so the shape of the support reads at a glance.
The extension marks every table whose first header cell holds
CORNER_GLYPH, and each of its body cells holding a
state glyph alone, then ships the stylesheet the marks hook into. The
stylesheet is written into the build rather than packaged as a data file.
- click_extra.sphinx.tables.CORNER_TABLE_CLASS = 'corner-table'ΒΆ
HTML class of a table whose top-left cell names both of its axes.
- click_extra.sphinx.tables.SUPPORTED_CELL_CLASS = 'matrix-supported'ΒΆ
HTML class of a cell holding
SUPPORTED_CELL.
- click_extra.sphinx.tables.FORBIDDEN_CELL_CLASS = 'matrix-forbidden'ΒΆ
HTML class of a cell holding
FORBIDDEN_CELL.
- click_extra.sphinx.tables.UNDECLARED_CELL_CLASS = 'matrix-undeclared'ΒΆ
HTML class of a cell holding
UNDECLARED_CELL.
- click_extra.sphinx.tables.STATE_CELL_CLASSES: dict[str, str] = {'β': 'matrix-undeclared', 'β ': 'matrix-supported', 'β': 'matrix-forbidden'}ΒΆ
The HTML class of each state glyph, for a body cell holding that glyph alone.
- click_extra.sphinx.tables.CORNER_TABLE_CSS = 'table.corner-table th:first-child,\ntable.corner-table td:first-child {\n white-space: nowrap;\n}\n\n/* State tints are translucent, so they read on light and dark themes alike.\n * Each is drawn as a background image, which layers over the background color\n * the crosshair sets on hover instead of hiding it. */\ntable.corner-table td.matrix-supported {\n --matrix-tint: rgba(46, 160, 67, 0.15);\n}\ntable.corner-table td.matrix-forbidden {\n --matrix-tint: rgba(248, 81, 73, 0.15);\n}\ntable.corner-table td.matrix-undeclared {\n --matrix-tint: rgba(128, 128, 128, 0.1);\n}\ntable.corner-table td.matrix-supported,\ntable.corner-table td.matrix-forbidden,\ntable.corner-table td.matrix-undeclared {\n background-image: linear-gradient(var(--matrix-tint), var(--matrix-tint));\n}\n'ΒΆ
Stylesheet of corner-labeled tables.
Keeps their first column on one line, and tints the state cells of a matrix.
- click_extra.sphinx.tables.STATIC_DIR = '_click_extra_static'ΒΆ
Output folder of the stylesheets and scripts the extension writes.
Sphinx copies it into
_staticwith the other static files, as it does for every folder listed inhtml_static_path. See_write_static_file.
- click_extra.sphinx.tables.STYLESHEET = 'click-extra.css'ΒΆ
File name of the stylesheet, served from the
_staticfolder.
- click_extra.sphinx.tables.mark_corner_tables(app, doctree)[source]ΒΆ
Add
CORNER_TABLE_CLASSto every table with a corner label.Each body cell of such a table holding a state glyph alone also gets the class of that state (see
STATE_CELL_CLASSES).- Return type:
- click_extra.sphinx.tables.add_stylesheet(app)[source]ΒΆ
Write
CORNER_TABLE_CSSinto the build and link it from each page.Only an HTML builder serves stylesheets, so other builders skip it.
- Return type:
- click_extra.sphinx.tables.setup(app)[source]ΒΆ
Register the table marker and its stylesheet on
app.Called from
click_extra.sphinx.setup()so projects only need to list"click_extra.sphinx"in theirextensions.- Return type: