Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions docs/linuxdoc-howto/table-markup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -226,25 +226,6 @@ roles:
:cspan: [int] additional columns (*morecols*)
:rspan: [int] additional rows (*morerows*)

The ``:rspan:`` and ``:cspan:`` are *special* reST-roles_. These directives
are used in the :py:obj:`linuxdoc.rstFlatTable.ListTableBuilder` and
:py:obj:`removed <linuxdoc.rstFlatTable.ListTableBuilder.parseCellItem>` while
the table is parsed. These reST-roles must not be in the translation:

.. code-block:: po

#: ../index.rst:21
msgid ":rspan:`1` :cspan:`1` field 2.2 - 3.3"
msgstr "test (fr) field 2.2 - 3.3"

Most other reST-roles_ should be translated *as-is*:

.. code-block:: po

#: ../index.rst:48
msgid ":math:`a^2 + b^2 = c^2`"
msgstr "test (fr) :math:`a^2 + b^2 = c^2`"

The example below shows how to use this markup. The first level of the staged
list is the *table-row*. In the *table-row* there is only one markup allowed,
the list of the cells in this *table-row*. Exception are *comments* ( ``..`` )
Expand Down
15 changes: 15 additions & 0 deletions linuxdoc/rstFlatTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def setup(app):
app.add_directive("flat-table", FlatTable)
roles.register_local_role('cspan', c_span)
roles.register_local_role('rspan', r_span)
app.connect('doctree-resolved', FlatTableProcessor)

return dict(
version = __version__,
Expand Down Expand Up @@ -347,3 +348,17 @@ def parseCellItem(self, cellItem):
elem.parent.remove(elem)
continue
return cspan, rspan, cellItem[:]

# ==============================================================================
class FlatTableProcessor:
# ==============================================================================

u"""Remove colSpan and rowSpan from the document after the doctree-resolved
phase."""

def __init__(self, app, doctree: nodes.document, docname: str) -> None:
self.process(doctree)

def process(self, doctree: nodes.document) -> None:
for node in list(doctree.findall(lambda item: isinstance(item, (colSpan, rowSpan)))):
node.parent.remove(node)