Skip to content

Commit ad6c2da

Browse files
authored
DOC: add a matrix style (python-graphblas#502)
1 parent 717cbda commit ad6c2da

File tree

6 files changed

+200
-52
lines changed

6 files changed

+200
-52
lines changed

docs/_static/matrix.css

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/* Based on the stylesheet used by matrepr (https://github.com/alugowski/matrepr) and modified for sphinx */
2+
3+
table.matrix {
4+
border-collapse: collapse;
5+
border: 0px;
6+
}
7+
8+
/* Disable a horizintal line from the default stylesheet */
9+
.table.matrix > :not(caption) > * > * {
10+
border-bottom-width: 0px;
11+
}
12+
13+
/* row indices */
14+
table.matrix > tbody tr th {
15+
font-size: smaller;
16+
font-weight: bolder;
17+
vertical-align: middle;
18+
text-align: right;
19+
}
20+
/* row indices are often made bold in the source data; here make them match the boldness of the th column label style*/
21+
table.matrix strong {
22+
font-weight: bold;
23+
}
24+
25+
/* column indices */
26+
table.matrix > thead tr th {
27+
font-size: smaller;
28+
font-weight: bolder;
29+
vertical-align: middle;
30+
text-align: center;
31+
}
32+
33+
/* cells */
34+
table.matrix > tbody tr td {
35+
vertical-align: middle;
36+
text-align: center;
37+
position: relative;
38+
}
39+
40+
/* left border */
41+
table.matrix > tbody tr td:first-of-type {
42+
border-left: solid 2px var(--pst-color-text-base);
43+
}
44+
/* right border */
45+
table.matrix > tbody tr td:last-of-type {
46+
border-right: solid 2px var(--pst-color-text-base);
47+
}
48+
49+
/* prevents empty cells from collapsing, especially empty rows */
50+
table.matrix > tbody tr td:empty::before {
51+
/* basicaly fills empty cells with   */
52+
content: "\00a0\00a0\00a0";
53+
visibility: hidden;
54+
}
55+
table.matrix > tbody tr td:empty::after {
56+
content: "\00a0\00a0\00a0";
57+
visibility: hidden;
58+
}
59+
60+
/* matrix bracket ticks */
61+
table.matrix > tbody > tr:first-child > td:first-of-type::before {
62+
content: "";
63+
width: 4px;
64+
position: absolute;
65+
top: 0;
66+
bottom: 0;
67+
visibility: visible;
68+
left: 0;
69+
right: auto;
70+
border-top: solid 2px var(--pst-color-text-base);
71+
}
72+
table.matrix > tbody > tr:last-child > td:first-of-type::before {
73+
content: "";
74+
width: 4px;
75+
position: absolute;
76+
top: 0;
77+
bottom: 0;
78+
visibility: visible;
79+
left: 0;
80+
right: auto;
81+
border-bottom: solid 2px var(--pst-color-text-base);
82+
}
83+
table.matrix > tbody > tr:first-child > td:last-of-type::after {
84+
content: "";
85+
width: 4px;
86+
position: absolute;
87+
top: 0;
88+
bottom: 0;
89+
visibility: visible;
90+
left: auto;
91+
right: 0;
92+
border-top: solid 2px var(--pst-color-text-base);
93+
}
94+
table.matrix > tbody > tr:last-child > td:last-of-type::after {
95+
content: "";
96+
width: 4px;
97+
position: absolute;
98+
top: 0;
99+
bottom: 0;
100+
visibility: visible;
101+
left: auto;
102+
right: 0;
103+
border-bottom: solid 2px var(--pst-color-text-base);
104+
}

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3737
# ones.
3838
extensions = ["sphinx.ext.autodoc", "numpydoc", "sphinx_panels", "nbsphinx"]
39-
html_css_files = ["custom.css"]
39+
html_css_files = ["custom.css", "matrix.css"]
4040
html_js_files = ["custom.js"]
4141

4242
# Add any paths that contain templates here, relative to this directory.

docs/user_guide/io.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ array will match the collection dtype.
2929
v = gb.Vector.from_coo([1, 3, 6], [2, 3, 4], float, size=10)
3030
3131
.. csv-table::
32+
:class: matrix
3233
:header: 0,1,2,3,4,5,6,7,8,9,10
3334

3435
,2.0,,3.0,,,4.0,,,

0 commit comments

Comments
 (0)