<s> """<STR_LIT>""" <EOL> __docformat__ = '<STR_LIT>' <EOL> from docutils import nodes <EOL> from docutils . transforms import Transform , TransformError <EOL> class CallBack ( Transform ) : <EOL> """<STR_LIT>""" <EOL> default_priority = <NUM_LIT> <EOL> def apply ( self ) : <EOL> pending = self . startnode <EOL> pending . details [ '<STR_LIT>' ] ( pending ) <EOL> pending . parent . remove ( pending ) <EOL> class ClassAttribute ( Transform ) : <EOL> """<STR_LIT>""" <EOL> default_priority = <NUM_LIT> <EOL> def apply ( self ) : <EOL> pending = self . startnode <EOL> parent = pending . parent <EOL> child = pending <EOL> while parent : <EOL> for index in range ( parent . index ( child ) + <NUM_LIT:1> , len ( parent ) ) : <EOL> element = parent [ index ] <EOL> if ( isinstance ( element , nodes . Invisible ) or <EOL> isinstance ( element , nodes . system_message ) ) : <EOL> continue <EOL> element [ '<STR_LIT>' ] += pending . details [ '<STR_LIT:class>' ] <EOL> pending . parent . remove ( pending ) <EOL> return <EOL> else : <EOL> child = parent <EOL> parent = parent . parent <EOL> error = self . document . reporter . error ( <EOL> '<STR_LIT>' <EOL> % pending . details [ '<STR_LIT>' ] , <EOL> nodes . literal_block ( pending . rawsource , pending . rawsource ) , <EOL> line = pending . line ) <EOL> pending . replace_self ( error ) <EOL> class Transitions ( Transform ) : <EOL> """<STR_LIT>""" <EOL> default_priority = <NUM_LIT> <EOL> def apply ( self ) : <EOL> for node in self . document . traverse ( nodes . transition ) : <EOL> self . visit_transition ( node ) <EOL> def visit_transition ( self , node ) : <EOL> index = node . parent . index ( node ) <EOL> error = None <EOL> if ( index == <NUM_LIT:0> or <EOL> isinstance ( node . parent [ <NUM_LIT:0> ] , nodes . title ) and <EOL> ( index == <NUM_LIT:1> or <EOL> isinstance ( node . parent [ <NUM_LIT:1> ] , nodes . subtitle ) and <EOL> index == <NUM_LIT:2> ) ) : <EOL> assert ( isinstance ( node . parent , nodes . document ) or <EOL> isinstance ( node . parent , nodes . section ) ) <EOL> error = self . document . reporter . error ( <EOL> '<STR_LIT>' , <EOL> line = node . line ) <EOL> elif isinstance ( node . parent [ index - <NUM_LIT:1> ] , nodes . transition ) : <EOL> error = self . document . reporter . error ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , line = node . line ) <EOL> if error : <EOL> node . parent . insert ( index , error ) <EOL> index += <NUM_LIT:1> <EOL> assert index < len ( node . parent ) <EOL> if index != len ( node . parent ) - <NUM_LIT:1> : <EOL> return <EOL> sibling = node <EOL> while index == len ( sibling . parent ) - <NUM_LIT:1> : <EOL> sibling = sibling . parent <EOL> if sibling . parent is None : <EOL> error = self . document . reporter . error ( <EOL> '<STR_LIT>' , <EOL> line = node . line ) <EOL> node . parent . insert ( node . parent . index ( node ) + <NUM_LIT:1> , error ) <EOL> return <EOL> index = sibling . parent . index ( sibling ) <EOL> node . parent . remove ( node ) <EOL> sibling . parent . insert ( index + <NUM_LIT:1> , node ) </s>
