def insert_doc(doc, new_items):
 doclist = doc.split(u'\n')
 tmpdoc = doclist[:2]
 tmpdoc.extend(new_items)
 tmpdoc.extend(doclist[2:])
 newdoc = []
 for line in tmpdoc:
  newdoc.append(line)
  newdoc.append(u'\n')
 newdoc.pop((-1))
 return u''.join(newdoc)

def insert_doc ( doc , new_items ) : doclist = doc . split ( u'\n' ) tmpdoc = doclist [ : 2 ] tmpdoc . extend ( new_items ) tmpdoc . extend ( doclist [ 2 : ] ) newdoc = [ ] for line in tmpdoc : newdoc . append ( line ) newdoc . append ( u'\n' ) newdoc . pop ( ( - 1 ) ) return u'' . join ( newdoc )
insert new_items into the beginning of the doc docstrings in new_items will be inserted right after the *parameters* header but before the existing docs .