diff options
author | Kavon Farvardin <kavon@farvard.in> | 2018-09-23 15:29:37 -0500 |
---|---|---|
committer | Kavon Farvardin <kavon@farvard.in> | 2018-09-23 15:29:37 -0500 |
commit | 84c2ad99582391005b5e873198b15e9e9eb4f78d (patch) | |
tree | caa8c2f2ec7e97fbb4977263c6817c9af5025cf4 /docs/users_guide/utils.py | |
parent | 8ddb47cfcf5776e9a3c55fd37947c8a95e00fa12 (diff) | |
parent | e68b439fe5de61b9a2ca51af472185c62ccb8b46 (diff) | |
download | haskell-wip/T13904.tar.gz |
update to current master againwip/T13904
Diffstat (limited to 'docs/users_guide/utils.py')
-rw-r--r-- | docs/users_guide/utils.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/users_guide/utils.py b/docs/users_guide/utils.py new file mode 100644 index 0000000000..128ae51ba5 --- /dev/null +++ b/docs/users_guide/utils.py @@ -0,0 +1,26 @@ +from docutils import nodes + +# Taken from Docutils source inside the ListTable class. We must bypass +# using the class itself, but this function comes in handy. +def build_table_from_list(table_data, col_widths): + table = nodes.table() + tgroup = nodes.tgroup(cols=len(col_widths)) + table += tgroup + for col_width in col_widths: + colspec = nodes.colspec(colwidth=col_width) + tgroup += colspec + rows = [] + for row in table_data: + row_node = nodes.row() + for cell in row: + entry = nodes.entry() + entry += cell + row_node += entry + rows.append(row_node) + thead = nodes.thead() + thead.extend(rows[:1]) + tgroup += thead + tbody = nodes.tbody() + tbody.extend(rows[1:]) + tgroup += tbody + return table |