|
| 1 | +(gridtable-directive)= |
| 2 | + |
| 3 | +# Grid Table |
| 4 | + |
| 5 | + |
| 6 | +## About |
| 7 | + |
| 8 | +_sd-table -- Tables with sphinx{design}_. |
| 9 | + |
| 10 | +A generic, beautiful, yet efficient table element based on a [grid layout](inv:sd#grids), |
| 11 | +with top-down configuration capabilities. |
| 12 | + |
| 13 | +It provides the Sphinx directives `sd-table`, `sd-row`, and `sd-item`, |
| 14 | +and a few convenience directive options and flags on them. |
| 15 | + |
| 16 | + |
| 17 | +## Details |
| 18 | + |
| 19 | +The idea of this element is to implement a table based on a grid layout, which can |
| 20 | +be parameterized using directives on the table level, so that styling details will |
| 21 | +not clutter the leaf nodes (row and item) too much. |
| 22 | + |
| 23 | +To goal is to provide a table element as an alternative to the `list-table` and |
| 24 | +`csv-table` directives, which explores a few needs of authors not offered by |
| 25 | +other Sphinx directives. |
| 26 | + |
| 27 | + |
| 28 | +## Synopsis |
| 29 | + |
| 30 | +Basic table, two columns, no formatting. |
| 31 | + |
| 32 | +::::{sd-table} |
| 33 | +:widths: 3 9 |
| 34 | + |
| 35 | +:::{sd-row} |
| 36 | +```{sd-item} **What** |
| 37 | +``` |
| 38 | +```{sd-item} **Description** |
| 39 | +``` |
| 40 | +::: |
| 41 | + |
| 42 | +:::{sd-row} |
| 43 | +```{sd-item} Fox |
| 44 | +``` |
| 45 | +```{sd-item} |
| 46 | +The quick brown fox jumps |
| 47 | +over the lazy dog. |
| 48 | +``` |
| 49 | +::: |
| 50 | +:::{sd-row} |
| 51 | +```{sd-item} Franz |
| 52 | +``` |
| 53 | +```{sd-item} |
| 54 | +Franz jagt im komplett verwahrlosten |
| 55 | +Taxi quer durch Bayern. |
| 56 | +``` |
| 57 | +::: |
| 58 | + |
| 59 | +:::: |
| 60 | + |
| 61 | + |
| 62 | +## Usage |
| 63 | + |
| 64 | +sphinx{design} uses a classic 12-column grid layout, so, in order to use |
| 65 | +it optimally, make sure that your table item/column widths sum up to 12. |
| 66 | + |
| 67 | +The example table defines two columns, using individual widths of `3` and `9`. |
| 68 | + |
| 69 | +````{tab-set-code} |
| 70 | +```{literalinclude} ./snippets/myst/gridtable.md |
| 71 | +:language: markdown |
| 72 | +``` |
| 73 | +```{literalinclude} ./snippets/rst/gridtable.rst |
| 74 | +:language: rst |
| 75 | +``` |
| 76 | +```` |
| 77 | + |
| 78 | + |
| 79 | +## Variants |
| 80 | + |
| 81 | +A few more variants how to change the visual appearance. |
| 82 | + |
| 83 | +### Visual line separators |
| 84 | + |
| 85 | +Using `:row-class:` to assign row-level styles on the table-level component. |
| 86 | + |
| 87 | +::::{sd-table} |
| 88 | +:widths: 3 9 |
| 89 | +:row-class: top-border |
| 90 | + |
| 91 | +:::{sd-row} |
| 92 | +```{sd-item} **What** |
| 93 | +``` |
| 94 | +```{sd-item} **Description** |
| 95 | +``` |
| 96 | +::: |
| 97 | + |
| 98 | +:::{sd-row} |
| 99 | +```{sd-item} Fox |
| 100 | +``` |
| 101 | +```{sd-item} |
| 102 | +The quick brown fox jumps |
| 103 | +over the lazy dog. |
| 104 | +``` |
| 105 | +::: |
| 106 | +:::{sd-row} |
| 107 | +```{sd-item} Franz |
| 108 | +``` |
| 109 | +```{sd-item} |
| 110 | +Franz jagt im komplett verwahrlosten |
| 111 | +Taxi quer durch Bayern. |
| 112 | +``` |
| 113 | +::: |
| 114 | + |
| 115 | +:::: |
| 116 | + |
| 117 | + |
| 118 | +### Outlines |
| 119 | + |
| 120 | +This section demonstrates different kinds of outlines, on different component levels. |
| 121 | + |
| 122 | +#### Table outline |
| 123 | + |
| 124 | +Using the `:outline:` directive flag will draw a single border around the whole **table**. |
| 125 | + |
| 126 | +```markdown |
| 127 | +::::{sd-table} |
| 128 | +:outline: |
| 129 | +``` |
| 130 | + |
| 131 | +::::{sd-table} |
| 132 | +:widths: 3 9 |
| 133 | +:outline: |
| 134 | + |
| 135 | +:::{sd-row} |
| 136 | +```{sd-item} **What** |
| 137 | +``` |
| 138 | +```{sd-item} **Description** |
| 139 | +``` |
| 140 | +::: |
| 141 | + |
| 142 | +:::{sd-row} |
| 143 | +```{sd-item} Fox |
| 144 | +``` |
| 145 | +```{sd-item} |
| 146 | +The quick brown fox jumps |
| 147 | +over the lazy dog. |
| 148 | +``` |
| 149 | +::: |
| 150 | +:::{sd-row} |
| 151 | +```{sd-item} Franz |
| 152 | +``` |
| 153 | +```{sd-item} |
| 154 | +Franz jagt im komplett verwahrlosten |
| 155 | +Taxi quer durch Bayern. |
| 156 | +``` |
| 157 | +::: |
| 158 | + |
| 159 | +:::: |
| 160 | + |
| 161 | + |
| 162 | +#### Row outline |
| 163 | + |
| 164 | +Using the `:row-outline:` directive flag will draw borders around each **row** component. |
| 165 | + |
| 166 | +```markdown |
| 167 | +::::{sd-table} |
| 168 | +:row-outline: |
| 169 | +``` |
| 170 | + |
| 171 | +::::{sd-table} |
| 172 | +:widths: 3 9 |
| 173 | +:row-outline: |
| 174 | + |
| 175 | +:::{sd-row} |
| 176 | +```{sd-item} **What** |
| 177 | +``` |
| 178 | +```{sd-item} **Description** |
| 179 | +``` |
| 180 | +::: |
| 181 | + |
| 182 | +:::{sd-row} |
| 183 | +```{sd-item} Fox |
| 184 | +``` |
| 185 | +```{sd-item} |
| 186 | +The quick brown fox jumps |
| 187 | +over the lazy dog. |
| 188 | +``` |
| 189 | +::: |
| 190 | +:::{sd-row} |
| 191 | +```{sd-item} Franz |
| 192 | +``` |
| 193 | +```{sd-item} |
| 194 | +Franz jagt im komplett verwahrlosten |
| 195 | +Taxi quer durch Bayern. |
| 196 | +``` |
| 197 | +::: |
| 198 | + |
| 199 | +:::: |
| 200 | + |
| 201 | + |
| 202 | +#### Item outline |
| 203 | + |
| 204 | +Using the `:item-outline:` directive flag will draw borders around each **item** component. |
| 205 | + |
| 206 | +```markdown |
| 207 | +::::{sd-table} |
| 208 | +:item-outline: |
| 209 | +``` |
| 210 | + |
| 211 | +::::{sd-table} |
| 212 | +:widths: 3 9 |
| 213 | +:item-outline: |
| 214 | + |
| 215 | +:::{sd-row} |
| 216 | +```{sd-item} **What** |
| 217 | +``` |
| 218 | +```{sd-item} **Description** |
| 219 | +``` |
| 220 | +::: |
| 221 | + |
| 222 | +:::{sd-row} |
| 223 | +```{sd-item} Fox |
| 224 | +``` |
| 225 | +```{sd-item} |
| 226 | +The quick brown fox jumps |
| 227 | +over the lazy dog. |
| 228 | +``` |
| 229 | +::: |
| 230 | +:::{sd-row} |
| 231 | +```{sd-item} Franz |
| 232 | +``` |
| 233 | +```{sd-item} |
| 234 | +Franz jagt im komplett verwahrlosten |
| 235 | +Taxi quer durch Bayern. |
| 236 | +``` |
| 237 | +::: |
| 238 | + |
| 239 | +:::: |
| 240 | + |
| 241 | + |
| 242 | +--- |
| 243 | + |
| 244 | +_This page is written in Markedly Structured Text (MyST Markdown)._ |
0 commit comments