def get_tablespec(self): table_spec = addnodes.tabular_col_spec() table_spec['spec'] = 'll' table = autosummary_table('') real_table = nodes.table('', classes=['longtable']) table.append(real_table) group = nodes.tgroup('', cols=2) real_table.append(group) group.append(nodes.colspec('', colwidth=10)) group.append(nodes.colspec('', colwidth=90)) body = nodes.tbody('') group.append(body) def append_row(*column_texts): row = nodes.row('') for text in column_texts: node = nodes.paragraph('') vl = ViewList() vl.append(text, '<autosummary>') self.state.nested_parse(vl, 0, node) try: if isinstance(node[0], nodes.paragraph): node = node[0] except IndexError: pass row.append(nodes.entry('', node)) body.append(row) return table, table_spec, append_row
def _get_table_spec(self): ncols = self.f2x_ncols() column_titles = self.f2x_get_title() table_spec = addnodes.tabular_col_spec() table_spec['spec'] = r'\X{1}{2}' * ncols table_wrap = autosummary_table('') table_layout = nodes.table('', classes=['longtable']) table_group = nodes.tgroup('', cols=ncols) table_body = nodes.tbody('') table_wrap.append(table_layout) table_layout.append(table_group) for width in self.f2x_get_width(): table_group.append(nodes.colspec('', colwidth=width)) if self.options.get('showheader', False) and column_titles is not None: table_head = nodes.thead('') table_group.append(table_head) self._append_row(table_head, column_titles) table_group.append(table_body) return table_spec, table_wrap, table_body
def get_table(self, items: List[Tuple[str, str, str, str]]) -> List[nodes.Node]: """ Generate a proper list of table nodes for autosummary:: directive. :param items: A a list produced by :meth:`~.get_items`. """ table_spec = addnodes.tabular_col_spec() # table_spec['spec'] = r'\Xx{1}{3}\Xx{2}{3}' # table_spec['spec'] = r'\Xx{3}{8}\Xx{5}{8}' # table_spec['spec'] = r'\Xx{7}{16}\Xx{9}{16}' widths = chain.from_iterable( getattr(self.state.document, "autosummary_widths", ((1, 2), (1, 2)))) table_spec["spec"] = r'\Xx{{{}}}{{{}}}\Xx{{{}}}{{{}}}'.format(*widths) table = autosummary_table('') real_table = nodes.table('', classes=["longtable"]) table.append(real_table) group = nodes.tgroup('', cols=2) real_table.append(group) group.append(nodes.colspec('', colwidth=10)) group.append(nodes.colspec('', colwidth=90)) body = nodes.tbody('') group.append(body) def append_row(*column_texts: str) -> None: row = nodes.row('') source, line = self.state_machine.get_source_and_line() for text in column_texts: node = nodes.paragraph('') vl = StringList() vl.append(text, "%s:%d:<autosummary>" % (source, line)) with switch_source_input(self.state, vl): self.state.nested_parse(vl, 0, node) try: if isinstance(node[0], nodes.paragraph): node = node[0] except IndexError: pass row.append(nodes.entry('', node)) body.append(row) for name, sig, summary, real_name in items: qualifier = "obj" if "nosignatures" not in self.options: col1 = ":{}:`{} <{}>`\\ {}".format( qualifier, name, real_name, rst.escape(sig).replace('(', "(")) else: col1 = f":{qualifier}:`{name} <{real_name}>`" col2 = summary append_row(col1, col2) return [table_spec, table]
def format_table(self, items): """Generate a proper list of table nodes for autosummary:: directive. *items* is a list produced by :meth:`get_items`. """ table_spec = addnodes.tabular_col_spec() table_spec["spec"] = r"\X{1}{2}\X{1}{2}" table = autosummary_table("") real_table = nodes.table("", classes=["longtable"]) table.append(real_table) group = nodes.tgroup("", cols=2) real_table.append(group) group.append(nodes.colspec("", colwidth=10)) group.append(nodes.colspec("", colwidth=90)) body = nodes.tbody("") group.append(body) def append_row(*column_texts: str) -> None: row = nodes.row("") source, line = self.state_machine.get_source_and_line() for text in column_texts: node = nodes.paragraph("") vl = StringList() vl.append(text, "%s:%d:<autosummary>" % (source, line)) with switch_source_input(self.state, vl): self.state.nested_parse(vl, 0, node) try: if isinstance(node[0], nodes.paragraph): node = node[0] except IndexError: pass row.append(nodes.entry("", node)) body.append(row) for prefix, name, sig, summary, real_name in items: qualifier = "any" # <== Only thing changed from autosummary version if "nosignatures" not in self.options: col1 = "%s:%s:`%s <%s>`\\ %s" % ( prefix, qualifier, name, real_name, rst.escape(sig), ) else: col1 = "%s:%s:`%s <%s>`" % (prefix, qualifier, name, real_name) col2 = summary append_row(col1, col2) return [table_spec, table]
def get_table(self, items: List[Tuple[str, str, str, str, str]]) -> List[Node]: """Generate a proper list of table nodes for autosummary:: directive. *items* is a list produced by :meth:`get_items`. """ table_spec = addnodes.tabular_col_spec() table_spec['spec'] = r'\X{1}{2}\X{1}{2}' table = autosummary_table('') real_table = nodes.table('', classes=['longtable']) table.append(real_table) group = nodes.tgroup('', cols=3) real_table.append(group) group.append(nodes.colspec('', colwidth=10)) group.append(nodes.colspec('', colwidth=70)) group.append(nodes.colspec('', colwidth=30)) body = nodes.tbody('') group.append(body) def append_row(*column_texts: str) -> None: row = nodes.row('', color="red") source, line = self.state_machine.get_source_and_line() for text in column_texts: node = nodes.paragraph('') vl = StringList() vl.append(text, '%s:%d:<autosummary>' % (source, line)) with switch_source_input(self.state, vl): self.state.nested_parse(vl, 0, node) try: if isinstance(node[0], nodes.paragraph): node = node[0] except IndexError: pass row.append(nodes.entry('', node)) body.append(row) # add table's title append_row("**API Name**", "**Description**", self.third_title) for name, sig, summary, real_name, env_sum in items: qualifier = 'obj' if 'nosignatures' not in self.options: col1 = ':%s:`%s <%s>`\\ %s' % (qualifier, name, real_name, rst.escape(sig)) else: col1 = ':%s:`%s <%s>`' % (qualifier, name, real_name) col2 = summary col3 = env_sum append_row(col1, col2, col3) return [table_spec, table]
def get_table(self): """docstring for get_table""" table_spec = addnodes.tabular_col_spec() table_spec['spec'] = 'll' table = autosummary_table('') real_table = nodes.table('', classes=['longtable']) table.append(real_table) group = nodes.tgroup('', cols=2) real_table.append(group) group.append(nodes.colspec('', colwidth=10)) group.append(nodes.colspec('', colwidth=90)) body = nodes.tbody('') group.append(body) return table_spec, table, body
def get_table(self, items): """Generate a proper list of table nodes for autosummary:: directive. *items* is a list produced by :meth:`get_items`. """ table_spec = addnodes.tabular_col_spec() table_spec['spec'] = 'LL' table = autosummary_table('') real_table = nodes.table('') if "title" in self.options: title_node = self.make_title(self.options["title"]) real_table.insert(0, title_node) table.append(real_table) group = nodes.tgroup('', cols=2) real_table.append(group) group.append(nodes.colspec('', colwidth=10)) group.append(nodes.colspec('', colwidth=90)) body = nodes.tbody('') group.append(body) def append_row(*column_texts): row = nodes.row('') for text in column_texts: node = nodes.paragraph('') vl = ViewList() vl.append(text, '<doxybridge-autosummary>') self.sphinx_directive.state.nested_parse(vl, 0, node) try: if isinstance(node[0], nodes.paragraph): node = node[0] except IndexError: pass row.append(nodes.entry('', node)) body.append(row) for name, sig, summary, real_name in items: qualifier = self.get_qualifier(name) if 'nosignatures' not in self.options: col1 = ':%s:`%s <%s>`\ %s' % (qualifier, name, real_name, sig) else: col1 = ':%s:`%s <%s>`' % (qualifier, name, real_name) col2 = summary append_row(col1, col2) return [table_spec, table]
def get_table(self, items): """ Subclass to get support for `hidesummary` as options to enable displaying the short summary in the table """ hidesummary = 'hidesummary' in self.options table_spec = addnodes.tabular_col_spec() table_spec['spec'] = 'p{0.5\linewidth}p{0.5\linewidth}' table = autosummary_table('') real_table = nodes.table('', classes=['longtable']) table.append(real_table) group = nodes.tgroup('', cols=2) real_table.append(group) group.append(nodes.colspec('', colwidth=10)) group.append(nodes.colspec('', colwidth=90)) body = nodes.tbody('') group.append(body) def append_row(*column_texts): row = nodes.row('') for text in column_texts: node = nodes.paragraph('') vl = ViewList() vl.append(text, '<autosummary>') self.state.nested_parse(vl, 0, node) try: if isinstance(node[0], nodes.paragraph): node = node[0] except IndexError: pass row.append(nodes.entry('', node)) body.append(row) for name, sig, summary, real_name in items: qualifier = 'obj' if 'nosignatures' not in self.options: col1 = ':%s:`%s <%s>`\ %s' % (qualifier, name, real_name, rst.escape(sig)) else: col1 = ':%s:`%s <%s>`' % (qualifier, name, real_name) col2 = summary if hidesummary: append_row(col1) else: append_row(col1, col2) return [table_spec, table]
def get_table(self, items: List[Tuple[str, str, str, str, str]]) -> List[Node]: """Generate a proper list of table nodes for autosummary:: directive. *items* is a list produced by :meth:`get_items`. """ has_config_type = any([item[-1] is not None for item in items]) if has_config_type: n_cols = 3 else: n_cols = 2 table_spec = addnodes.tabular_col_spec() table_spec["spec"] = r"\X{1}{2}\X{1}{2}" table = autosummary_table("") real_table = nodes.table("", classes=["longtable"]) table.append(real_table) group = nodes.tgroup("", cols=n_cols) real_table.append(group) group.append(nodes.colspec("", colwidth=10)) if has_config_type: group.append(nodes.colspec("", colwidth=10)) group.append(nodes.colspec("", colwidth=90)) head = nodes.thead("") cols = ["Class/method name", "type", "Summary"] if not has_config_type: del cols[1] row = nodes.row("") source, line = self.state_machine.get_source_and_line() for text in cols: node = nodes.paragraph("") vl = StringList() vl.append(text, "%s:%d:<autosummary>" % (source, line)) with switch_source_input(self.state, vl): self.state.nested_parse(vl, 0, node) try: if isinstance(node[0], nodes.paragraph): node = node[0] except IndexError: pass row.append(nodes.entry("", node)) head.append(row) group.append(head) body = nodes.tbody("") group.append(body) def append_row(*column_texts: str) -> None: row = nodes.row("") source, line = self.state_machine.get_source_and_line() for text in column_texts: node = nodes.paragraph("") vl = StringList() vl.append(text, "%s:%d:<autosummary>" % (source, line)) with switch_source_input(self.state, vl): self.state.nested_parse(vl, 0, node) try: if isinstance(node[0], nodes.paragraph): node = node[0] except IndexError: pass row.append(nodes.entry("", node)) body.append(row) for name, sig, summary, real_name, config_type in items: qualifier = "obj" if "nosignatures" not in self.options: col1 = ":%s:`%s <%s>`\\ %s" % ( qualifier, name, real_name, rst.escape(sig), ) else: col1 = ":%s:`%s <%s>`" % (qualifier, name, real_name) col2 = summary if has_config_type: col3 = config_type if config_type else "" append_row(col1, col3, col2) else: append_row(col1, col2) return [table_spec, table]