<?xml version="1.0" encoding="ascii" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ascii" /> <meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" /> <title>Regression Testing for epydoc.markup.pyval_repr</title> <link rel="stylesheet" href="../custom.css" type="text/css" /> </head> <body> <div class="document" id="regression-testing-for-epydoc-markup-pyval-repr"> <h1 class="title">Regression Testing for epydoc.markup.pyval_repr</h1> <blockquote> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-keyword">from</span> epydoc.markup.pyval_repr <span class="py-keyword">import</span> * <span class="py-prompt">>>> </span>colorizer = PyvalColorizer(linelen=40) <span class="py-prompt">>>> </span><span class="py-keyword">def</span> <span class="py-defname">color</span>(v, linebreakok=True): <span class="py-more">... </span> colorizer = PyvalColorizer(linelen=40, linebreakok=linebreakok) <span class="py-more">... </span> pds = colorizer.colorize(v, None) <span class="py-more">... </span> s = pds.to_html(None).rstrip() <span class="py-more">... </span> <span class="py-keyword">if</span> isinstance(s, unicode): <span class="py-more">... </span> s = s.encode(<span class="py-string">'ascii'</span>, <span class="py-string">'xmlcharrefreplace'</span>) <span class="py-more">... </span> <span class="py-keyword">print</span> s</pre> </blockquote> <div class="section" id="simple-types"> <h1>Simple Types</h1> <p>Integers, floats, None, and complex numbers get printed using str, with no syntax highlighting:</p> <blockquote> <pre class="py-doctest"> <span class="py-prompt">>>> </span>color(10) <span class="py-output">10</span> <span class="py-output"></span><span class="py-prompt">>>> </span>color(1./4) <span class="py-output">0.25</span> <span class="py-output"></span><span class="py-prompt">>>> </span>color(None) <span class="py-output">None</span> <span class="py-output"></span><span class="py-prompt">>>> </span>color(100) <span class="py-output">100</span></pre> </blockquote> <p>Long ints will get wrapped if they're big enough:</p> <blockquote> <pre class="py-doctest"> <span class="py-prompt">>>> </span>color(10000000) <span class="py-output">10000000</span> <span class="py-output"></span><span class="py-prompt">>>> </span>color(10**90) <span class="py-output">1000000000000000000000000000000000000000&crarr;</span> <span class="py-output">0000000000000000000000000000000000000000&crarr;</span> <span class="py-output">00000000000</span> <span class="py-output"></span><span class="py-prompt">>>> </span>colorizer = PyvalColorizer(linelen=40) <span class="py-prompt">>>> </span><span class="py-keyword">print</span> <span class="py-string">'-'</span>*40+<span class="py-string">'\n'</span>+colorizer.colorize(10**90).to_plaintext(None) <span class="py-output">----------------------------------------</span> <span class="py-output">1000000000000000000000000000000000000000\</span> <span class="py-output">0000000000000000000000000000000000000000\</span> <span class="py-output">00000000000</span></pre> </blockquote> </div> <div class="section" id="strings"> <h1>Strings</h1> <p>Strings have their quotation marks tagged as 'quote'. Characters are escaped using the 'string-escape' encoding.</p> <blockquote> <pre class="py-doctest"> <span class="py-prompt">>>> </span>color(<span class="py-string">''</span>.join([chr(i) <span class="py-keyword">for</span> i <span class="py-keyword">in</span> range(256)])) <span class="py-output"><code class="variable-quote">'''</code><code class="variable-string">\x00\x01\x02\x03\x04\x05\x06\x07\x08\</code>&crarr;</span> <span class="py-output"><code class="variable-string">t</code></span> <span class="py-output"><code class="variable-string">\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x</code>&crarr;</span> <span class="py-output"><code class="variable-string">15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x</code>&crarr;</span> <span class="py-output"><code class="variable-string">1f !&quot;#$%&amp;\'()*+,-./0123456789:;&lt;=&gt;?@ABCD</code>&crarr;</span> <span class="py-output"><code class="variable-ellipsis">...</code></span></pre> </blockquote> <p>Currently, the "'" quote is always used, because that's what the 'string-escape' encoding expects.</p> <blockquote> <pre class="py-doctest"> <span class="py-prompt">>>> </span>color(<span class="py-string">'Hello'</span>) <span class="py-output"><code class="variable-quote">'</code><code class="variable-string">Hello</code><code class="variable-quote">'</code></span> <span class="py-output"></span><span class="py-prompt">>>> </span>color(<span class="py-string">'"Hello"'</span>) <span class="py-output"><code class="variable-quote">'</code><code class="variable-string">&quot;Hello&quot;</code><code class="variable-quote">'</code></span> <span class="py-output"></span><span class="py-prompt">>>> </span>color(<span class="py-string">"'Hello'"</span>) <span class="py-output"><code class="variable-quote">'</code><code class="variable-string">\'Hello\'</code><code class="variable-quote">'</code></span></pre> </blockquote> <p>Strings containing newlines are automatically rendered as multiline strings.</p> <blockquote> <pre class="py-doctest"> <span class="py-prompt">>>> </span>color(<span class="py-string">"This\n is a multiline\n string!"</span>) <span class="py-output"><code class="variable-quote">'''</code><code class="variable-string">This</code></span> <span class="py-output"><code class="variable-string"> is a multiline</code></span> <span class="py-output"><code class="variable-string"> string!</code><code class="variable-quote">'''</code></span></pre> </blockquote> <p>Unless we ask for them not to be:</p> <blockquote> <pre class="py-doctest"> <span class="py-prompt">>>> </span>color(<span class="py-string">"This\n is a multiline\n string!"</span>, linebreakok=False) <span class="py-output"><code class="variable-quote">'</code><code class="variable-string">This\n is a multiline\n string!</code><code class="variable-quote">'</code></span></pre> </blockquote> <p>Unicode strings are handled properly.</p> <blockquote> <pre class="py-doctest"> <span class="py-prompt">>>> </span>color(u<span class="py-string">"Hello world"</span>) <span class="py-output"><code class="variable-quote">u'</code><code class="variable-string">Hello world</code><code class="variable-quote">'</code></span> <span class="py-output"></span><span class="py-prompt">>>> </span>color(u<span class="py-string">"\uaaaa And \ubbbb"</span>) <span class="py-output"><code class="variable-quote">u'</code><code class="variable-string">&#43690; And &#48059;</code><code class="variable-quote">'</code></span></pre> </blockquote> </div> <div class="section" id="lists-tuples-etc"> <h1>Lists, Tuples, etc.</h1> <p>Lists, tuples, and sets are all colorized using the same method. The braces and commas are tagged with "op". If the value can fit on the current line, it is displayed on one line. Otherwise, each value is listed on a separate line, indented by the size of the open-bracket.</p> <blockquote> <pre class="py-doctest"> <span class="py-prompt">>>> </span>color(range(10)) <span class="py-output"><code class="variable-group">[</code>0<code class="variable-op">, </code>1<code class="variable-op">, </code>2<code class="variable-op">, </code>3<code class="variable-op">, </code>4<code class="variable-op">, </code>5<code class="variable-op">, </code>6<code class="variable-op">, </code>7<code class="variable-op">, </code>8<code class="variable-op">, </code>9<code class="variable-group">]</code></span> <span class="py-output"></span><span class="py-prompt">>>> </span>color(range(100)) <span class="py-output"><code class="variable-group">[</code>0<code class="variable-op">,</code></span> <span class="py-output"> 1<code class="variable-op">,</code></span> <span class="py-output"> 2<code class="variable-op">,</code></span> <span class="py-output"> 3<code class="variable-op">,</code></span> <span class="py-output"> 4<code class="variable-op">,</code></span> <span class="py-output"><code class="variable-ellipsis">...</code></span> <span class="py-output"></span><span class="py-prompt">>>> </span>color([1,2,[5,6,[(11,22,33),9],10],11]+[99,98,97,96,95]) <span class="py-output"><code class="variable-group">[</code>1<code class="variable-op">,</code></span> <span class="py-output"> 2<code class="variable-op">,</code></span> <span class="py-output"> <code class="variable-group">[</code>5<code class="variable-op">, </code>6<code class="variable-op">, </code><code class="variable-group">[</code><code class="variable-group">(</code>11<code class="variable-op">, </code>22<code class="variable-op">, </code>33<code class="variable-group">)</code><code class="variable-op">, </code>9<code class="variable-group">]</code><code class="variable-op">, </code>10<code class="variable-group">]</code><code class="variable-op">,</code></span> <span class="py-output"> 11<code class="variable-op">,</code></span> <span class="py-output"> 99<code class="variable-op">,</code></span> <span class="py-output"><code class="variable-ellipsis">...</code></span> <span class="py-output"></span><span class="py-prompt">>>> </span>color(set(range(20))) <span class="py-output"><code class="variable-group">set([</code>0<code class="variable-op">,</code></span> <span class="py-output"> 1<code class="variable-op">,</code></span> <span class="py-output"> 2<code class="variable-op">,</code></span> <span class="py-output"> 3<code class="variable-op">,</code></span> <span class="py-output"> 4<code class="variable-op">,</code></span> <span class="py-output"><code class="variable-ellipsis">...</code></span></pre> </blockquote> </div> <div class="section" id="dictionaries"> <h1>Dictionaries</h1> <p>Dicts are treated just like lists, except that the ":" is also tagged as "op".</p> <blockquote> <pre class="py-doctest"> <span class="py-prompt">>>> </span>color({1:33, 2:[1,2,3,{7:<span class="py-string">'oo'</span>*20}]}) <span class="py-output"><code class="variable-group">{</code>1<code class="variable-op">: </code>33<code class="variable-op">,</code></span> <span class="py-output"> 2<code class="variable-op">: </code><code class="variable-group">[</code>1<code class="variable-op">,</code></span> <span class="py-output"> 2<code class="variable-op">,</code></span> <span class="py-output"> 3<code class="variable-op">,</code></span> <span class="py-output"> <code class="variable-group">{</code>7<code class="variable-op">: </code><code class="variable-quote">'</code><code class="variable-string">oooooooooooooooooooooooooooooo</code>&crarr;</span> <span class="py-output"><code class="variable-ellipsis">...</code></span></pre> </blockquote> </div> <div class="section" id="regular-expressions"> <h1>Regular Expressions</h1> <blockquote> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-keyword">def</span> <span class="py-defname">textcontent</span>(elt): <span class="py-more">... </span> <span class="py-keyword">if</span> isinstance(elt, basestring): return elt <span class="py-more">... </span> <span class="py-keyword">else</span>: return <span class="py-string">''</span>.join([textcontent(c) <span class="py-keyword">for</span> c <span class="py-keyword">in</span> elt.children])</pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-keyword">import</span> re <span class="py-prompt">>>> </span><span class="py-keyword">def</span> <span class="py-defname">color_re</span>(s, check_roundtrip=True): <span class="py-more">... </span> colorizer = PyvalColorizer(linelen=55) <span class="py-more">... </span> val = colorizer.colorize(re.compile(s)) <span class="py-more">... </span> <span class="py-keyword">if</span> check_roundtrip: <span class="py-more">... </span> assert textcontent(val._tree)[13:-2] == s, val._tree <span class="py-more">... </span> <span class="py-keyword">print</span> val.to_html(None).rstrip()[13:-2]</pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-comment"># Literal characters</span> <span class="py-prompt">>>> </span>color_re(u<span class="py-string">'abc \t\r\n\f\v \xff \uffff'</span>, False) <span class="py-output">abc \t\r\n\f\v \xff \uffff</span> <span class="py-output"></span><span class="py-prompt">>>> </span>color_re(r'\.\^\$\\\*\+\?\{\}\[\]\|\(\)\<span class="py-string">''</span>) <span class="py-output">\.\^\$\\\*\+\?\{\}\[\]\|\(\)\'</span></pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-comment"># Any character & character classes</span> <span class="py-prompt">>>> </span>color_re(r<span class="py-string">".\d\D\s\S\w\W\A^$\b\B\Z"</span>) <span class="py-output">.\d\D\s\S\w\W\A^$\b\B\Z</span></pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-comment"># Branching</span> <span class="py-prompt">>>> </span>color_re(r<span class="py-string">"foo|bar"</span>) <span class="py-output">foo<code class="re-op">|</code>bar</span></pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-comment"># Character classes</span> <span class="py-prompt">>>> </span>color_re(r<span class="py-string">"[abcd]"</span>) <span class="py-output"><code class="re-group">[</code>abcd<code class="re-group">]</code></span></pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-comment"># Repeats</span> <span class="py-prompt">>>> </span>color_re(r<span class="py-string">"a*b+c{4,}d{,5}e{3,9}f?"</span>) <span class="py-output">a<code class="re-op">*</code>b<code class="re-op">+</code>c<code class="re-op">{4,}</code>d<code class="re-op">{,5}</code>e<code class="re-op">{3,9}</code>f<code class="re-op">?</code></span> <span class="py-output"></span><span class="py-prompt">>>> </span>color_re(r<span class="py-string">"a*?b+?c{4,}?d{,5}?e{3,9}?f??"</span>) <span class="py-output">a<code class="re-op">*?</code>b<code class="re-op">+?</code>c<code class="re-op">{4,}?</code>d<code class="re-op">{,5}?</code>e<code class="re-op">{3,9}?</code>f<code class="re-op">??</code></span></pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-comment"># Subpatterns</span> <span class="py-prompt">>>> </span>color_re(r<span class="py-string">"(foo (bar) | (baz))"</span>) <span class="py-output"><code class="re-group">(</code>foo <code class="re-group">(</code>bar<code class="re-group">)</code> <code class="re-op">|</code> <code class="re-group">(</code>baz<code class="re-group">)</code><code class="re-group">)</code></span> <span class="py-output"></span><span class="py-prompt">>>> </span>color_re(r<span class="py-string">"(?:foo (?:bar) | (?:baz))"</span>) <span class="py-output"><code class="re-group">(?:</code>foo <code class="re-group">(?:</code>bar<code class="re-group">)</code> <code class="re-op">|</code> <code class="re-group">(?:</code>baz<code class="re-group">)</code><code class="re-group">)</code></span> <span class="py-output"></span><span class="py-prompt">>>> </span>color_re(<span class="py-string">"(foo (?P<a>bar) | (?P<boop>baz))"</span>) <span class="py-output"><code class="re-group">(</code>foo <code class="re-group">(?P&lt;</code><code class="re-ref">a</code><code class="re-group">&gt;</code>bar<code class="re-group">)</code> <code class="re-op">|</code> <code class="re-group">(?P&lt;</code><code class="re-ref">boop</code><code class="re-group">&gt;</code>baz<code class="re-group">)</code><code class="re-group">)</code></span></pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-comment"># Group References</span> <span class="py-prompt">>>> </span>color_re(r<span class="py-string">"(...) and (\1)"</span>) <span class="py-output"><code class="re-group">(</code>...<code class="re-group">)</code> and <code class="re-group">(</code><code class="re-ref">\1</code><code class="re-group">)</code></span></pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-comment"># Ranges</span> <span class="py-prompt">>>> </span>color_re(r<span class="py-string">"[a-bp-z]"</span>) <span class="py-output"><code class="re-group">[</code>a<code class="re-op">-</code>bp<code class="re-op">-</code>z<code class="re-group">]</code></span> <span class="py-output"></span><span class="py-prompt">>>> </span>color_re(r<span class="py-string">"[^a-bp-z]"</span>) <span class="py-output"><code class="re-group">[</code><code class="re-op">^</code>a<code class="re-op">-</code>bp<code class="re-op">-</code>z<code class="re-group">]</code></span> <span class="py-output"></span><span class="py-prompt">>>> </span>color_re(r<span class="py-string">"[^abc]"</span>) <span class="py-output"><code class="re-group">[</code><code class="re-op">^</code>abc<code class="re-group">]</code></span></pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-comment"># Lookahead/behinds</span> <span class="py-prompt">>>> </span>color_re(r<span class="py-string">"foo(?=bar)"</span>) <span class="py-output">foo<code class="re-group">(?=</code>bar<code class="re-group">)</code></span> <span class="py-output"></span><span class="py-prompt">>>> </span>color_re(r<span class="py-string">"foo(?!bar)"</span>) <span class="py-output">foo<code class="re-group">(?!</code>bar<code class="re-group">)</code></span> <span class="py-output"></span><span class="py-prompt">>>> </span>color_re(r<span class="py-string">"(?<=bar)foo"</span>) <span class="py-output"><code class="re-group">(?&lt;=</code>bar<code class="re-group">)</code>foo</span> <span class="py-output"></span><span class="py-prompt">>>> </span>color_re(r<span class="py-string">"(?<!bar)foo"</span>) <span class="py-output"><code class="re-group">(?&lt;!</code>bar<code class="re-group">)</code>foo</span></pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-comment"># Flags</span> <span class="py-prompt">>>> </span>color_re(r<span class="py-string">"(?im)^Food"</span>) <span class="py-output"><code class="re-flags">(?im)</code>^Food</span> <span class="py-output"></span><span class="py-prompt">>>> </span>color_re(r<span class="py-string">"(?Limsx)^Food"</span>) <span class="py-output"><code class="re-flags">(?Limsx)</code>^Food</span> <span class="py-output"></span><span class="py-prompt">>>> </span>color_re(r<span class="py-string">"(?Limstux)^Food"</span>) <span class="py-output"><code class="re-flags">(?Limstux)</code>^Food</span> <span class="py-output"></span><span class="py-prompt">>>> </span>color_re(r<span class="py-string">"(?x)This is verbose"</span>, False) <span class="py-output"><code class="re-flags">(?x)</code>Thisisverbose</span></pre> </blockquote> </div> <div class="section" id="line-wrapping"> <h1>Line Wrapping</h1> <p>If a line goes beyond linelen, it is wrapped using <tt class="docutils literal"><span class="pre">&crarr;</span></tt> (which gets translated to <tt class="docutils literal"><span class="pre">\\</span></tt> by <cite>ParsedEpytextDocstring.to_plaintext()</cite>).</p> <blockquote> <pre class="py-doctest"> <span class="py-prompt">>>> </span>colorizer = PyvalColorizer(linelen=40) <span class="py-prompt">>>> </span><span class="py-keyword">print</span> colorizer.colorize(<span class="py-string">'x'</span>*100).to_plaintext(None) <span class="py-output">'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\</span> <span class="py-output">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\</span> <span class="py-output">xxxxxxxxxxxxxxxxxxxxx'</span></pre> </blockquote> <p>Check that the last line gets a <tt class="docutils literal"><span class="pre">&crarr;</span></tt> when maxlines is exceeded:</p> <blockquote> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-keyword">print</span> colorizer.colorize(<span class="py-string">'x'</span>*1000).to_plaintext(None) <span class="py-output">'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\</span> <span class="py-output">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\</span> <span class="py-output">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\</span> <span class="py-output">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\</span> <span class="py-output">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\</span> <span class="py-output">...</span></pre> </blockquote> <p>If linebreakok is False, then line wrapping gives an ellipsis instead:</p> <blockquote> <pre class="py-doctest"> <span class="py-prompt">>>> </span>colorizer = PyvalColorizer(linelen=40, linebreakok=False) <span class="py-prompt">>>> </span><span class="py-keyword">print</span> colorizer.colorize(<span class="py-string">'x'</span>*100).to_plaintext(None) <span class="py-output">'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...</span></pre> </blockquote> </div> <div class="section" id="representation-scores"> <h1>Representation Scores</h1> <p>When colorized representations are built, a score is computed evaluating how helpful the repr is. E.g., unhelpful values like <tt class="docutils literal"><span class="pre"><Foo</span> <span class="pre">instance</span> <span class="pre">at</span> <span class="pre">0x12345></span></tt> get low scores. Currently, the scoring algorithm is:</p> <ul class="simple"> <li>[+1] for each object colorized. When the colorizer recurses into a structure, this will add one for each element contained.</li> <li>[-5] when repr(obj) looks like <xyz instance at ...>, for any colorized object (including objects in structures).</li> <li>[-100] if repr(obj) raises an exception, for any colorized object (including objects in structures).</li> </ul> <p>The <tt class="docutils literal"><span class="pre">min_score</span></tt> arg to colorize can be used to set a cutoff-point for scores; if the score is too low, then <cite>PyvalColorizer.colorize</cite> will return <tt class="docutils literal"><span class="pre">None</span></tt>.</p> <blockquote> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-keyword">def</span> <span class="py-defname">color2</span>(v): <span class="py-more">... </span> colorizer = PyvalColorizer(linelen=40) <span class="py-more">... </span> pds = colorizer.colorize(v) <span class="py-more">... </span> <span class="py-keyword">print</span> <span class="py-string">'repr: %s'</span> % pds.to_plaintext(None) <span class="py-more">... </span> <span class="py-keyword">print</span> <span class="py-string">'score: %s (%s)'</span> % (pds.score, pds.score>0 <span class="py-keyword">and</span> <span class="py-string">'ok'</span> <span class="py-keyword">or</span> <span class="py-string">'bad'</span>)</pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-keyword">class</span> <span class="py-defname">A</span>: <span class="py-keyword">pass</span></pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span>color2(<span class="py-string">'hello'</span>) <span class="py-output">repr: 'hello'</span> <span class="py-output">score: 1 (ok)</span></pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span>color2([<span class="py-string">"hello"</span>, 123]) <span class="py-output">repr: ['hello', 123]</span> <span class="py-output">score: 3 (ok)</span></pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span>color2(A()) <span class="py-comment"># doctest: +ELLIPSIS</span> <span class="py-output">repr: <__builtin__.A instance at ...></span> <span class="py-output">score: -4 (bad)</span></pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span>color2([A()]) <span class="py-comment"># doctest: +ELLIPSIS</span> <span class="py-output">repr: [<__builtin__.A instance at ...>]</span> <span class="py-output">score: -3 (bad)</span></pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span>color2([A(),1,2,3,4,5,6]) <span class="py-comment"># doctest: +ELLIPSIS</span> <span class="py-output">repr: [<__builtin__.A instance at ...>,</span> <span class="py-output"> 1,</span> <span class="py-output"> 2,</span> <span class="py-output"> 3,</span> <span class="py-output"> 4,</span> <span class="py-output">...</span> <span class="py-output">score: 1 (ok)</span></pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span><span class="py-keyword">from</span> epydoc.test.util <span class="py-keyword">import</span> print_warnings <span class="py-prompt">>>> </span>print_warnings()</pre> </blockquote> </div> <div class="section" id="summary"> <h1>Summary</h1> <p>To generate summary-reprs, use maxlines=1 and linebreakok=False:</p> <blockquote> <pre class="py-doctest"> <span class="py-prompt">>>> </span>summarizer = PyvalColorizer(linelen=60, maxlines=1, linebreakok=False) <span class="py-prompt">>>> </span><span class="py-keyword">def</span> <span class="py-defname">summarize</span>(v): <span class="py-more">... </span> <span class="py-keyword">print</span> summarizer.colorize(v).to_plaintext(None)</pre> <pre class="py-doctest"> <span class="py-prompt">>>> </span>summarize(range(100)) <span class="py-output">[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16...</span> <span class="py-output"></span><span class="py-prompt">>>> </span>summarize(<span class="py-string">'hello\nworld'</span>) <span class="py-output">'hello\nworld'</span> <span class="py-output"></span><span class="py-prompt">>>> </span>summarize(<span class="py-string">'hello\nworld'</span>*100) <span class="py-output">'hello\nworldhello\nworldhello\nworldhello\nworldhello\nw...</span></pre> </blockquote> </div> </div> <table width="100%" class="navbox" cellpadding="1" cellspacing="0"> <tr> <a class="nav" href="../index.html"> <td align="center" width="20%" class="nav"> <a class="nav" href="../index.html"> Home</a></td></a> <a class="nav" href="../installing.html"> <td align="center" width="20%" class="nav"> <a class="nav" href="../installing.html"> Installing Epydoc</a></td></a> <a class="nav" href="../using.html"> <td align="center" width="20%" class="nav"> <a class="nav" href="../using.html"> Using Epydoc</a></td></a> <a class="nav" href="../epytext.html"> <td align="center" width="20%" class="nav"> <a class="nav" href="../epytext.html"> Epytext</a></td></a> <td align="center" width="20%" class="nav"> <A href="http://sourceforge.net/projects/epydoc"> <IMG src="../sflogo.png" width="88" height="26" border="0" alt="SourceForge" align="top"/></A></td> </tr> </table> </body> </html>