当前位置: 首页>>代码示例>>Python>>正文


Python nodes.tbody方法代码示例

本文整理汇总了Python中docutils.nodes.tbody方法的典型用法代码示例。如果您正苦于以下问题:Python nodes.tbody方法的具体用法?Python nodes.tbody怎么用?Python nodes.tbody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在docutils.nodes的用法示例。


在下文中一共展示了nodes.tbody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: autosummary_table_visit_html

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import tbody [as 别名]
def autosummary_table_visit_html(self, node):
    """Make the first column of the table non-breaking."""
    try:
        tbody = node[0][0][-1]
        for row in tbody:
            col1_entry = row[0]
            par = col1_entry[0]
            for j, subnode in enumerate(list(par)):
                if isinstance(subnode, nodes.Text):
                    new_text = text_type(subnode.astext())
                    new_text = new_text.replace(u" ", u"\u00a0")
                    par[j] = nodes.Text(new_text)
    except IndexError:
        pass


# -- autodoc integration ------------------------------------------------------- 
开发者ID:pyGSTio,项目名称:pyGSTi,代码行数:19,代码来源:autosummary__init__.py

示例2: build_table

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import tbody [as 别名]
def build_table(self, tabledata, tableline, stub_columns=0, widths=None):
        colwidths, headrows, bodyrows = tabledata
        table = nodes.table()
        if widths:
            table['classes'] += ['colwidths-%s' % widths]
        tgroup = nodes.tgroup(cols=len(colwidths))
        table += tgroup
        for colwidth in colwidths:
            colspec = nodes.colspec(colwidth=colwidth)
            if stub_columns:
                colspec.attributes['stub'] = 1
                stub_columns -= 1
            tgroup += colspec
        if headrows:
            thead = nodes.thead()
            tgroup += thead
            for row in headrows:
                thead += self.build_table_row(row, tableline)
        tbody = nodes.tbody()
        tgroup += tbody
        for row in bodyrows:
            tbody += self.build_table_row(row, tableline)
        return table 
开发者ID:skarlekar,项目名称:faces,代码行数:25,代码来源:states.py

示例3: build_table

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import tbody [as 别名]
def build_table(self, tabledata, tableline, stub_columns=0, widths=None):
        colwidths, headrows, bodyrows = tabledata
        table = nodes.table()
        if widths == 'auto':
            table['classes'] += ['colwidths-auto']
        elif widths: # "grid" or list of integers
            table['classes'] += ['colwidths-given']
        tgroup = nodes.tgroup(cols=len(colwidths))
        table += tgroup
        for colwidth in colwidths:
            colspec = nodes.colspec(colwidth=colwidth)
            if stub_columns:
                colspec.attributes['stub'] = 1
                stub_columns -= 1
            tgroup += colspec
        if headrows:
            thead = nodes.thead()
            tgroup += thead
            for row in headrows:
                thead += self.build_table_row(row, tableline)
        tbody = nodes.tbody()
        tgroup += tbody
        for row in bodyrows:
            tbody += self.build_table_row(row, tableline)
        return table 
开发者ID:QData,项目名称:deepWordBug,代码行数:27,代码来源:states.py

示例4: prepare_table_header

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import tbody [as 别名]
def prepare_table_header(titles, widths):
    """Build docutil empty table """
    ncols = len(titles)
    assert len(widths) == ncols

    tgroup = nodes.tgroup(cols=ncols)
    for width in widths:
        tgroup += nodes.colspec(colwidth=width)
    header = nodes.row()
    for title in titles:
        header += nodes.entry("", nodes.paragraph(text=title))
    tgroup += nodes.thead("", header)

    tbody = nodes.tbody()
    tgroup += tbody

    return nodes.table("", tgroup), tbody 
开发者ID:altair-viz,项目名称:altair,代码行数:19,代码来源:schematable.py

示例5: create_table

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import tbody [as 别名]
def create_table(self, head, body, colspec=None):
        table = nodes.table()
        tgroup = nodes.tgroup()
        table.append(tgroup)

        # Create a colspec for each column
        if colspec is None:
            colspec = [1 for n in range(len(head))]

        for width in colspec:
            tgroup.append(nodes.colspec(colwidth=width))

        # Create the table headers
        thead = nodes.thead()
        thead.append(self.row(head))
        tgroup.append(thead)

        # Create the table body
        tbody = nodes.tbody()
        tbody.extend([self.row(r) for r in body])
        tgroup.append(tbody)

        return table 
开发者ID:unaguil,项目名称:sphinx-swaggerdoc,代码行数:25,代码来源:swaggerv2_doc.py

示例6: autosummary_table_visit_html

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import tbody [as 别名]
def autosummary_table_visit_html(self, node):
    """Make the first column of the table non-breaking."""
    try:
        tbody = node[0][0][-1]
        for row in tbody:
            col1_entry = row[0]
            par = col1_entry[0]
            for j, subnode in enumerate(list(par)):
                if isinstance(subnode, nodes.Text):
                    new_text = str(subnode.astext())
                    new_text = new_text.replace(u" ", u"\u00a0")
                    par[j] = nodes.Text(new_text)
    except IndexError:
        pass


# -- autodoc integration ------------------------------------------------------- 
开发者ID:nguy,项目名称:artview,代码行数:19,代码来源:__init__.py

示例7: __init__

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import tbody [as 别名]
def __init__(
        self,
        state,
        state_machine,
        table_classes: typing.List[str]=['colwidths-auto'],
    ):
        self.table_node = nodes.table('', classes=table_classes)

        # state and state_machine are required by the _create_row method taken from sphinx
        self.state_machine = state_machine
        self.state = state

        self.head = nodes.thead('')
        self.body = nodes.tbody('')
        self.groups = None

    # taken and adjusted from sphinx.ext.Autosummary.get_table() 
开发者ID:gardener,项目名称:cc-utils,代码行数:19,代码来源:sphinxutil.py

示例8: models_table

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import tbody [as 别名]
def models_table(self, species):
        table = nodes.table()
        tgroup = nodes.tgroup(cols=2)
        for _ in range(2):
            colspec = nodes.colspec(colwidth=1)
            tgroup.append(colspec)
        table += tgroup

        thead = nodes.thead()
        tgroup += thead
        row = nodes.row()
        entry = nodes.entry()
        entry += nodes.paragraph(text="ID")
        row += entry
        entry = nodes.entry()
        entry += nodes.paragraph(text="Description")
        row += entry

        thead.append(row)

        rows = []
        for model in species.demographic_models:
            row = nodes.row()
            rows.append(row)

            mid = self.get_demographic_model_id(species, model)
            entry = nodes.entry()
            para = nodes.paragraph()
            entry += para
            para += nodes.reference(internal=True, refid=mid, text=model.id)
            row += entry

            entry = nodes.entry()
            entry += nodes.paragraph(text=model.description)
            row += entry

        tbody = nodes.tbody()
        tbody.extend(rows)
        tgroup += tbody

        return table 
开发者ID:popsim-consortium,项目名称:stdpopsim,代码行数:43,代码来源:speciescatalog.py

示例9: create_summary_table

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import tbody [as 别名]
def create_summary_table(self, config, context, options):
        default_column = self.builder.config.cfg_options_default_in_summary_table
        table_spec = addnodes.tabular_col_spec()
        table = nodes.table("", classes=["longtable"])
        if default_column:
            table_spec['spec'] = r'\X{1}{4}\X{1}{4}\X{2}{4}'
            group = nodes.tgroup('', cols=3)
            group.append(nodes.colspec('', colwidth=20))
            group.append(nodes.colspec('', colwidth=20))
            group.append(nodes.colspec('', colwidth=60))
        else:
            table_spec['spec'] = r'\X{1}{4}\X{2}{4}'
            group = nodes.tgroup('', cols=2)
            group.append(nodes.colspec('', colwidth=25))
            group.append(nodes.colspec('', colwidth=75))
        table.append(group)
        if self.builder.config.cfg_options_table_add_header:
            header = nodes.thead('')
            group.append(header)
            row = nodes.row()
            row += nodes.entry("", nodes.Text("option"))
            if default_column:
                row += nodes.entry("", nodes.Text("default"))
            row += nodes.entry("", nodes.Text("summary"))
            header.append(row)
        body = nodes.tbody('')
        group.append(body)
        for opt in options:
            body += self.create_option_reference_table_row(opt, config, context)
        return [table_spec, table] 
开发者ID:tenpy,项目名称:tenpy,代码行数:32,代码来源:sphinx_cfg_options.py

示例10: build_table_from_list

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import tbody [as 别名]
def build_table_from_list(self, table_data, widths, col_widths, header_rows,
                              stub_columns):
        table = nodes.table()
        if widths:
            table['classes'] += ['colwidths-%s' % widths]
        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 
开发者ID:skarlekar,项目名称:faces,代码行数:33,代码来源:tables.py

示例11: run

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import tbody [as 别名]
def run(self):
        name = self.options.get("name", "Details and conventions")
        rst = DETAILS_TEMPLATE.format(title=name, content="\n".join(self.content))
        string_list = StringList(rst.split('\n'))
        node = nodes.tbody()
        self.state.nested_parse(string_list, self.content_offset, node)
        return [node] 
开发者ID:XanaduAI,项目名称:strawberryfields,代码行数:9,代码来源:custom_directives.py

示例12: build_table_from_list

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import tbody [as 别名]
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 
开发者ID:QData,项目名称:deepWordBug,代码行数:34,代码来源:tables.py

示例13: build_schema_tabel

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import tbody [as 别名]
def build_schema_tabel(items):
    """Return schema table of items (iterator of prop, schema.item, requred)"""
    table, tbody = prepare_table_header(
        ["Property", "Type", "Description"], [10, 20, 50]
    )
    for item in items:
        tbody += build_row(item)

    return table 
开发者ID:altair-viz,项目名称:altair,代码行数:11,代码来源:schematable.py

示例14: test_desctable_option_with_numbered

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import tbody [as 别名]
def test_desctable_option_with_numbered(self):
        directives.setup(format='SVG', outputdir=self.tmpdir)
        text = (".. rackdiag::\n"
                "   :desctable:\n"
                "\n"
                "   1: server [numbered = 2]\n"
                "   2: database [numbered = 1]\n")
        doctree = publish_doctree(text)
        self.assertEqual(2, len(doctree))
        self.assertEqual(nodes.image, type(doctree[0]))
        self.assertEqual(nodes.table, type(doctree[1]))

        # tgroup
        self.assertEqual(5, len(doctree[1][0]))
        self.assertEqual(nodes.colspec, type(doctree[1][0][0]))
        self.assertEqual(nodes.colspec, type(doctree[1][0][1]))
        self.assertEqual(nodes.colspec, type(doctree[1][0][2]))
        self.assertEqual(nodes.thead, type(doctree[1][0][3]))
        self.assertEqual(nodes.tbody, type(doctree[1][0][4]))

        # colspec
        self.assertEqual(25, doctree[1][0][0]['colwidth'])
        self.assertEqual(50, doctree[1][0][1]['colwidth'])
        self.assertEqual(50, doctree[1][0][2]['colwidth'])

        # thead
        thead = doctree[1][0][3]
        self.assertEqual(3, len(thead[0]))
        self.assertEqual('No', thead[0][0][0][0])
        self.assertEqual('Name', thead[0][1][0][0])
        self.assertEqual('Height', thead[0][2][0][0])

        # tbody
        tbody = doctree[1][0][4]
        self.assertEqual(2, len(tbody))
        self.assertEqual('1', tbody[0][0][0][0])
        self.assertEqual('server', tbody[0][1][0][0])
        self.assertEqual('1U', tbody[0][2][0][0])
        self.assertEqual('2', tbody[1][0][0][0])
        self.assertEqual('database', tbody[1][1][0][0])
        self.assertEqual('1U', tbody[1][2][0][0]) 
开发者ID:blockdiag,项目名称:nwdiag,代码行数:43,代码来源:test_rst_directives.py

示例15: test_desctable_option

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import tbody [as 别名]
def test_desctable_option(self):
        directives.setup(format='SVG', outputdir=self.tmpdir)
        text = (".. packetdiag::\n"
                "   :desctable:\n"
                "\n"
                "   1: server [description = foo]\n"
                "   2: database [description = bar]\n")
        doctree = publish_doctree(text)
        self.assertEqual(2, len(doctree))
        self.assertEqual(nodes.image, type(doctree[0]))
        self.assertEqual(nodes.table, type(doctree[1]))

        # tgroup
        self.assertEqual(nodes.colspec, type(doctree[1][0][0]))
        self.assertEqual(nodes.colspec, type(doctree[1][0][1]))
        self.assertEqual(nodes.colspec, type(doctree[1][0][2]))
        self.assertEqual(nodes.thead, type(doctree[1][0][3]))
        self.assertEqual(nodes.tbody, type(doctree[1][0][4]))

        # colspec
        self.assertEqual(25, doctree[1][0][0]['colwidth'])
        self.assertEqual(50, doctree[1][0][1]['colwidth'])
        self.assertEqual(50, doctree[1][0][2]['colwidth'])

        # thead
        thead = doctree[1][0][3]
        self.assertEqual(3, len(thead[0]))
        self.assertEqual('Seq', thead[0][0][0][0])
        self.assertEqual('Name', thead[0][1][0][0])
        self.assertEqual('Description', thead[0][2][0][0])

        # tbody
        tbody = doctree[1][0][4]
        self.assertEqual(2, len(tbody))
        self.assertEqual('1', tbody[0][0][0][0])
        self.assertEqual('server', tbody[0][1][0][0])
        self.assertEqual('foo', tbody[0][2][0][0])
        self.assertEqual('2', tbody[1][0][0][0])
        self.assertEqual('database', tbody[1][1][0][0])
        self.assertEqual('bar', tbody[1][2][0][0]) 
开发者ID:blockdiag,项目名称:nwdiag,代码行数:42,代码来源:test_rst_directives.py


注:本文中的docutils.nodes.tbody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。