*
2<c       s%    d  Z     h  d d <d d <d d <d d <d	 d
 <d d <d d <d d <Z 1 y 2 e d i d  d Z Wn 3 4 d Z n X9 d k Z > d k Z ? d k Z E d   Z P d e i i	 f d     YZ
 h d e i i f d     YZ d e i i f d     YZ d S(   s0   Docstring converter for StructuredText format.

s)   $RCSfile: docstring_StructuredText.py,v $s   module_namesM   $Id: docstring_StructuredText.py,v 1.2 2001/12/08 15:33:00 doughellmann Exp $s   rcs_ids(   Doug Hellmann <DougHellmann@bigfoot.com>s   creators   UNSPECIFIEDs   projects   Wed, 26-Sep-2001 09:52:01 EDTs   createds   $Author: doughellmann $s   authors   $Revision: 1.2 $s   versions   $Date: 2001/12/08 15:33:00 $s   dates    i   s   0.0Nc      s5   E F G h  d d <t  d <d d d g d <Sd S(	   s;   Return information about this module to the dynamic loader.s   StructuredTexts   names   factorys	   ^.*\.stx$s	   ^.*\.txt$s"   (README|LICENSE|ANNOUNCE|CHANGES)$s   filenamePatternListN(   s   StructuredTextConverter(    (    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys
   entryPointE s   s   StructuredTextFilec      s&   P d  Z  R S d Z U e d  Z RS(   s5   External documentation in StructuredText format.
    s   StructuredTextc    s   U V t  i i i |  X | Y |  Z t  i i i	 |  i
  } [ | } \ x^ \ d oS ] y/ ^ | i   o _ | i   d } n a PWn b t j
 o c Pn XqO Wd t |  |  _ e d  Sd  S(   Ni   i    (   s   happydoclibs   happydocstrings   ExternalDocumentationFileBases   __init__s   selfs   filenames   bodys	   docstrings   StructuredTexts   Basics   _file_contentss   converted_bodys   one_liner_paras   getChildrens   AttributeErrors   strs	   _oneliner(   s   selfs   filenames   bodys   one_liner_paras   converted_body(    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys   __init__U s   
	 
(   s   __doc__s   _input_types   Nones   __init__(    (    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys   StructuredTextFileP s   		s   StructuredTextConverterc      s   h d  Z  n p e Z r d g Z t d   Z | e i d e i e i B d  Z	  e i d  d f e i d  d f e i d	  d
 f e i d  d f f d  Z
  d   Z  d d  Z  d   Z RS(   s   StructuredText format converter.

    This converter supports translating StructuredText (see
    the StructuredText package) input to HTML output.
    
    s   htmlc    s=   t u | |  i j o# v t d | |  i i f   n d  S(   Ns'   Unrecognized output format "%s" for %s.(   s   outputFormats   selfs   RECOGNIZED_OUTPUT_FORMATSs
   ValueErrors	   __class__s   __name__(   s   selfs   outputFormat(    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys   _testOutputFormatt s   s   <body>(.*)</body>c    sM   |   | i |  }  | o  | } n  | i d  }  | Sd S(   s*   Clean converted text and return new value.i   N(   s   extractBodys   searchs	   inputTexts   matchs
   clean_texts   group(   s   selfs	   inputTexts   extractBodys   matchs
   clean_text(    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys   _cleanup| s   s   &amp;s   &s   &lt;s   <s   &gt;s   >s   &quot;s   "c    sE      x. | d  r! \ } }  | i | |  } q W | Sd S(   s3   Reverse the quoting process for character entities.i    N(   s   character_entitiess   regexs   replacements   subs   text(   s   selfs   texts   character_entitiess   replacements   regex(    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys   _unquoteHTML s
    c    s      y  | i   } Wn  t j
 o  d Snr X | d j o1  | i }  |  i | i  }  | | _ n0  x) | i
   d  r }  |  i |  q W d Sd S(   s@   Unquote the characters in all example paragraphs in the ST tree.Ns   StructuredTextExamplei    (   s   sts
   getTagNames   tag_names   AttributeErrors   aq_selfs   actual_paras   selfs   _unquoteHTMLs   _srcs   texts   getChildNodess   childs   _unquoteExamplesInST(   s   selfs   sts   childs   texts   actual_paras   tag_name(    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys   _unquoteExamplesInST s    	i   c    sh     | }	  |  i |   | d j o. h  }  | i |   | | d < t	 i
 d t i i i i  d  |	  }	  t	 i
 d t i i i i  d  |	  }	  t	 i
 d  d  |	  }	  t i i i |	  }  |  i |   t i i i i   }
  t |
  | f |  |  }  t |  }  |  i |  }  | Sn  | Sd	 S(
   s  Returns the 'inputText' data translated into the 'outputFormat'.

        Parameters:

          'inputText' -- String or other sequence of characters to be
          converted.  This string should be in the format advertised
          by the docstring converter.

          'outputFormat' -- String defined by the docstring converter
          class to represent a supported output scheme.  This value is
          converter-specific, and not all converters will support the
          same output formats.

          'level=3' -- Beginning indention level for the text.  This
          controls what type of header elements are created among
          other behaviors.
        
        s   htmls   levels   [\000\n]\.\. \[([0-9_%s-]+)\]s   \n  <a name="\1">[\1]</a>s/   ([\000- ,])\[(?P<ref>[0-9_%s-]+)\]([\000- ,.:])s   \1<a href="#\2">[\2]</a>\3s)   ([\000- ,])\[([^]]+)\.html\]([\000- ,.:])s   \1<a href="\2.html">[\2]</a>\3N(   s	   inputTexts   texts   selfs   _testOutputFormats   outputFormats   applyNamedArgss   updates	   namedArgss   levels   res   subs   happydoclibs	   docstrings   StructuredTexts	   STletterss   letterss   Documents   sts   _unquoteExamplesInSTs	   HTMLClasss   htmlngs   applys   argss   html_representations   strs   _cleanup(   s   selfs	   inputTexts   outputFormats   levels   argss	   namedArgss   html_representations   sts   applyNamedArgss   texts   htmlng(    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys   convert s4   			c    s      |  i |   | d j oT  t t i i i  | f |  |  } t i d d |  } | Sn 	| Sd S(   s  Returns the 'inputText' quoted in a way that special characters are escaped.

        Parameters:

          'inputText' -- String or other sequence of characters to be
          converted.  This string should be in the format advertised
          by the docstring converter.

          'outputFormat' -- String defined by the docstring converter
          class to represent a supported output scheme.  This value is
          converter-specific, and not all converters will support the
          same output formats.

          '*args' -- Additional, converter-specific, positional arguments.

          '**namedArgs' -- Additional, converter-specific, named arguments.
          
        s   htmls   &quot;([^&]+)&quot;:s   "\1":N(   s   selfs   _testOutputFormats   outputFormats   applys   happydoclibs	   docstrings   StructuredTexts
   html_quotes	   inputTexts   argss	   namedArgss   html_quoteds   res   sub(   s   selfs	   inputTexts   outputFormats   argss	   namedArgss   html_quoted(    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys   quote s   (   s   __doc__s   StructuredTextFiles   externalDocumentFactorys   RECOGNIZED_OUTPUT_FORMATSs   _testOutputFormats   res   compiles	   MULTILINEs   DOTALLs   _cleanups   _unquoteHTMLs   _unquoteExamplesInSTs   converts   quote(    (    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys   StructuredTextConverterh s   		%W?s   StructuredTextUnitTestc      sw   d Z  d Z d Z d Z "d Z d Z d   Z d   Z d	   Z d
   Z	 d   Z
 RS(   Ns
   <>&"'[]{};s   &lt;&gt;&amp;&quot;'[]{};s   
        Structured Text With Links

          This "link":link.html points to link.html.

          This [1] reference points to an internal reference.

.. [1] This is the internal reference.
s0  
<h3>        Structured Text With Links</h3>
<p>          This <a href="link.html">link</a> points to link.html.</p>
<p>          This <a href="#1"><a href="#ref1">[1]</a></a> reference points to an internal reference.</p>
<p>  <a name="1"><a href="#ref1">[1]</a></a> This is the internal reference.</p>
s  Structured Text Manipulation

Parse a structured text string into a form that can be used with 
structured formats, like html.

Structured text is text that uses indentation and simple
symbology to indicate the structure of a document.  

A structured string consists of a sequence of paragraphs separated by
one or more blank lines.  Each paragraph has a level which is defined
as the minimum indentation of the paragraph.  A paragraph is a
sub-paragraph of another paragraph if the other paragraph is the last
preceding paragraph that has a lower level.

Special symbology is used to indicate special constructs:

- A single-line paragraph whose immediately succeeding paragraphs are lower
  level is treated as a header.

- A paragraph that begins with a '-', '*', or 'o' is treated as an
  unordered list (bullet) element.

- A paragraph that begins with a sequence of digits followed by a
  white-space character is treated as an ordered list element.

- A paragraph that begins with a sequence of sequences, where each
  sequence is a sequence of digits or a sequence of letters followed
  by a period, is treated as an ordered list element.

- A paragraph with a first line that contains some text, followed by
  some white-space and '--' is treated as
  a descriptive list element. The leading text is treated as the
  element title.

- Sub-paragraphs of a paragraph that ends in the word 'example' or the
  word 'examples', or '::' is treated as example code and is output as is.

- Text enclosed single quotes (with white-space to the left of the
  first quote and whitespace or puctuation to the right of the second quote)
  is treated as example code.

- Text surrounded by '*' characters (with white-space to the left of the
  first '*' and whitespace or puctuation to the right of the second '*')
  is emphasized.

- Text surrounded by '**' characters (with white-space to the left of the
  first '**' and whitespace or puctuation to the right of the second '**')
  is made strong.

- Text surrounded by '_' underscore characters (with whitespace to the left 
  and whitespace or punctuation to the right) is made underlined.

- Text encloded by double quotes followed by a colon, a URL, and concluded
  by punctuation plus white space, *or* just white space, is treated as a
  hyper link. For example:

    "Zope":http://www.zope.org/ is ...

  Is interpreted as '<a href="http://www.zope.org/">Zope</a> is ....'
  Note: This works for relative as well as absolute URLs.

- Text enclosed by double quotes followed by a comma, one or more spaces,
  an absolute URL and concluded by punctuation plus white space, or just
  white space, is treated as a hyper link. For example: 

    "mail me", mailto:amos@digicool.com.

  Is interpreted as '<a href="mailto:amos@digicool.com">mail me</a>.' 

- Text enclosed in brackets which consists only of letters, digits,
  underscores and dashes is treated as hyper links within the document.
  For example:
    
    As demonstrated by Smith [12] this technique is quite effective.

  Is interpreted as '... by Smith <a href="#12">[12]</a> this ...'. Together
  with the next rule this allows easy coding of references or end notes.

- Text enclosed in brackets which is preceded by the start of a line, two
  periods and a space is treated as a named link. For example:

    .. [12] "Effective Techniques" Smith, Joe ... 

  Is interpreted as '<a name="12">[12]</a> "Effective Techniques" ...'.
  Together with the previous rule this allows easy coding of references or
  end notes. 


- A paragraph that has blocks of text enclosed in '||' is treated as a
  table. The text blocks correspond to table cells and table rows are
  denoted by newlines. By default the cells are center aligned. A cell
  can span more than one column by preceding a block of text with an
  equivalent number of cell separators '||'. Newlines and '|' cannot
  be a part of the cell text. For example:

      |||| **Ingredients** ||
      || *Name* || *Amount* ||
      ||Spam||10||
      ||Eggs||3||

  is interpreted as::

    <TABLE BORDER=1 CELLPADDING=2>
     <TR>
      <TD ALIGN=CENTER COLSPAN=2> <strong>Ingredients</strong> </TD>
     </TR>
     <TR>
      <TD ALIGN=CENTER COLSPAN=1> <em>Name</em> </TD>
      <TD ALIGN=CENTER COLSPAN=1> <em>Amount</em> </TD>
     </TR>
     <TR>
      <TD ALIGN=CENTER COLSPAN=1>Spam</TD>
      <TD ALIGN=CENTER COLSPAN=1>10</TD>
     </TR>
     <TR>
      <TD ALIGN=CENTER COLSPAN=1>Eggs</TD>
      <TD ALIGN=CENTER COLSPAN=1>3</TD>
     </TR>
    </TABLE>s  
<p>Structured Text Manipulation</p>
<p>Parse a structured text string into a form that can be used with 
structured formats, like html.</p>
<p>Structured text is text that uses indentation and simple
symbology to indicate the structure of a document.  </p>
<p>A structured string consists of a sequence of paragraphs separated by
one or more blank lines.  Each paragraph has a level which is defined
as the minimum indentation of the paragraph.  A paragraph is a
sub-paragraph of another paragraph if the other paragraph is the last
preceding paragraph that has a lower level.</p>
<p>Special symbology is used to indicate special constructs:</p>

<ul>
<li><p>A single-line paragraph whose immediately succeeding paragraphs are lower
  level is treated as a header.</p></li>
<li><p>A paragraph that begins with a '-', <code>*</code>, or <code>o</code> is treated as an
  unordered list (bullet) element.</p></li>
<li><p>A paragraph that begins with a sequence of digits followed by a
  white-space character is treated as an ordered list element.</p></li>
<li><p>A paragraph that begins with a sequence of sequences, where each
  sequence is a sequence of digits or a sequence of letters followed
  by a period, is treated as an ordered list element.</p></li>
<li><p>A paragraph with a first line that contains some text, followed by
  some white-space and <code>--</code> is treated as
  a descriptive list element. The leading text is treated as the
  element title.</p></li>
<li><p>Sub-paragraphs of a paragraph that ends in the word <code>example</code> or the
  word <code>examples</code>, or <code>::</code> is treated as example code and is output as is.</p></li>
<li><p>Text enclosed single quotes (with white-space to the left of the
  first quote and whitespace or puctuation to the right of the second quote)
  is treated as example code.</p></li>
<li><p>Text surrounded by '<em><code> characters (with white-space to the left of the
  first </code></em>' and whitespace or puctuation to the right of the second <code>*</code>)
  is emphasized.</p></li>
<li><p>Text surrounded by '<strong><code> characters (with white-space to the left of the
  first </code></strong>' and whitespace or puctuation to the right of the second <code>**</code>)
  is made strong.</p></li>
<li><p>Text surrounded by <code>_</code> underscore characters (with whitespace to the left 
  and whitespace or punctuation to the right) is made underlined.</p></li>
<li><p>Text encloded by double quotes followed by a colon, a URL, and concluded
  by punctuation plus white space, <em>or</em> just white space, is treated as a
  hyper link. For example:<p>    <a href="http://www.zope.org/">Zope</a> is ...</p>
<p>  Is interpreted as '<a href="http://www.zope.org/">Zope</a> is ....'
  Note: This works for relative as well as absolute URLs.</p>
</p></li>
<li><p>Text enclosed by double quotes followed by a comma, one or more spaces,
  an absolute URL and concluded by punctuation plus white space, or just
  white space, is treated as a hyper link. For example: <p>    <a href="mailto:amos@digicool.com">mail me</a>.</p>
<p>  Is interpreted as '<a href="mailto:amos@digicool.com">mail me</a>.' </p>
</p></li>
<li><p>Text enclosed in brackets which consists only of letters, digits,
  underscores and dashes is treated as hyper links within the document.
  For example:<p>    As demonstrated by Smith <a href="#12"><a href="#ref12">[12]</a></a> this technique is quite effective.</p>
<p>  Is interpreted as '... by Smith <a href="#12"><a href="#ref12">[12]</a></a> this ...'. Together
  with the next rule this allows easy coding of references or end notes.</p>
</p></li>
<li><p>Text enclosed in brackets which is preceded by the start of a line, two
  periods and a space is treated as a named link. For example:<p>    .. <a href="#12"><a href="#ref12">[12]</a></a> "Effective Techniques" Smith, Joe ... </p>
<p>  Is interpreted as '<a name="12"><a href="#ref12">[12]</a></a> "Effective Techniques" ...'.
  Together with the previous rule this allows easy coding of references or
  end notes. </p>
</p></li>
<li><p>A paragraph that has blocks of text enclosed in <code>||</code> is treated as a
  table. The text blocks correspond to table cells and table rows are
  denoted by newlines. By default the cells are center aligned. A cell
  can span more than one column by preceding a block of text with an
  equivalent number of cell separators <code>||</code>. Newlines and <code>|</code> cannot
  be a part of the cell text. For example:<p>      |||| <strong>Ingredients</strong> ||
      || <em>Name</em> || <em>Amount</em> ||
      ||Spam||10||
      ||Eggs||3||</p>
<p>  is interpreted as:
<pre>
    &lt;TABLE BORDER=1 CELLPADDING=2&gt;
     &lt;TR&gt;
      &lt;TD ALIGN=CENTER COLSPAN=2&gt; &lt;strong&gt;Ingredients&lt;/strong&gt; &lt;/TD&gt;
     &lt;/TR&gt;
     &lt;TR&gt;
      &lt;TD ALIGN=CENTER COLSPAN=1&gt; &lt;em&gt;Name&lt;/em&gt; &lt;/TD&gt;
      &lt;TD ALIGN=CENTER COLSPAN=1&gt; &lt;em&gt;Amount&lt;/em&gt; &lt;/TD&gt;
     &lt;/TR&gt;
     &lt;TR&gt;
      &lt;TD ALIGN=CENTER COLSPAN=1&gt;Spam&lt;/TD&gt;
      &lt;TD ALIGN=CENTER COLSPAN=1&gt;10&lt;/TD&gt;
     &lt;/TR&gt;
     &lt;TR&gt;
      &lt;TD ALIGN=CENTER COLSPAN=1&gt;Eggs&lt;/TD&gt;
      &lt;TD ALIGN=CENTER COLSPAN=1&gt;3&lt;/TD&gt;
     &lt;/TR&gt;
    &lt;/TABLE&gt;
</pre>
</p>
</p></li>

</ul>
c    s6   |  i |  i d d |  i  d  d  Sd  S(   Ns   StructuredTexts   htmls)   StructuredText-to-HTML conversion failed.(   s   selfs   _testConversions   st_test_texts   st_expected_text(   s   self(    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys   testConvertStructuredTextToHTMLs   
c    s6   |  i |  i d d |  i d  	d  Sd  S(   Ns   StructuredTexts   htmls4   StructuredText-to-HTML-with-links conversion failed.(   s   selfs   _testConversions   st_test_text_with_linkss   st_expected_text_with_links(   s   self(    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys(   testConvertStructuredTextToHTMLWithLinkss   
c    s6   |  i |  i d d |  i d  d  Sd  S(   Ns   StructuredTexts   htmls   ST-to-HTML quote failed.(   s   selfs
   _testQuotes   html_quote_texts   html_quote_expected_text(   s   self(    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys   testQuoteStructuredTextToHTMLs   	
c    s~   t  d d d |  i  } t o | p
 t d  d } t o' | i   | j p t d | i    d  Sd  S(   Ns   filenames   internals   bodys)   Unable to create valid StructuredTextFiles   Structured Text Manipulations   Got different one-liner "%s"(   s   StructuredTextFiles   selfs   st_test_texts   stfs	   __debug__s   AssertionErrors   expected_oneliners   oneLiner(   s   selfs   expected_oneliners   stf(    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys   testStructuredTextOneLiners
   	1c    s   d } +d } 8|  i | :d ;d <| =d  @d } Qd } ]|  i | _d `d a| bd  dd  Sd  S(   Ns~    any text

first heading

    first
    section

second heading

    second
    section

third heading

    third
    section
s   
<h3> any text</h3>
<p>    first
    section</p>
<h3>first heading</h3>
<p>    second
    section</p>
<h3>second heading</h3>
<p>    third
    section</p>
<p>third heading</p>
s   StructuredTexts   htmls?   Converting Classic ST to HTML did not produce expected results.su   

first heading

    first
    section

second heading

    second
    section

third heading

    third
    section
s   
<h3>first heading</h3>
<p>    first
    section</p>
<h3>second heading</h3>
<p>    second
    section</p>
<h3>third heading</h3>
<p>    third
    section</p>
(   s   input_text1s   expected_text1s   selfs   _testConversions   input_text2s   expected_text2(   s   selfs   expected_text2s   input_text2s   expected_text1s   input_text1(    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys   testBug471981s   		
		
(   s   html_quote_texts   html_quote_expected_texts   st_test_text_with_linkss   st_expected_text_with_linkss   st_test_texts   st_expected_texts   testConvertStructuredTextToHTMLs(   testConvertStructuredTextToHTMLWithLinkss   testQuoteStructuredTextToHTMLs   testStructuredTextOneLiners   testBug471981(    (    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys   StructuredTextUnitTests   			
		x	c(   s   __doc__s   __rcs_info__s   splits   __version__s   res$   happydoclib.docstring.StructuredTexts   happydoclibs
   entryPoints   happydocstrings   ExternalDocumentationFileBases   StructuredTextFiles   HappyDocStringConverterBases   StructuredTextConverters   DocStringConverterTests   StructuredTextUnitTest(   s   __rcs_info__s   happydoclibs   __version__s   StructuredTextUnitTests   StructuredTextFiles   StructuredTextConverters
   entryPoints   re(    (    sl   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_0/happydoclib/docstring/docstring_StructuredText.pys   ? s   Q