Package epydoc :: Package markup :: Module epytext
[show private | hide private]
[frames | no frames]

Module epydoc.markup.epytext

Parser for epytext strings. Epytext is a lightweight markup whose primary intended application is Python documentation strings. This parser converts Epytext strings to a XML/DOM representation. 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)>
  <!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;)>

  <!ELEMENT symbol (#PCDATA)>

Classes
ParsedEpytextDocstring  
Token Tokens are an intermediate data structure used while constructing the structuring DOM tree for a formatted docstring.

Exceptions
ColorizingError An error generated while colorizing a paragraph.
StructuringError An error generated while structuring a formatted documentation string.
TokenizationError An error generated while tokenizing a formatted documentation string.

Function Summary
xml.dom.minidom.Document parse(str, errors)
Return a DOM tree encoding the contents of an epytext string.
xml.dom.minidom.Document parse_as_literal(str)
Return a DOM document matching the epytext DTD, containing a single literal block.
xml.dom.minidom.Document parse_as_para(str)
Return a DOM document matching the epytext DTD, containing a single paragraph.
ParsedDocstring parse_docstring(docstring, errors, **options)
Parse the given docstring, which is formatted using epytext; and return a ParsedDocstring representation of its contents.
xml.dom.minidom.Document pparse(str, show_warnings, show_errors, stream)
Pretty-parse the string.
string to_debug(tree, indent, seclevel)
Convert a DOM document encoding epytext back to an epytext string, annotated with extra debugging information.
string to_epytext(tree, indent, seclevel)
Convert a DOM document encoding epytext back to an epytext string.
string to_plaintext(tree, indent, seclevel)
Convert a DOM document encoding epytext to a string representation.

Variable Summary
list SYMBOLS: A list of the of escape symbols that are supported by epydoc.

Function Details

parse(str, errors=None)

Return a DOM tree encoding the contents of an epytext string. Any errors generated during parsing will be stored in errors.
Parameters:
str - The epytext string to parse.
           (type=string)
errors - 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.
           (type=list of ParseError)
Returns:
a DOM tree encoding the contents of an epytext string.
           (type=xml.dom.minidom.Document)
Raises:
ParseError - If errors is None and an error is encountered while parsing.

parse_as_literal(str)

Return a DOM document matching the epytext DTD, containing a single literal block. That literal block will include the contents of the given string. This method is typically used as a fall-back when the parser fails.
Parameters:
str - The string which should be enclosed in a literal block.
           (type=string)
Returns:
A DOM document containing str in a single literal block.
           (type=xml.dom.minidom.Document)

parse_as_para(str)

Return a DOM document matching the epytext DTD, containing a single paragraph. That paragraph will include the contents of the given string. This can be used to wrap some forms of automatically generated information (such as type names) in paragraphs.
Parameters:
str - The string which should be enclosed in a paragraph.
           (type=string)
Returns:
A DOM document containing str in a single paragraph.
           (type=xml.dom.minidom.Document)

parse_docstring(docstring, errors, **options)

Parse the given docstring, which is formatted using epytext; and return a ParsedDocstring representation of its contents.
Parameters:
docstring - The docstring to parse
           (type=string)
errors - A list where any errors generated during parsing will be stored.
           (type=list of ParseError)
options - Extra options. Unknown options are ignored. Currently, no extra options are defined.
Returns:
ParsedDocstring

pparse(str, show_warnings=1, show_errors=1, stream=<cStringIO.StringO object at 0x8504f68>)

Pretty-parse the string. This parses the string, and catches any warnings or errors produced. Any warnings and errors are displayed, and the resulting DOM parse structure is returned.
Parameters:
str - The string to parse.
           (type=string)
show_warnings - Whether or not to display non-fatal errors generated by parsing str.
           (type=boolean)
show_errors - Whether or not to display fatal errors generated by parsing str.
           (type=boolean)
stream - The stream that warnings and errors should be written to.
           (type=stream)
Returns:
a DOM document encoding the contents of str.
           (type=xml.dom.minidom.Document)
Raises:
SyntaxError - If any fatal errors were encountered.

to_debug(tree, indent=4, seclevel=0)

Convert a DOM document encoding epytext back to an epytext string, annotated with extra debugging information. This function is similar to to_epytext, but it adds explicit information about where different blocks begin, along the left margin.
Parameters:
tree - A DOM document encoding of an epytext string.
           (type=xml.dom.minidom.Document)
indent - The indentation for the string representation of tree. Each line of the returned string will begin with indent space characters.
           (type=int)
seclevel - The section level that tree appears at. This is used to generate section headings.
           (type=int)
Returns:
The epytext string corresponding to tree.
           (type=string)

to_epytext(tree, indent=0, seclevel=0)

Convert a DOM document encoding epytext back to an epytext string. This is the inverse operation from parse. I.e., assuming there are no errors, the following is true:
  • parse(to_epytext(tree)) == tree
The inverse is true, except that whitespace, line wrapping, and character escaping may be done differently.
  • to_epytext(parse(str)) == str (approximately)
Parameters:
tree - A DOM document encoding of an epytext string.
           (type=xml.dom.minidom.Document)
indent - The indentation for the string representation of tree. Each line of the returned string will begin with indent space characters.
           (type=int)
seclevel - The section level that tree appears at. This is used to generate section headings.
           (type=int)
Returns:
The epytext string corresponding to tree.
           (type=string)

to_plaintext(tree, indent=0, seclevel=0)

Convert a DOM document encoding epytext to a string representation. This representation is similar to the string generated by to_epytext, but to_plaintext removes inline markup, prints escaped characters in unescaped form, etc.
Parameters:
tree - A DOM document encoding of an epytext string.
           (type=xml.dom.minidom.Document)
indent - The indentation for the string representation of tree. Each line of the returned string will begin with indent space characters.
           (type=int)
seclevel - The section level that tree appears at. This is used to generate section headings.
           (type=int)
Returns:
The epytext string corresponding to tree.
           (type=string)

Variable Details

SYMBOLS

A list of the of escape symbols that are supported by epydoc. Currently the following symbols are supported: S{<-}=←; S{->}=→; S{^}=↑; S{v}=↓; S{alpha}=α; S{beta}=β; S{gamma}=γ; S{delta}=δ; S{epsilon}=ε; S{zeta}=ζ; S{eta}=η; S{theta}=θ; S{iota}=ι; S{kappa}=κ; S{lambda}=λ; S{mu}=μ; S{nu}=ν; S{xi}=ξ; S{omicron}=ο; S{pi}=π; S{rho}=ρ; S{sigma}=σ; S{tau}=τ; S{upsilon}=υ; S{phi}=φ; S{chi}=χ; S{psi}=ψ; S{omega}=ω; S{Alpha}=Α; S{Beta}=Β; S{Gamma}=Γ; S{Delta}=Δ; S{Epsilon}=Ε; S{Zeta}=Ζ; S{Eta}=Η; S{Theta}=Θ; S{Iota}=Ι; S{Kappa}=Κ; S{Lambda}=Λ; S{Mu}=Μ; S{Nu}=Ν; S{Xi}=Ξ; S{Omicron}=Ο; S{Pi}=Π; S{Rho}=Ρ; S{Sigma}=Σ; S{Tau}=Τ; S{Upsilon}=Υ; S{Phi}=Φ; S{Chi}=Χ; S{Psi}=Ψ; S{Omega}=Ω; S{larr}=←; S{rarr}=→; S{uarr}=↑; S{darr}=↓; S{harr}=↔; S{crarr}=↵; S{lArr}=⇐; S{rArr}=⇒; S{uArr}=⇑; S{dArr}=⇓; S{hArr}=⇔; S{copy}=©; S{times}=×; S{forall}=∀; S{exist}=∃; S{part}=∂; S{empty}=∅; S{isin}=∈; S{notin}=∉; S{ni}=∋; S{prod}=∏; S{sum}=∑; S{prop}=∝; S{infin}=∞; S{ang}=∠; S{and}=∧; S{or}=∨; S{cap}=∩; S{cup}=∪; S{int}=∫; S{there4}=∴; S{sim}=∼; S{cong}=≅; S{asymp}=≈; S{ne}=≠; S{equiv}=≡; S{le}=≤; S{ge}=≥; S{sub}=⊂; S{sup}=⊃; S{nsub}=⊄; S{sube}=⊆; S{supe}=⊇; S{oplus}=⊕; S{otimes}=⊗; S{perp}=⊥; S{infinity}=∞; S{integral}=∫; S{product}=∏; S{>=}=≥; S{<=}=≤
Type:
list
Value:
['<-', '->', '^', 'v', 'alpha', 'beta', 'gamma', 'delta', 'epsilon']   

Generated by Epydoc 2.1 on Sat Mar 20 17:46:14 2004 http://epydoc.sf.net