docutils.parsers.rst.directives.tables module

Directives for table elements.

align(argument)[source]
class Table(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: Directive

Generic table base class.

optional_arguments = 1

Number of optional arguments after the required arguments.

final_argument_whitespace = True

May the final argument contain whitespace?

option_spec = {'align': <function align>, 'class': <function class_option>, 'name': <function unchanged>, 'width': <function length_or_percentage_or_unitless>, 'widths': <function value_or.<locals>.auto_or_other>}

Mapping of option names to validator functions.

has_content = True

May the directive have content?

make_title()[source]
process_header_option()[source]
check_table_dimensions(rows, header_rows, stub_columns)[source]
set_table_width(table_node)[source]
property widths
get_column_widths(n_cols)[source]
extend_short_rows_with_empty_cells(columns, parts)[source]
class RSTTable(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: Table

Class for the “table” directive for formal tables using rST syntax.

run()[source]
class CSVTable(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: Table

option_spec = {'align': <function align>, 'class': <function class_option>, 'delim': <function single_char_or_whitespace_or_unicode>, 'encoding': <function encoding>, 'escape': <function single_char_or_unicode>, 'file': <function path>, 'header': <function unchanged>, 'header-rows': <function nonnegative_int>, 'keepspace': <function flag>, 'name': <function unchanged>, 'quote': <function single_char_or_unicode>, 'stub-columns': <function nonnegative_int>, 'url': <function uri>, 'width': <function length_or_percentage_or_unitless>, 'widths': <function value_or.<locals>.auto_or_other>}

Mapping of option names to validator functions.

class DocutilsDialect(options)[source]

Bases: Dialect

CSV dialect for csv_table directive.

strict = True
lineterminator = '\n'
quoting = 0
delimiter = ','
skipinitialspace = True
quotechar = '"'
doublequote = True
class HeaderDialect[source]

Bases: Dialect

CSV dialect used for the “header” option data.

Deprecated. Will be removed in Docutils 0.22.

delimiter = ','
quotechar = '"'
escapechar = '\\'
doublequote = False
skipinitialspace = True
strict = True
lineterminator = '\n'
quoting = 0
static check_requirements()[source]
run()[source]
get_csv_data()[source]

Get CSV data from the directive content, from an external file, or from a URL reference.

static decode_from_csv(s)[source]
static encode_for_csv(s)[source]
parse_csv_data_into_rows(csv_data, dialect, source)[source]
class ListTable(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: Table

Implement tables whose data is encoded as a uniform two-level bullet list. For further ideas, see https://docutils.sourceforge.io/docs/dev/rst/alternatives.html#list-driven-tables

option_spec = {'align': <function align>, 'class': <function class_option>, 'header-rows': <function nonnegative_int>, 'name': <function unchanged>, 'stub-columns': <function nonnegative_int>, 'width': <function length_or_percentage_or_unitless>, 'widths': <function value_or.<locals>.auto_or_other>}

Mapping of option names to validator functions.

run()[source]
check_list_content(node)[source]
build_table_from_list(table_data, col_widths, header_rows, stub_columns)[source]