def codestr2rst(codestr, lang='python'):
 code_directive = '\n.. code-block:: {0}\n\n'.format(lang)
 indented_block = indent(codestr, (' ' * 4))
 return (code_directive + indented_block)

def codestr2rst ( codestr , lang = 'python' ) : code_directive = '\n.. code-block:: {0}\n\n' . format ( lang ) indented_block = indent ( codestr , ( ' ' * 4 ) ) return ( code_directive + indented_block )
return restructuredtext code block from code string .