def create_cross_table(self, app, docname, node, matrix, options):
        table = nodes.table()
        table["classes"].append("traceables-crosstable")
        tgroup = nodes.tgroup(cols=len(matrix.secondaries), colwidths="auto")
        table += tgroup

        # Add column specifications.
        tgroup += nodes.colspec(colwidth=1)
        for column in matrix.secondaries:
            tgroup += nodes.colspec(colwidth=1)

        # Add heading row.
        thead = nodes.thead()
        tgroup += thead
        row = nodes.row()
        thead += row
        entry = nodes.entry()
        row += entry
        for secondary in matrix.secondaries:
            entry = nodes.entry()
            row += entry
            container = nodes.container()
            entry += container
            inline = nodes.inline()
            container += inline
            paragraph = nodes.paragraph()
            inline += paragraph
            paragraph += secondary.make_reference_node(app.builder, docname)

        # Add table body.
        tbody = nodes.tbody()
        tgroup += tbody
        for primary in matrix.primaries:
            row = nodes.row()
            tbody += row
            entry = nodes.entry()
            row += entry
            paragraph = nodes.paragraph()
            entry += paragraph
            paragraph += primary.make_reference_node(app.builder, docname)

            for is_related in matrix.get_boolean_row(primary):
                entry = nodes.entry()
                row += entry
                if is_related:
                    checkmark = traceable_checkmark()
                    entry += checkmark
                    checkmark += nodes.inline(u"\u2714", u"\u2714")
                else:
                    continue

        container = traceable_matrix_crosstable()
        container += table
        container["traceables-matrix"] = matrix
#        backward = matrix.backward_relationship.capitalize()
#        forward = matrix.forward_relationship.capitalize()
#        container["relationships"] = (forward, backward)
#        container["boolean_matrix"] = 0#boolean_matrix
#        container["secondaries"] = matrix.secondaries
        return container
def description_table(descriptions, widths, headers):
    # generate table-root
    tgroup = nodes.tgroup(cols=len(widths))
    for width in widths:
        tgroup += nodes.colspec(colwidth=width)
    table = nodes.table()
    table += tgroup

    # generate table-header
    thead = nodes.thead()
    row = nodes.row()
    for header in headers:
        entry = nodes.entry()
        entry += nodes.paragraph(text=header)
        row += entry
    thead += row
    tgroup += thead

    # generate table-body
    tbody = nodes.tbody()
    for desc in descriptions:
        row = nodes.row()
        for col in desc:
            entry = nodes.entry()
            if not isinstance(col, basestring):
                col = str(col)
            paragraph = nodes.paragraph()
            paragraph += nodes.Text(col)
            entry += paragraph
            row += entry
        tbody += row
    tgroup += tbody

    return table
Beispiel #3
0
    def _description_table(self, descriptions, widths, headers):
        # generate table-root
        tgroup = nodes.tgroup(cols=len(widths))
        for width in widths:
            tgroup += nodes.colspec(colwidth=width)
        table = nodes.table()
        table += tgroup

        # generate table-header
        thead = nodes.thead()
        row = nodes.row()
        for header in headers:
            entry = nodes.entry()
            entry += nodes.paragraph(text=header)
            row += entry
        thead += row
        tgroup += thead

        # generate table-body
        tbody = nodes.tbody()
        for desc in descriptions:
            row = nodes.row()
            for attr in desc:
                entry = nodes.entry()
                if not isinstance(attr, string_types):
                    attr = str(attr)
                self.state.nested_parse(ViewList([attr], source=attr),
                                        0, entry)
                row += entry
            tbody += row
        tgroup += tbody

        return table
Beispiel #4
0
def gen_table(columns, data):
        table = nodes.table()
        tgroup = nodes.tgroup(cols=len(columns))
        table += tgroup
        for column in columns:
            tgroup += nodes.colspec(colwidth=1)
        thead = nodes.thead()
        tgroup += thead
        headrow = nodes.row()
        for column in columns:
            entry = nodes.entry()
            para = nodes.paragraph()
            entry += para
            header = column.header()
            para += nodes.Text(header, header)
            headrow += entry
        thead += headrow
        tbody = nodes.tbody()
        tgroup += tbody
        for obj in data:
            row = nodes.row()
            for column in columns:
                entry = nodes.entry()
                para = nodes.paragraph()
                entry += para
                para += column.data(obj)
                row += entry
            tbody += row
        return [table]
Beispiel #5
0
def envy_resolve(app, doctree, fromdocname):
    objects = app.env.domaindata['envy']['objects']

    # add uplink info
    for holder in doctree.traverse(uplink_placeholder):
        obj = objects[holder.name]
        links = []
        for sp, pos, name, variants in obj.uplinks:
            signode = addnodes.desc_signature('', '')
            signode['first'] = False
            signode += make_refnode(app.builder, fromdocname, sp.docname, sp.iname + '-' + sp.name, addnodes.desc_addname(sp.name, sp.name), sp.name)
            text = ' {}: {}'.format(pos, name)
            signode += addnodes.desc_name(text, text)
            if variants is not None:
                text = ' [{}]'.format(variants)
                signode += addnodes.desc_annotation(text, text)
            links.append(signode)
        holder.replace_self(links)

    # add subnode list
    for holder in doctree.traverse(sub_placeholder):
        obj = objects[holder.name]
        add_variant = False
        for pos, name, child, variants in obj.subs:
            if variants is not None:
                add_variant = True
        table = nodes.table()
        headers = [(1, 'Address'), (1, 'Name'), (10, 'Description')]
        if add_variant:
            headers.insert(1, (1, 'Variants'))
        tgroup = nodes.tgroup(cols=len(headers))
        table += tgroup
        for colwidth, header in headers:
            tgroup += nodes.colspec(colwidth=colwidth)
        thead = nodes.thead()
        tgroup += thead
        headrow = nodes.row()
        for colwidth, header in headers:
            entry = nodes.entry()
            para = nodes.paragraph()
            entry += para
            para += nodes.Text(header, header)
            headrow += entry
        thead += headrow
        tbody = nodes.tbody()
        tgroup += tbody
        for pos, name, child, variants in obj.subs:
            row = nodes.row()
            row += wrap_text_entry(pos)
            if add_variant:
                row += wrap_text_entry('all' if variants is None else variants)
            row += wrap_text_entry(name)
            entry = nodes.entry()
            para = nodes.paragraph()
            entry += para
            para += make_refnode(app.builder, fromdocname, child.docname, child.iname + '-' + child.name, nodes.Text(child.brief, child.brief), obj.brief)
            row += entry
            tbody += row
        holder.replace_self([table])
    def create_list_table(self, matrix, options, docname):
        table = nodes.table()
        tgroup = nodes.tgroup(cols=2, colwidths="auto")
        table += tgroup

        # Add column specifications.
        tgroup += nodes.colspec(colwidth=50)
        tgroup += nodes.colspec(colwidth=50)

        # Add heading row.
        thead = nodes.thead()
        tgroup += thead
        row = nodes.row()
        thead += row
        entry = nodes.entry()
        row += entry
        backward_relationship = matrix.backward_relationship.capitalize()
        entry += nodes.paragraph(backward_relationship,
                                 backward_relationship)
        entry = nodes.entry()
        row += entry
        forward_relationship = matrix.forward_relationship.capitalize()
        entry += nodes.paragraph(forward_relationship,
                                 forward_relationship)

        # Add table body.
        tbody = nodes.tbody()
        tgroup += tbody
        for traceable in matrix.primaries:
            relatives = matrix.get_relatives(traceable)

            # Create first row with a first column.
            row = nodes.row()
            entry = nodes.entry(morerows=len(relatives) - 1)
            row += entry
            paragraph = nodes.paragraph()
            entry += paragraph
            paragraph += traceable.make_reference_node(
                self.app.builder, docname)

            for relative in relatives:
                if not row:
                    # Create subsequent rows without a first column.
                    row = nodes.row()
                tbody += row

                entry = nodes.entry()
                row += entry
                paragraph = nodes.paragraph()
                entry += paragraph
                paragraph += relative.make_reference_node(
                    self.app.builder, docname)

                row = None

        return table
Beispiel #7
0
    def format(self, app, docname, node, traceables, options):
        additional_attributes = options.get("attributes") or []
        columns = ["tag", "title"] + additional_attributes

        table = nodes.table()
        table["classes"].append("traceables-listtable")
        tgroup = nodes.tgroup(cols=len(columns), colwidths="auto")
        table += tgroup

        # Add column specifications.
        for attribute_name in columns:
            tgroup += nodes.colspec(colwidth=1)

        # Add heading row.
        thead = nodes.thead()
        tgroup += thead
        row = nodes.row()
        thead += row
        for attribute_name in columns:
            entry = nodes.entry()
            row += entry
            container = nodes.container()
            entry += container
            text = attribute_name.capitalize()
            inline = nodes.inline(text, text)
            container += inline

        # Add table body.
        tbody = nodes.tbody()
        tgroup += tbody
        for traceable in traceables:
            row = nodes.row()
            tbody += row

            for attribute_name in columns:
                entry = nodes.entry()
                row += entry
                if attribute_name == "tag":
                    inline = nodes.inline()
                    inline += traceable.make_reference_node(
                        app.builder, docname)
                elif attribute_name == "title":
                    text = traceable.title if traceable.has_title else ""
                    inline = nodes.inline(text, text)
                else:
                    text = traceable.attributes.get(attribute_name, "")
                    inline = nodes.inline(text, text)
                entry += inline

        return table
Beispiel #8
0
def process_indigo_option_nodes(app, doctree, fromdocname):
    env = app.builder.env

    for node in doctree.traverse(optionslist):
        content = []

        tbl = nodes.table()
        tgroup = nodes.tgroup(cols=4)
        tbl += tgroup

        tgroup += nodes.colspec(colwidth=35)
        tgroup += nodes.colspec(colwidth=9)
        tgroup += nodes.colspec(colwidth=9)
        tgroup += nodes.colspec(colwidth=73)

        thead = nodes.thead()
        tgroup += thead
        row = nodes.row()
        thead += row
        row += createRowEntryText('Name')
        row += createRowEntryText('Type')
        row += createRowEntryText('Default')
        row += createRowEntryText('Short description')

        tbody = nodes.tbody()
        tgroup += tbody

        content.append(tbl)

        sorted_options = sorted(env.indigo_options, key=lambda o:o['name'])

        for opt_info in sorted_options:
            row = nodes.row()
            tbody += row

            # Create a reference
            newnode = nodes.reference('', '')
            innernode = nodes.Text(opt_info['name'], opt_info['name'])
            newnode['refdocname'] = opt_info['docname']
            newnode['refuri'] = app.builder.get_relative_uri(
                fromdocname, opt_info['docname'])
            newnode['refuri'] += '#' + normalize_name(opt_info['name'])
            newnode.append(innernode)

            row += createRowEntry(newnode)
            row += createRowEntryText(opt_info['type'])
            row += createRowEntryText(opt_info['default'])
            row += createRowEntryText(opt_info['short'])

        node.replace_self(content)
    def _build_markup(self, notifications):
        content = []
        cols = ['Notification class', 'Payload class', 'Sample file link']
        table = nodes.table()
        content.append(table)
        group = nodes.tgroup(cols=len(cols))
        table.append(group)

        head = nodes.thead()
        group.append(head)

        for i in range(len(cols)):
            group.append(nodes.colspec(colwidth=1))

        body = nodes.tbody()
        group.append(body)

        # fill the table header
        row = nodes.row()
        body.append(row)
        for col_name in cols:
            col = nodes.entry()
            row.append(col)
            text = nodes.strong(text=col_name)
            col.append(text)

        # fill the table content, one notification per row
        for name, payload, sample in notifications:
            row = nodes.row()
            body.append(row)
            col = nodes.entry()
            row.append(col)
            text = nodes.literal(text=name)
            col.append(text)

            col = nodes.entry()
            row.append(col)
            text = nodes.literal(text=payload)
            col.append(text)

            col = nodes.entry()
            row.append(col)
            ref = nodes.reference(refuri=self.LINK_PREFIX +
                                  self.SAMPLE_ROOT + sample)
            txt = nodes.inline()
            col.append(txt)
            txt.append(ref)
            ref.append(nodes.literal(text=sample))

        return content
Beispiel #10
0
    def _build_grade_listing(self, matrix, content):

        summarytitle = nodes.subtitle(text="Grades")
        content.append(nodes.raw(text="Grades", attributes={'tagname': 'h2'}))
        content.append(summarytitle)
        table = nodes.table()
        table.set_class("table")
        table.set_class("table-condensed")
        grades = matrix.grades

        tablegroup = nodes.tgroup(cols=2)
        summarybody = nodes.tbody()
        summaryhead = nodes.thead()

        for i in range(2):
            tablegroup.append(nodes.colspec(colwidth=1))
        tablegroup.append(summaryhead)
        tablegroup.append(summarybody)
        table.append(tablegroup)
        content.append(table)

        header = nodes.row()
        blank = nodes.entry()
        blank.append(nodes.strong(text="Grade"))
        header.append(blank)

        blank = nodes.entry()
        blank.append(nodes.strong(text="Description"))
        header.append(blank)

        summaryhead.append(header)

        for grade in grades:
            item = nodes.row()
            namecol = nodes.entry()
            class_name = "label-%s" % grade.css_class
            status_text = nodes.paragraph(text=grade.title)
            status_text.set_class(class_name)
            status_text.set_class("label")
            namecol.append(status_text)
            item.append(namecol)

            notescol = nodes.entry()
            notescol.append(nodes.paragraph(text=grade.notes))
            item.append(notescol)

            summarybody.append(item)

        return content
Beispiel #11
0
 def run(self):
     ncolumns = self.options.get('columns', 2)
     node = nodes.Element()
     node.document = self.state.document
     self.state.nested_parse(self.content, self.content_offset, node)
     if len(node.children) != 1 or not isinstance(node.children[0],
                                                  nodes.bullet_list):
         return [self.state.document.reporter.warning(
             '.. hlist content is not a list', line=self.lineno)]
     fulllist = node.children[0]
     # create a hlist node where the items are distributed
     npercol, nmore = divmod(len(fulllist), ncolumns)
     index = 0
     table = nodes.table()
     tg = nodes.tgroup()
     table += tg
     row = nodes.row()
     tbody = nodes.tbody()
     for column in range(ncolumns):
         endindex = index + (column < nmore and (npercol + 1) or npercol)
         colspec = nodes.colspec()
         colspec.attributes['stub'] = 0
         colspec.attributes['colwidth'] = 100. / ncolumns
         col = nodes.entry()
         col += nodes.bullet_list()
         col[0] += fulllist.children[index:endindex]
         index = endindex
         tg += colspec
         row += col
     tbody += row
     tg += tbody
     table['classes'].append('hlist')
     return [table]
    def build_table(self, table_data):
        table = nodes.table()
        tgroup = nodes.tgroup(cols=len(self.headers))
        table += tgroup

        tgroup.extend(
            nodes.colspec(colwidth=col_width, colname='c' + str(idx))
            for idx, col_width in enumerate(self.col_widths)
        )

        thead = nodes.thead()
        tgroup += thead

        row_node = nodes.row()
        thead += row_node
        row_node.extend(nodes.entry(h, nodes.paragraph(text=h))
                        for h in self.headers)

        tbody = nodes.tbody()
        tgroup += tbody

        rows, groups = self.get_rows(table_data)
        tbody.extend(rows)
        table.extend(groups)

        return table
Beispiel #13
0
    def create_table(self, data, num_headers=1):
        table_node = nodes.table()

        if len(data) > 0:
            tgroup_node = nodes.tgroup(cols=len(data[0]))
            table_node += tgroup_node

            col_width = 100 // len(data[0])
            for col_index in range(len(data[0])):
                colspec_node = nodes.colspec(colwidth=col_width)
                tgroup_node += colspec_node

            thead = nodes.thead()
            tgroup_node += thead
            tbody = nodes.tbody()
            tgroup_node += tbody
            for row_index, row in enumerate(data):
                row_node = nodes.row()
                for col_index, cell_item in enumerate(row):
                    row_node += self.create_cell(col_index, cell_item, row_index < num_headers)
                if row_index < num_headers:
                    thead += row_node
                else:
                    tbody += row_node

        return table_node
Beispiel #14
0
            def get_row(*column_texts):
                row = nodes.row('')
                for text in column_texts:
                    node = nodes.paragraph('', '', nodes.Text(text))
                    row += nodes.entry('', node)

                return row
 def build_table_from_list(self, table_data, num_cols, col_widths, header_rows, stub_columns):
     table = nodes.table()
     tgroup = nodes.tgroup(cols=len(col_widths))
     table += tgroup
     for col_width in col_widths:
         colspec = nodes.colspec(colwidth=col_width)
         if stub_columns:
             colspec.attributes['stub'] = 1
             stub_columns -= 1
         tgroup += colspec
     rows = []
     for row in table_data:
         row_node = nodes.row()
         for cell_index, cell in enumerate(row):
             entry = nodes.entry()
             entry += cell
             row_node += entry
             if self.bias == "left" and not cell_index:
                 remainder = num_cols - len(row)
                 if remainder:
                     entry["morecols"] = remainder
             if self.bias == "right" and cell_index == len(row) - 1:
                 remainder = num_cols - (cell_index + 1)
                 if remainder:
                     entry["morecols"] = remainder
         rows.append(row_node)
     if header_rows:
         thead = nodes.thead()
         thead.extend(rows[:header_rows])
         tgroup += thead
     tbody = nodes.tbody()
     tbody.extend(rows[header_rows:])
     tgroup += tbody
     return table
Beispiel #16
0
 def build_table_from_list(self, table_data, col_widths, header_rows, stub_columns):
     table = nodes.table()
     if self.widths == 'auto':
         table['classes'] += ['colwidths-auto']
     elif self.widths: # "grid" or list of integers
         table['classes'] += ['colwidths-given']
     tgroup = nodes.tgroup(cols=len(col_widths))
     table += tgroup
     for col_width in col_widths:
         colspec = nodes.colspec()
         if col_width is not None:
             colspec.attributes['colwidth'] = col_width
         if stub_columns:
             colspec.attributes['stub'] = 1
             stub_columns -= 1
         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)
     if header_rows:
         thead = nodes.thead()
         thead.extend(rows[:header_rows])
         tgroup += thead
     tbody = nodes.tbody()
     tbody.extend(rows[header_rows:])
     tgroup += tbody
     return table
    def _generate_rows(self, sensors):

        vendor_name = None
        for s in sensors:
            # only generate one row for each vendor name that serves as a group heading
            if 'vendor_name' in s and vendor_name != s['vendor_name']:
                vendor_name = s['vendor_name']

                strong = nodes.strong(text=vendor_name)
                para = nodes.paragraph()
                para += strong
                entry = nodes.entry(morecols=5)
                entry += para
                row = nodes.row()
                row += entry
                yield row

            # then generate one row for each sensor
            yield self._row([
                self._link(s.get('vendor_website', None), s.get('vendor_part_number', '')),
                ':ref:`{} <{}>`'.format(s.get('vendor_part_name', s.get('vendor_part_number', '')),
                                         s['url_name']),
                '``{}``'.format(s['name']),
                self._pretty_sensor_type(s['sensor_type']),
                self._auto_detect(s['name'], s['sensor_type']),
            ])
Beispiel #18
0
 def run(self):
   if ValueTableDirective.values[0].description is None:
     list = nodes.bullet_list()
     for v in ValueTableDirective.values:
       item = nodes.list_item()
       item += nodes.literal(v.value, v.value)
       list += item
     return [list]
   table = nodes.table()
   tgroup = nodes.tgroup()
   tbody = nodes.tbody()
   for v in ValueTableDirective.values:
     row = nodes.row()
     entry = nodes.entry()
     entry += nodes.literal(v.value, v.value)
     row += entry
     entry = nodes.entry()
     entry += nodes.paragraph(text=v.description)
     row += entry
     tbody += row
   tgroup += nodes.colspec(colwidth=10)
   tgroup += nodes.colspec(colwidth=90)
   tgroup += tbody
   table += tgroup
   return [table]
Beispiel #19
0
def build_toc(descinfo, env):
    """Return a desc table of contents node tree"""
    
    separator = EMDASH
    child_ids = descinfo['children']
    if not child_ids:
        return None
    max_fullname_len = 0
    max_summary_len = 0
    rows = []
    for fullname, refid, summary in ichild_ids(child_ids, env):
        max_fullname_len = max(max_fullname_len, len(fullname))
        max_summary_len = max(max_summary_len, len(summary))
        reference_node = toc_ref(fullname, refid)
        ref_entry_node = entry('', paragraph('', '', reference_node))
        sep_entry_node = entry('', paragraph('', separator))
        sum_entry_node = entry('', paragraph('', summary))
        row_node = row('', ref_entry_node, sep_entry_node, sum_entry_node)
        rows.append(row_node)
    col0_len = max_fullname_len + 2   # add error margin
    col1_len = len(separator)         # no padding
    col2_len = max_summary_len + 10   # add error margin
    tbody_node = tbody('', *rows)
    col0_colspec_node = colspec(colwidth=col0_len)
    col1_colspec_node = colspec(colwidth=col1_len)
    col2_colspec_node = colspec(colwidth=col2_len)
    tgroup_node = tgroup('',
                         col0_colspec_node,
                         col1_colspec_node,
                         col2_colspec_node,
                         tbody_node,
                         cols=3)
    return TocTable('', tgroup_node, classes=['toc'])
Beispiel #20
0
 def build_table_from_list(self, table_data, col_widths, header_rows, stub_columns):
     table = nodes.table()
     tgroup = nodes.tgroup(cols=len(col_widths))
     table += tgroup
     for col_width in col_widths:
         colspec = nodes.colspec(colwidth=col_width)
         if stub_columns:
             colspec.attributes['stub'] = 1
             stub_columns -= 1
         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)
     if header_rows:
         thead = nodes.thead()
         thead.extend(rows[:header_rows])
         tgroup += thead
     tbody = nodes.tbody()
     tbody.extend(rows[header_rows:])
     tgroup += tbody
     return table
 def create_table_row(self, row_cells):
     row = nodes.row()
     for cell in row_cells:
         entry = nodes.entry()
         row += entry
         entry += cell
     return row
Beispiel #22
0
    def build_table(self):
        table = nodes.table()
        tgroup = nodes.tgroup(cols=len(self.headers))
        table += tgroup

        # TODO(sdague): it would be really nice to figure out how not
        # to have this stanza, it kind of messes up all of the table
        # formatting because it doesn't let tables just be the right
        # size.
        tgroup.extend(
             nodes.colspec(colwidth=col_width, colname='c' + str(idx))
             for idx, col_width in enumerate(self.col_widths)
        )

        thead = nodes.thead()
        tgroup += thead

        row_node = nodes.row()
        thead += row_node
        row_node.extend(nodes.entry(h, nodes.paragraph(text=h))
                        for h in self.headers)

        tbody = nodes.tbody()
        tgroup += tbody

        rows, groups = self.collect_rows()
        tbody.extend(rows)
        table.extend(groups)

        return table
Beispiel #23
0
 def collect_rows(self):
     rows = []
     groups = []
     try:
         # self.app.info("Parsed content is: %s" % self.yaml)
         for key, values in self.yaml:
             min_version = values.get('min_version', '')
             desc = values.get('description', '')
             classes = []
             if min_version:
                 desc += ("\n\n**New in version %s**\n" % min_version)
                 min_ver_css_name = ("rp_min_ver_" +
                                     str(min_version).replace('.', '_'))
                 classes.append(min_ver_css_name)
             trow = nodes.row(classes=classes)
             name = key
             if values.get('required', False) is False:
                 name += " (Optional)"
             trow += self.add_col(name)
             trow += self.add_col(values.get('in'))
             trow += self.add_col(values.get('type'))
             trow += self.add_col(desc)
             rows.append(trow)
     except AttributeError as exc:
         if 'key' in locals():
             self.app.warn("Failure on key: %s, values: %s. %s" %
                           (key, values, exc))
         else:
             rows.append(self.show_no_yaml_error())
     return rows, groups
Beispiel #24
0
 def show_no_yaml_error(self):
     trow = nodes.row(classes=["no_yaml"])
     trow += self.add_col("No yaml found %s" % self.yaml_file)
     trow += self.add_col("")
     trow += self.add_col("")
     trow += self.add_col("")
     return trow
Beispiel #25
0
 def append_row(*column_texts):
     row = nodes.row('')
     for text in column_texts:
         node = nodes.paragraph('')
         vl = ViewList()
         vl.append(text, '<autosummary>')
         state.nested_parse(vl, 0, node)
         row.append(nodes.entry('', node))
     body.append(row)
Beispiel #26
0
def build_table_row(*vals):
    rv = nodes.row('')
    for val in vals:
        if isinstance(val, nodes.Node):
            node = val
        else:
            node = nodes.paragraph(val, val)
        rv.append(nodes.entry(node, node))
    return rv
Beispiel #27
0
    def create_table_row(self, row_cells):
        row = nodes.row()

        for cell in row_cells:
            entry = nodes.entry()
            row += entry
            entry += nodes.paragraph(text=cell.strip())

        return row
Beispiel #28
0
 def get_rows(self, table_data):
     rows = []
     groups = []
     trow = nodes.row()
     entry = nodes.entry()
     para = nodes.paragraph(text=unicode(table_data))
     entry += para
     trow += entry
     rows.append(trow)
     return rows, groups
Beispiel #29
0
 def _make_enum_documentation(self, obj):
     def get_entry(node):
         para = addnodes.compact_paragraph()
         para += node
         entry = nodes.entry()
         entry += para
         return entry
     desc = addnodes.desc_signature()
     desc['ids'].append(obj.get_id())
     first = False
     desc += nodes.emphasis(text=u'enum')
     desc += nodes.Text(u' ')
     desc += addnodes.desc_name(text=obj.get_name())
     desc.attributes['first'] = True
     content = addnodes.desc_content()
     if obj.brief():
         para = nodes.paragraph()
         para += nodes.emphasis(text='Brief: ')
         para += nodes.Text(' '.join(obj.brief()))
         content += para
     table, body = nodes.table(), nodes.tbody()
     tgroup = nodes.tgroup(cols=3)
     thead = nodes.thead()
     for it in [20, 10, 70]:
         tgroup += nodes.colspec(colwidth=it)
     tgroup += thead
     tgroup += body
     table += tgroup
     head_row = nodes.row()
     for it in ['Name', 'Value', 'Brief']:
         head_row += get_entry(nodes.Text(it))
     thead += head_row
     for val in sorted(obj.values):
         row = nodes.row()
         row += get_entry(nodes.literal(text=val.name))
         tmp = [val.value if val.value is not None else '',
         ' '.join(val.brief())]
         for it in tmp:
             row += get_entry(nodes.Text(it))
         body += row
     content += table
     return (desc, content)
Beispiel #30
0
    def _build_grade_listing(self, matrix, content):

        summarytitle = nodes.title(text="Grades")
        content.append(summarytitle)
        table = nodes.table()
        grades = matrix.grades

        tablegroup = nodes.tgroup(cols=2)
        summarybody = nodes.tbody()
        summaryhead = nodes.thead()

        for i in range(2):
            tablegroup.append(nodes.colspec(colwidth=1))
        tablegroup.append(summaryhead)
        tablegroup.append(summarybody)
        table.append(tablegroup)
        content.append(table)

        header = nodes.row()
        blank = nodes.entry()
        blank.append(nodes.strong(text="Grade"))
        header.append(blank)

        blank = nodes.entry()
        blank.append(nodes.strong(text="Description"))
        header.append(blank)

        summaryhead.append(header)

        for grade in grades:
            item = nodes.row()
            namecol = nodes.entry()
            namecol.append(nodes.paragraph(text=grade.title))
            item.append(namecol)

            notescol = nodes.entry()
            notescol.append(nodes.paragraph(text=grade.notes))
            item.append(notescol)

            summarybody.append(item)

        return content