Skip to content

Commit 0249a76

Browse files
return42Jonathan Corbet
authored andcommitted
doc-rst: flat-table directive - initial implementation
Implements the reST flat-table directive. The ``flat-table`` is a double-stage list similar to the ``list-table`` with some additional features: * column-span: with the role ``cspan`` a cell can be extended through additional columns * row-span: with the role ``rspan`` a cell can be extended through additional rows * auto span rightmost cell of a table row over the missing cells on the right side of that table-row. With Option ``:fill-cells:`` this behavior can changed from *auto span* to *auto fill*, which automaticly inserts (empty) list tables The *list tables* formats are double stage lists. Compared to the ASCII-art they migth be less comfortable for readers of the text-files. Their advantage is, that they are easy to create/modify and that the diff of a modification is much more meaningfull, because it is limited to the modified content. The initial implementation was taken from the sphkerneldoc project [1] [1] https://github.com/return42/sphkerneldoc/commits/master/scripts/site-python/linuxdoc/rstFlatTable.py Signed-off-by: Markus Heiser <[email protected]> [jc: fixed typos and misspellings in the docs] Signed-off-by: Jonathan Corbet <[email protected]>
1 parent 17defc2 commit 0249a76

File tree

3 files changed

+452
-1
lines changed

3 files changed

+452
-1
lines changed

Documentation/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# Add any Sphinx extension module names here, as strings. They can be
2929
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3030
# ones.
31-
extensions = ['kernel-doc']
31+
extensions = ['kernel-doc', 'rstFlatTable']
3232

3333
# Gracefully handle missing rst2pdf.
3434
try:

Documentation/kernel-documentation.rst

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,92 @@ Here are some specific guidelines for the kernel documentation:
107107
the order as encountered."), having the higher levels the same overall makes
108108
it easier to follow the documents.
109109

110+
list tables
111+
-----------
112+
113+
We recommend the use of *list table* formats. The *list table* formats are
114+
double-stage lists. Compared to the ASCII-art they might not be as
115+
comfortable for
116+
readers of the text files. Their advantage is that they are easy to
117+
create or modify and that the diff of a modification is much more meaningful,
118+
because it is limited to the modified content.
119+
120+
The ``flat-table`` is a double-stage list similar to the ``list-table`` with
121+
some additional features:
122+
123+
* column-span: with the role ``cspan`` a cell can be extended through
124+
additional columns
125+
126+
* row-span: with the role ``rspan`` a cell can be extended through
127+
additional rows
128+
129+
* auto span rightmost cell of a table row over the missing cells on the right
130+
side of that table-row. With Option ``:fill-cells:`` this behavior can
131+
changed from *auto span* to *auto fill*, which automatically inserts (empty)
132+
cells instead of spanning the last cell.
133+
134+
options:
135+
136+
* ``:header-rows:`` [int] count of header rows
137+
* ``:stub-columns:`` [int] count of stub columns
138+
* ``:widths:`` [[int] [int] ... ] widths of columns
139+
* ``:fill-cells:`` instead of auto-spanning missing cells, insert missing cells
140+
141+
roles:
142+
143+
* ``:cspan:`` [int] additional columns (*morecols*)
144+
* ``:rspan:`` [int] additional rows (*morerows*)
145+
146+
The example below shows how to use this markup. The first level of the staged
147+
list is the *table-row*. In the *table-row* there is only one markup allowed,
148+
the list of the cells in this *table-row*. Exceptions are *comments* ( ``..`` )
149+
and *targets* (e.g. a ref to ``:ref:`last row <last row>``` / :ref:`last row
150+
<last row>`).
151+
152+
.. code-block:: rst
153+
154+
.. flat-table:: table title
155+
:widths: 2 1 1 3
156+
157+
* - head col 1
158+
- head col 2
159+
- head col 3
160+
- head col 4
161+
162+
* - column 1
163+
- field 1.1
164+
- field 1.2 with autospan
165+
166+
* - column 2
167+
- field 2.1
168+
- :rspan:`1` :cspan:`1` field 2.2 - 3.3
169+
170+
* .. _`last row`:
171+
172+
- column 3
173+
174+
Rendered as:
175+
176+
.. flat-table:: table title
177+
:widths: 2 1 1 3
178+
179+
* - head col 1
180+
- head col 2
181+
- head col 3
182+
- head col 4
183+
184+
* - column 1
185+
- field 1.1
186+
- field 1.2 with autospan
187+
188+
* - column 2
189+
- field 2.1
190+
- :rspan:`1` :cspan:`1` field 2.2 - 3.3
191+
192+
* .. _`last row`:
193+
194+
- column 3
195+
110196

111197
Including kernel-doc comments
112198
=============================

0 commit comments

Comments
 (0)