code: def script_and_notebook_to_rst(spth, npth, rpth):
      
  
      # Read entire text of script at spth
      with open(spth) as f:
          stxt = f.read()
      # Process script text
      stxt = preprocess_script_string(stxt)
      # Convert script text to notebook object
      nbs = script_string_to_notebook_object(stxt)
  
      # Read notebook file npth
      nbn = nbformat.read(npth, as_version=4)
  
      # Overwrite markdown cells in nbn with those from nbs
      try:
          replace_markdown_cells(nbs, nbn)
      except ValueError:
          raise ValueError('mismatch between source script %s and notebook %s' %
                           (spth, npth))
  
      # Convert notebook object to rst
      notebook_object_to_rst(nbn, rpth)
docs: Convert a script and the corresponding executed notebook to rst.
      The script is converted to notebook format *without* replacement
      of sphinx cross-references with links to online docs, and the
      resulting markdown cells are inserted into the executed notebook,
      which is then converted to rst.