gwin.utils.sphinx module

Sphinx/RST for GWIn

gwin.utils.sphinx.rst_dict_table(dict_, key_format=<type 'str'>, val_format=<type 'str'>, header=None)[source]

Returns an RST-formatted table of keys and values from a dict

Parameters:
  • dict (dict) – data to display in table
  • key_format (callable) – callable function with which to format keys
  • val_format (callable) – callable function with which to format values
  • header (None, tuple of str) – a 2-tuple of header for the two columns, or None to exclude a header line (default)

Examples

>>> a = {'key1': 'value1', 'key2': 'value2'}
>>> print(rst_dict_table(a))
====  ======
key1  value1
key2  value2
====  ======
>>> print(rst_dict_table(a, key_format='``{}``'.format,
...                      val_format=':class:`{}`'.format,
...                      header=('Key', 'Value'))
========  ===============
Key       Value
========  ===============
``key1``  :class:`value1`
``key2``  :class:`value2`
========  ===============