Skip to content

ListTable class #788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
69 changes: 68 additions & 1 deletion bin/table_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions themes/mongodb/static/mongodb-docs.css_t
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down