code: def codestr2rst(codestr, lang='python', lineno=None):
      
      if lineno is not None:
          if LooseVersion(sphinx.__version__) >= '1.3':
              # Sphinx only starts numbering from the first non-empty line.
              blank_lines = codestr.count('\n', 0, -len(codestr.lstrip()))
              lineno = '   :lineno-start: {0}\n'.format(lineno + blank_lines)
          else:
              lineno = '   :linenos:\n'
      else:
          lineno = ''
      code_directive = "\n.. code-block:: {0}\n{1}\n".format(lang, lineno)
      indented_block = indent(codestr, ' ' * 4)
      return code_directive + indented_block
docs: Return reStructuredText code block from code string