pyndoc.readers.gfm package

Submodules

pyndoc.readers.gfm.blocks module

class pyndoc.readers.gfm.blocks.Space[source]

Bases: Space

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

class pyndoc.readers.gfm.blocks.SoftBreak[source]

Bases: SoftBreak

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

class pyndoc.readers.gfm.blocks.Header[source]

Bases: Header

process_read(**kwargs: 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

class pyndoc.readers.gfm.blocks.Emph(**_: None)[source]

Bases: Emph

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 handle_premature_closure(**kwargs: Unpack[EndParams]) str[source]

Used when when the file has ended, but context has not been closed Potentially modify recieved token end return it

Parameters:

token (str) – The current token to be modified

class pyndoc.readers.gfm.blocks.BulletList[source]

Bases: _GFMList, BulletList

process_read(**kwargs: 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

class pyndoc.readers.gfm.blocks.OrderedList[source]

Bases: _GFMList, OrderedList

separator_dict = {')': Separator.CLOSING_PAREN, '.': Separator.PERIOD}
numbering_type = 1
process_read(**kwargs: 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

class pyndoc.readers.gfm.blocks.Table[source]

Bases: Table

static add_table_head(context: list) None[source]
static add_table_body(context: list) None[source]
static add_row(context: list) None[source]
static add_cell(context: list) None[source]
classmethod handle_table_end(context: list) None[source]
classmethod handle_table_head_end(context: list) None[source]
process_read(**kwargs: 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 handle_premature_closure(**kwargs: Unpack[EndParams]) str[source]

Used when when the file has ended, but context has not been closed Potentially modify recieved token end return it

Parameters:

token (str) – The current token to be modified

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

class pyndoc.readers.gfm.blocks.TableHead[source]

Bases: TableHead

static format_table_head(thead: TableHead, alignment: list[Alignment], row_size: int) None[source]
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

class pyndoc.readers.gfm.blocks.TableBody[source]

Bases: TableBody

static format_table_body(tbody: TableBody, alignment: list[Alignment], row_size: int) None[source]
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

class pyndoc.readers.gfm.blocks.Row[source]

Bases: Row

static format_row(row: Row, alignment: list[Alignment], size: int) None[source]
static is_delimiter_row(row: Row) bool[source]

Determines whether a row is delimiter row

Parameters:

row (Row) – row being checked

return: true if row is delimiter row, otherwise false :rtype: bool

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

class pyndoc.readers.gfm.blocks.Cell[source]

Bases: Cell

delimiter_regex = '(?P<l>:?)-+(?P<r>:?)'
classmethod is_delimiter_cell(cell: Cell) bool[source]

Determines whether a cell is delimiter cell - has only one element that is a string and its content is in format matches regular expression (?P<l>:?)-+(?P<l>:?) e.g.: “-”, “:—-”, “–:”, “:—:”

Parameters:

cell (Cell) – cell being checked

Returns:

true if passed cell is delimiter cell, otherwise false

Return type:

bool

classmethod get_delimiter_cell_alignment(cell: Cell) Alignment[source]

Returns the alignment of delimiter cell. To be used with cell that passed is_delimiter_cell method

Parameters:

cell (Cell) – cell being checked

Returns:

cell alignment

Return type:

Alignment

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

class pyndoc.readers.gfm.blocks.CodeBlockHelper[source]

Bases: ASTCompositeBlock

A composite helper for parsing CodeBlocks This block will create a CodeBlock in its contents, parse its metadata and adjust contents. When the block ends, it will replace itself with the CodeBlock in the context stack.

process_read(**kwargs: Unpack[ProcessParams]) None[source]

Parse a CodeBlock metadata and add an empty CodeBlock to the block’s contents

classmethod end(**kwargs: Unpack[EndParams]) tuple[Match | None, str][source]

Add ANY token to the CodeBlock, then check if the end of the block matches CodeBlock end pattern

class pyndoc.readers.gfm.blocks.CodeHelper[source]

Bases: ASTCompositeBlock

A Helper for parsing inline code This block will create a Code in its contents, parse its metadata and adjust contents. When the block ends, it will replace itself with the Code in the context stack.

process_read(**kwargs: Unpack[ProcessParams]) None[source]

Set the end pattern of the block based on the start pattern. Then add an empty Code block to the contents

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]

Add ANY token to the Code, then check if the end of the block matches Code end pattern

pyndoc.readers.gfm.tokens module

pyndoc.readers.gfm.tokens.assign_patterns() None[source]

Module contents