AST (pyndoc.ast package)
This package contains the definitions related to the Pyndoc Abstract Syntax Tree, including blocks, helpers, and read handlers
Submodules
pyndoc.ast.ast_tree module
pyndoc.ast.basic_blocks module
Basic AST blocks that are used as a base for more complex AST Blocks
- class pyndoc.ast.basic_blocks.ASTAtomBlock(contents: str = '')[source]
Bases:
ASTBlock,AtomReadHandlerDefinition of an AST Atom Block. An AST Atom block is a block that cannot hold any other blocks inside of it.
- Parameters:
contents (
str, optional) – the contents of the Atom Block, empty by default
- class pyndoc.ast.basic_blocks.ASTCompositeContents(metadata: list, contents: list[ASTBlock])[source]
Bases:
objectThe representation of a composite block’s contents
- Parameters:
metadata (
list) – The block’s special metadatacontents (
list[ASTBlock]) – The contents of the class
- class pyndoc.ast.basic_blocks.ASTCompositeBlock(metadata: list | None = None, contents: list | None = None)[source]
Bases:
ASTBlock,CompositeReadHandlerThe definition of an AST Composite block. This block can hold both atom, and other composite blocks inside of it.
- Parameters:
metadata (
list | None) – List of block’s metadatacontents (
list | None) – A list of other ASTBlocks representing the block’s contents, defaults to a None object
pyndoc.ast.blocks module
Defualt block definitions
- class pyndoc.ast.blocks.Space[source]
Bases:
ASTAtomBlockAST Atom block representing whitespace
- class pyndoc.ast.blocks.Str(contents: str = '')[source]
Bases:
ASTAtomBlockspecial AST block representing string without whitespace characters
- class pyndoc.ast.blocks.SoftBreak[source]
Bases:
ASTAtomBlock
- class pyndoc.ast.blocks.Header[source]
Bases:
ASTCompositeBlockAST block representing a heading
- class pyndoc.ast.blocks.Para[source]
Bases:
ASTCompositeBlockAST block representing a paragraph.
- class pyndoc.ast.blocks.Emph[source]
Bases:
ASTCompositeBlockBasic Italic AST block
- class pyndoc.ast.blocks.Strong[source]
Bases:
ASTCompositeBlockBasic Bold AST block
- class pyndoc.ast.blocks.Code[source]
Bases:
ASTAtomBlockBasic Code AST block
- class pyndoc.ast.blocks.BulletList[source]
Bases:
ASTCompositeBlock
- class pyndoc.ast.blocks.OrderedList[source]
Bases:
ASTCompositeBlockOrdered List AST block
- class pyndoc.ast.blocks.Plain[source]
Bases:
ASTCompositeBlock
- class pyndoc.ast.blocks.Table[source]
Bases:
ASTCompositeBlockTable AST block
- class pyndoc.ast.blocks.TableHead[source]
Bases:
ASTCompositeBlockTable Head AST block
- class pyndoc.ast.blocks.TableBody[source]
Bases:
ASTCompositeBlockTable Body AST block
- class pyndoc.ast.blocks.Row[source]
Bases:
ASTCompositeBlockTable Row AST block
- class pyndoc.ast.blocks.Cell[source]
Bases:
ASTCompositeBlockTable Cell AST block
- class pyndoc.ast.blocks.CodeBlock[source]
Bases:
ASTAtomBlockCode block AST block
pyndoc.ast.helpers module
- class pyndoc.ast.helpers.NumberingType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum- DECIMAL = 1
- ALPHABETIC = 2
- ROMAN_NUMERALS = 3
- class pyndoc.ast.helpers.Separator(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum- PERIOD = 1
- CLOSING_PAREN = 2
pyndoc.ast.read_handler module
Read handlers, that define class attributes for read patterns for certain blocks
- class pyndoc.ast.read_handler.CompositeReadHandler[source]
Bases:
objectClass that is meant as a handler for reading logic for an AST Composite child. methods implemented here are defaults for
- start_pattern = ''
str, The start pattern of a block, defaults to an empty string
- end_pattern = ''
str, The end pattern of a block, defaults to an empty string
- inline = False
bool, decides if the block is an inline
- process_read(**_: Unpack[ProcessParams]) None[source]
Process additional keyword arguments after block initialization. Not used here, the function is meant to be used inside of blocks inherited from basic AST blocks. Otherwise no processing will be done
- classmethod start(**kwargs: Unpack[StartParams]) tuple[Match | None, str][source]
Check if a block has started. Returns a match if matched, otherwise None
- Parameters:
**kwargs – See below
- Keyword Arguments:
token (
str) – the current token
- classmethod end(**kwargs: Unpack[EndParams]) tuple[Match | None, str][source]
Check if a block has ended. Returns a match if matched, otherwise None
- Parameters:
**kwargs – See below
- Keyword Arguments:
token (
str) – string representing current token to be matched against pattern
- classmethod override_start(pattern: str) None[source]
Override the start pattern of an ASTCompositeBlock
- Parameters:
pattern (str) – The new pattern of a block
- classmethod override_end(pattern: str) None[source]
Override the end pattern of an ASTCompositeBlock
- Parameters:
pattern (str) – The new pattern of a block
- class pyndoc.ast.read_handler.AtomReadHandler[source]
Bases:
object- pattern = ''
- start_pattern = ''
- has_content = True
- classmethod match_pattern(**kwargs: Unpack[AtomMatchParams]) tuple[Match | None, str][source]
Check if the block matches a given token. Returns a regex match (or None if match failed)
- Parameters:
**kwargs – See below
- Keyword Arguments:
text (
str) – the token to be matched against the pattern attribute
- classmethod override_match_pattern(pattern: str) None[source]
Set the match pattern to a new value
- Parameters:
pattern (str) – The new pattern to be set