Parser for epytext strings. Epytext is a lightweight markup whose primary intended application is Python documentation strings. This parser converts Epytext strings to a simple DOM-like representation (encoded as a tree of Element
objects and strings). Epytext strings can contain the following structural blocks:
Additionally, the following inline regions may be used within para blocks:
The returned DOM tree will conform to the the following Document Type Description:
<!ENTITY % colorized '(code | math | index | italic | bold | uri | link | symbol)*'> <!ELEMENT epytext ((para | literalblock | doctestblock | section | ulist | olist)*, fieldlist?)> <!ELEMENT para (#PCDATA | %colorized;)*> <!ELEMENT section (para | listblock | doctestblock | section | ulist | olist)+> <!ELEMENT fieldlist (field+)> <!ELEMENT field (tag, arg?, (para | listblock | doctestblock) ulist | olist)+)> <!ELEMENT tag (#PCDATA)> <!ELEMENT arg (#PCDATA)> <!ELEMENT literalblock (#PCDATA | %colorized;)*> <!ELEMENT doctestblock (#PCDATA)> <!ELEMENT ulist (li+)> <!ELEMENT olist (li+)> <!ELEMENT li (para | literalblock | doctestblock | ulist | olist)+> <!ATTLIST li bullet NMTOKEN #IMPLIED> <!ATTLIST olist start NMTOKEN #IMPLIED> <!ELEMENT uri (name, target)> <!ELEMENT link (name, target)> <!ELEMENT name (#PCDATA | %colorized;)*> <!ELEMENT target (#PCDATA)> <!ELEMENT code (#PCDATA | %colorized;)*> <!ELEMENT math (#PCDATA | %colorized;)*> <!ELEMENT italic (#PCDATA | %colorized;)*> <!ELEMENT bold (#PCDATA | %colorized;)*> <!ELEMENT indexed (#PCDATA | %colorized;)> <!ATTLIST code style CDATA #IMPLIED> <!ELEMENT symbol (#PCDATA)> <!ELEMENT wbr>
Class | ColorizingError |
An error generated while colorizing a paragraph. |
Class | Element |
No summary |
Class | ParsedEpytextDocstring |
Undocumented |
Class | StructuringError |
An error generated while structuring a formatted documentation string. |
Class | Token |
Tokens are an intermediate data structure used while constructing the structuring DOM tree for a formatted docstring. There are five types of Token: |
Class | TokenizationError |
An error generated while tokenizing a formatted documentation string. |
Function | get_parser |
Get the parse_docstring function. |
Function | parse |
Return a DOM tree encoding the contents of an epytext string. Any errors generated during parsing will be stored in errors. |
Function | parse_docstring |
Parse the given docstring, which is formatted using epytext; and return a ParsedDocstring representation of its contents. |
Constant | SYMBOLS |
A list of the of escape symbols that are supported by epydoc. Currently the following symbols are supported : |
Variable | __doc__ |
Undocumented |
Variable | symblist |
Undocumented |
Function | _add_list |
Add a new list item or field to the DOM tree, with the given bullet or field tag. When necessary, create the associated list. |
Function | _add_para |
Colorize the given paragraph, and add it to the DOM tree. |
Function | _add_section |
Add a new section to the DOM tree, with the given heading. |
Function | _colorize |
No summary |
Function | _colorize_link |
Undocumented |
Function | _pop_completed_blocks |
No summary |
Function | _tokenize |
Split a given formatted docstring into an ordered list of Token s, according to the epytext markup rules. |
Function | _tokenize_doctest |
No summary |
Function | _tokenize_listart |
No summary |
Function | _tokenize_literal |
No summary |
Function | _tokenize_para |
No summary |
Constant | _BRACE_RE |
Undocumented |
Constant | _BULLET_RE |
Undocumented |
Constant | _COLORIZING_TAGS |
Undocumented |
Constant | _ESCAPES |
Undocumented |
Constant | _FIELD_BULLET |
Undocumented |
Constant | _FIELD_BULLET_RE |
Undocumented |
Constant | _HEADING_CHARS |
Undocumented |
Constant | _LINK_COLORIZING_TAGS |
Undocumented |
Constant | _LIST_BULLET_RE |
Undocumented |
Constant | _OLIST_BULLET |
Undocumented |
Constant | _SYMBOLS |
Undocumented |
Constant | _TARGET_RE |
Undocumented |
Constant | _ULIST_BULLET |
Undocumented |
parse_docstring
function.Parameters | |
obj:Optional[ | Undocumented |
Returns | |
Callable[ | Undocumented |
Parameters | |
text:str | The epytext string to parse. |
errors:Optional[ | A list where any errors generated during parsing will be stored. If no list is specified, then fatal errors will generate exceptions, and non-fatal errors will be ignored. |
Returns | |
Optional[ | a DOM tree encoding the contents of an epytext string, or None if non-fatal errors were encountered and no errors accumulator was provided. |
Raises | |
ParseError | If errors is None and an error is encountered while parsing. |
ParsedDocstring
representation of its contents.Parameters | |
docstring:str | The docstring to parse |
errors:List[ | A list where any errors generated during parsing will be stored. |
processtypes:bool | Use ParsedTypeDocstring to parsed 'type' fields. |
Returns | |
ParsedDocstring | Undocumented |
list[ str]
=
A list of the of escape symbols that are supported by epydoc. Currently the following symbols are supported :
# Arrows '<-', '->', '^', 'v', # Greek letters 'alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', 'omicron', 'pi', 'rho', 'sigma', 'tau', 'upsilon', 'phi', 'chi', 'psi', 'omega', 'Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta', 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi', 'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Upsilon', 'Phi', 'Chi', 'Psi', 'Omega', # HTML character entities 'larr', 'rarr', 'uarr', 'darr', 'harr', 'crarr', 'lArr', 'rArr', 'uArr', 'dArr', 'hArr', 'copy', 'times', 'forall', 'exist', 'part', 'empty', 'isin', 'notin', 'ni', 'prod', 'sum', 'prop', 'infin', 'ang', 'and', 'or', 'cap', 'cup', 'int', 'there4', 'sim', 'cong', 'asymp', 'ne', 'equiv', 'le', 'ge', 'sub', 'sup', 'nsub', 'sube', 'supe', 'oplus', 'otimes', 'perp', # Alternate (long) names 'infinity', 'integral', 'product', '>=', '<=',
Value |
|
Parameters | |
bullet_token:Token | Undocumented |
stack:List[ | Undocumented |
indent_stack:List[ | Undocumented |
errors:List[ | Undocumented |
Parameters | |
para_token:Token | Undocumented |
stack:List[ | Undocumented |
indent_stack:List[ | Undocumented |
errors:List[ | Undocumented |
Parameters | |
heading_token:Token | Undocumented |
stack:List[ | Undocumented |
indent_stack:List[ | Undocumented |
errors:List[ | Undocumented |
Parameters | |
token:Token | Undocumented |
errors:list of string | A list of errors. Any newly generated errors will be appended to this list. |
tagName:string | The element tag for the DOM Element that should be generated. |
Returns | |
Element | a DOM Element encoding the given paragraph. |
Undocumented
Parameters | |
link:Element | Undocumented |
token:Token | Undocumented |
end:int | Undocumented |
errors:List[ | Undocumented |
Parameters | |
token:Token | Undocumented |
stack:List[ | Undocumented |
indent_stack:List[ | Undocumented |
Token
s, according to the epytext markup rules.Parameters | |
text:str | The epytext string |
errors:List[ | A list where any errors generated during parsing will be stored. If no list is specified, then errors will generate exceptions. |
Returns | |
List[ | a list of the Token s that make up the given string. |
Token
containing the doctest block starting at lines[start], and append it to tokens. block_indent should be the indentation of the doctest block. Any errors generated while tokenizing the doctest block will be appended to errors.Parameters | |
lines:List[ | The list of lines to be tokenized |
start:int | The index into lines of the first line of the doctest block to be tokenized. |
block_indent:int | The indentation of lines[start]. This is the indentation of the doctest block. |
tokens:List[ | Undocumented |
errors:List[ | A list where any errors generated during parsing will be stored. If no list is specified, then errors will generate exceptions. |
Returns | |
int | The line number of the first line following the doctest block. |
Token
s for the bullet and the first paragraph of the list item (or field) starting at lines[start], and append them to tokens. bullet_indent should be the indentation of the list item. Any errors generated while tokenizing will be appended to errors.Parameters | |
lines:List[ | The list of lines to be tokenized |
start:int | The index into lines of the first line of the list item to be tokenized. |
bullet_indent:int | The indentation of lines[start]. This is the indentation of the list item. |
tokens:List[ | Undocumented |
errors:List[ | A list of the errors generated by parsing. Any new errors generated while will tokenizing this paragraph will be appended to this list. |
Returns | |
int | The line number of the first line following the list item's first paragraph. |
Token
containing the literal block starting at lines[start], and append it to tokens. block_indent should be the indentation of the literal block. Any errors generated while tokenizing the literal block will be appended to errors.Parameters | |
lines:List[ | The list of lines to be tokenized |
start:int | The index into lines of the first line of the literal block to be tokenized. |
block_indent:int | The indentation of lines[start]. This is the indentation of the literal block. |
tokens:List[ | Undocumented |
errors:List[ | A list of the errors generated by parsing. Any new errors generated while will tokenizing this paragraph will be appended to this list. |
Returns | |
int | The line number of the first line following the literal block. |
Token
containing the paragraph starting at lines[start], and append it to tokens. para_indent should be the indentation of the paragraph . Any errors generated while tokenizing the paragraph will be appended to errors.Parameters | |
lines:List[ | The list of lines to be tokenized |
start:int | The index into lines of the first line of the paragraph to be tokenized. |
para_indent:int | The indentation of lines[start]. This is the indentation of the paragraph. |
tokens:List[ | Undocumented |
errors:List[ | A list of the errors generated by parsing. Any new errors generated while will tokenizing this paragraph will be appended to this list. |
Returns | |
int | The line number of the first line following the paragraph. |