[Epydoc-commits] SF.net SVN: epydoc: [1652] trunk/epydoc/src/epydoc
Brought to you by:
edloper
From: <ed...@us...> - 2007-09-26 04:45:38
|
Revision: 1652 http://epydoc.svn.sourceforge.net/epydoc/?rev=1652&view=rev Author: edloper Date: 2007-09-25 21:45:34 -0700 (Tue, 25 Sep 2007) Log Message: ----------- - Fixed sf bug [ 1673017 ] Graphs are considered inline elements -- graphs are now 'raised' to an appropraite level after the dom tree is created. Modified Paths: -------------- trunk/epydoc/src/epydoc/markup/epytext.py trunk/epydoc/src/epydoc/test/epytext.doctest Modified: trunk/epydoc/src/epydoc/markup/epytext.py =================================================================== --- trunk/epydoc/src/epydoc/markup/epytext.py 2007-09-26 04:00:55 UTC (rev 1651) +++ trunk/epydoc/src/epydoc/markup/epytext.py 2007-09-26 04:45:34 UTC (rev 1652) @@ -316,6 +316,14 @@ "epytext string.") errors.append(StructuringError(estr, token.startline)) + # Graphs use inline markup (G{...}) but are really block-level + # elements; so "raise" any graphs we generated. This is a bit of + # a hack, but the alternative is to define a new markup for + # block-level elements, which I'd rather not do. (See sourceforge + # bug #1673017.) + for child in doc.children: + _raise_graphs(child, doc) + # If there was an error, then signal it! if len([e for e in errors if e.is_fatal()]) > 0: if raise_on_error: @@ -326,6 +334,32 @@ # Return the top-level epytext DOM element. return doc +def _raise_graphs(tree, parent): + # Recurse to children. + have_graph_child = False + for elt in tree.children: + if isinstance(elt, Element): + _raise_graphs(elt, tree) + if elt.tag == 'graph': have_graph_child = True + + block = ('section', 'fieldlist', 'field', 'ulist', 'olist', 'li') + if have_graph_child and tree.tag not in block: + child_index = 0 + for elt in tree.children: + if isinstance(elt, Element) and elt.tag == 'graph': + # We found a graph: splice it into the parent. + parent_index = parent.children.index(tree) + left = tree.children[:child_index] + right = tree.children[child_index+1:] + parent.children[parent_index:parent_index+1] = [ + Element(tree.tag, *left, **tree.attribs), + elt, + Element(tree.tag, *right, **tree.attribs)] + child_index = 0 + parent_index += 2 + else: + child_index += 1 + def _pop_completed_blocks(token, stack, indent_stack): """ Pop any completed blocks off the stack. This includes any Modified: trunk/epydoc/src/epydoc/test/epytext.doctest =================================================================== --- trunk/epydoc/src/epydoc/test/epytext.doctest 2007-09-26 04:00:55 UTC (rev 1651) +++ trunk/epydoc/src/epydoc/test/epytext.doctest 2007-09-26 04:45:34 UTC (rev 1652) @@ -315,4 +315,37 @@ >>> print epytext2html("{{E{lb}E{lb}E{lb}}}") <p>{{{{{}}</p> +Graph Raising +============= +>>> epytext._x = True +>>> print testparse(""" +... Para containing G{classtree} graph. +... """) +<para>Para containing </para> +<graph>classtree</graph> +<para> graph.</para> + +>>> print testparse(""" +... Para B{I{containing C{G{classtree} graph}} inside nested markup}. +... """) +<para>Para <bold><italic>containing <code></code></italic></bold> +</para> +<graph>classtree</graph> +<para><bold><italic><code> graph</code></italic> + inside nested markup</bold> +.</para> + +Should we strip the 'inline' from the paras in cases like this:? +>>> print testparse(""" +... - List item with G{classtree foo} graph. +... - And with I{nested G{callgraph: zippy} markup} too. +... """) +<ulist><li><para inline=True>List item with </para> +<graph>classtreefoo</graph> +<para inline=True> graph.</para></li> +<li><para inline=True>And with <italic>nested </italic> +</para> +<graph>callgraphzippy</graph> +<para inline=True><italic> markup</italic> + too.</para></li></ulist> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |