Skip to content

Support table templates

Tables also need templating.

I suggest a dict where key is column of a table, value is a header-cell tuple.

Proposed syntax in conf.py:

constdata_files = {
    "foo.csv":  {
        "label": ":guilabel:`{Path}`",
        "table: {
            "__title__": "Foo options reference",
            "__widths__": "30,20,50",
            "col": ("_('Column')", "``{col}`` ({flags})"),
            "type": ("_('Type')", "{type}"),
            "desc": ("_('Description')", "{desc}")
        }
    }
}

Alternatively, and it will take precedence, as table options:

.. constdata:table:: foo.csv

   :__title__: "Foo options reference",
   :__widths__: "30,20,50",
   :col: ("_('Column')", "``{col}`` ({flags})"),
   :type: ("_('Type')", "{type}"),
   :desc: ("_('Description')", "{desc}")

Each key is a column in file. Value is tuple of header text and cell template.

Headers and cells can also contain _("translatable") parts! Gettext builder must pick them too.

Not listed columns are hidden in the table.

Few __special__ keys are recognized like __title__, __widths__ (corresponds to table options).

Strings only! For example, true in YAML or JSON, will normally produce 1. Or `null`` produce blank string. Point out in the docs that flatfiles should contain strings primarily to prevent any implicit conversions.

Edited by Matt from Documatt