docutils.parsers.rst.directives.misc module

Miscellaneous directives.

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

Bases: Directive

Include content read from a separate source file.

Content may be parsed by the parser, or included as a literal block. The encoding of the included file can be specified. Only a part of the given file argument may be included by specifying start and end line or text to match before and/or after the text to be used.

https://docutils.sourceforge.io/docs/ref/rst/directives.html#including-an-external-document-fragment

required_arguments = 1

Number of required directive arguments.

optional_arguments = 0

Number of optional arguments after the required arguments.

final_argument_whitespace = True

May the final argument contain whitespace?

option_spec = {'class': <function class_option>, 'code': <function unchanged>, 'encoding': <function encoding>, 'end-before': <function unchanged_required>, 'end-line': <class 'int'>, 'literal': <function flag>, 'name': <function unchanged>, 'number-lines': <function unchanged>, 'parser': <function parser_name>, 'start-after': <function unchanged_required>, 'start-line': <class 'int'>, 'tab-width': <class 'int'>}

Mapping of option names to validator functions.

standard_include_path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/sphinx-docutils/envs/latest/lib/python3.12/site-packages/docutils/parsers/rst/include')
run()[source]

Include a file as part of the content of this reST file.

Depending on the options, the file (or a clipping) is converted to nodes and returned or inserted into the input stream.

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

Bases: Directive

Pass through content unchanged

Content is included in output based on type argument

Content may be included inline (content section of directive) or imported from a file or url.

required_arguments = 1

Number of required directive arguments.

optional_arguments = 0

Number of optional arguments after the required arguments.

final_argument_whitespace = True

May the final argument contain whitespace?

option_spec = {'class': <function class_option>, 'encoding': <function encoding>, 'file': <function path>, 'url': <function uri>}

Mapping of option names to validator functions.

has_content = True

May the directive have content?

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

Bases: Directive

has_content = True

May the directive have content?

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

Bases: Directive

Convert Unicode character codes (numbers) to characters. Codes may be decimal numbers, hexadecimal numbers (prefixed by 0x, x, \x, U+, u, or \u; e.g. U+262E), or XML-style numeric character entities (e.g. &#x262E;). Text following “..” is a comment and is ignored. Spaces are ignored, and any other text remains as-is.

required_arguments = 1

Number of required directive arguments.

optional_arguments = 0

Number of optional arguments after the required arguments.

final_argument_whitespace = True

May the final argument contain whitespace?

option_spec = {'ltrim': <function flag>, 'rtrim': <function flag>, 'trim': <function flag>}

Mapping of option names to validator functions.

comment_pattern = re.compile('( |\\n|^)\\.\\. ')
run()[source]
class Class(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: Directive

Set a “class” attribute on the directive content or the next element. When applied to the next element, a “pending” element is inserted, and a transform does the work later.

required_arguments = 1

Number of required directive arguments.

optional_arguments = 0

Number of optional arguments after the required arguments.

final_argument_whitespace = True

May the final argument contain whitespace?

has_content = True

May the directive have content?

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

Bases: Directive

has_content = True

May the directive have content?

argument_pattern = re.compile('((?:(?!_)\\w)+(?:[-._+:](?:(?!_)\\w)+)*)\\s*(\\(\\s*((?:(?!_)\\w)+(?:[-._+:](?:(?!_)\\w)+)*)\\s*\\)\\s*)?$')
run()[source]

Dynamically create and register a custom interpreted text role.

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

Bases: Directive

Set the default interpreted text role.

optional_arguments = 1

Number of optional arguments after the required arguments.

final_argument_whitespace = False

May the final argument contain whitespace?

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

Bases: Directive

required_arguments = 1

Number of required directive arguments.

optional_arguments = 0

Number of optional arguments after the required arguments.

final_argument_whitespace = True

May the final argument contain whitespace?

run()[source]
class MetaBody(state_machine, debug=False)[source]

Bases: SpecializedBody

field_marker(match, context, next_state)[source]

Meta element.

parsemeta(match)[source]
class Meta(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: Directive

has_content = True

May the directive have content?

SMkwargs = {'state_classes': (<class 'docutils.parsers.rst.directives.misc.MetaBody'>,)}
run()[source]
class Date(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: Directive

has_content = True

May the directive have content?

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

Bases: Directive

This directive is useful only for testing purposes.

optional_arguments = 1

Number of optional arguments after the required arguments.

final_argument_whitespace = True

May the final argument contain whitespace?

option_spec = {'option': <function unchanged_required>}

Mapping of option names to validator functions.

has_content = True

May the directive have content?

run()[source]