From 67ee2f1641112a56b94eb4191ea45d55cc1f4ede Mon Sep 17 00:00:00 2001 From: kay Date: Mon, 25 Mar 2013 18:31:21 -0400 Subject: [PATCH] ListTable class add scroll to the div body --- bin/table_builder.py | 69 +++++++++++++++++++++++- themes/mongodb/static/mongodb-docs.css_t | 1 + 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/bin/table_builder.py b/bin/table_builder.py index 24936ad3fdf..33f8a6f1145 100644 --- a/bin/table_builder.py +++ b/bin/table_builder.py @@ -200,8 +200,75 @@ def render_table(self): return o + +################################### +# +# Outputs a list-table + class ListTable(OutputTable): - pass + + spacing = ' ' + newrowmarker = ' * - ' + newcolmarker = ' - ' + + def __init__(self, imported_table): + + self.table = imported_table + self.process_table_content() + self.output = self.render_table() + + def process_table_content(self): + self.tabledata = [] + prepend = '' + + for index in range(len(self.table.rows)): + isnewrow = True + + # Append each cell to the parsed_row list, breaking multi-line + # cell data as needed. + for cell in self.table.rows[index][index + 1]: + firstline=True + + if isnewrow: + prepend = ListTable.newrowmarker + isnewrow = False + else: + prepend = ListTable.newcolmarker + + parsed_row= cell.split('\n') + + for parsed in parsed_row: + if firstline: + self.tabledata.append(prepend + parsed) + firstline = False + else: + self.tabledata.append(ListTable.spacing + parsed) + + def render_table(self): + + o = [] + + o.append('.. list-table::') + + if self.table.header is not None: + isnewrow = True + + o.append(' :header-rows: 1') + o.append('') + + for heading in self.table.header: + if isnewrow: + o.append(ListTable.newrowmarker + heading[0]) + isnewrow = False + else: + o.append(ListTable.newcolmarker + heading[0]) + + o.append('') + + for row in self.tabledata: + o.append(row) + + return o class HtmlTable(OutputTable): pass diff --git a/themes/mongodb/static/mongodb-docs.css_t b/themes/mongodb/static/mongodb-docs.css_t index c504e97c385..65f4e70eed4 100644 --- a/themes/mongodb/static/mongodb-docs.css_t +++ b/themes/mongodb/static/mongodb-docs.css_t @@ -40,6 +40,7 @@ div.body { background-color: white; color: black; font-size: 100%; + overflow-x: scroll; } div.body > div#cse-results + div.section { margin:0 1.5em; }