def inline_all_toctrees(builder, docnameset, docname, tree, colorfunc, traversed):
 tree = tree.deepcopy()
 for toctreenode in tree.traverse(addnodes.toctree):
  newnodes = []
  includefiles = map(text_type, toctreenode['includefiles'])
  for includefile in includefiles:
   if (includefile not in traversed):
    try:
     traversed.append(includefile)
     logger.info((colorfunc(includefile) + ' '), nonl=1)
     subtree = inline_all_toctrees(builder, docnameset, includefile, builder.env.get_doctree(includefile), colorfunc, traversed)
     docnameset.add(includefile)
    except Exception:
     logger.warning('toctree contains ref to nonexisting file %r', includefile, location=docname)
    else:
     sof = addnodes.start_of_file(docname=includefile)
     sof.children = subtree.children
     for sectionnode in sof.traverse(nodes.section):
      if ('docname' not in sectionnode):
       sectionnode['docname'] = includefile
     newnodes.append(sof)
  toctreenode.parent.replace(toctreenode, newnodes)
 return tree

def inline_all_toctrees ( builder , docnameset , docname , tree , colorfunc , traversed ) : tree = tree . deepcopy ( ) for toctreenode in tree . traverse ( addnodes . toctree ) : newnodes = [ ] includefiles = map ( text_type , toctreenode [ 'includefiles' ] ) for includefile in includefiles : if ( includefile not in traversed ) : try : traversed . append ( includefile ) logger . info ( ( colorfunc ( includefile ) + ' ' ) , nonl = 1 ) subtree = inline_all_toctrees ( builder , docnameset , includefile , builder . env . get_doctree ( includefile ) , colorfunc , traversed ) docnameset . add ( includefile ) except Exception : logger . warning ( 'toctree contains ref to nonexisting file %r' , includefile , location = docname ) else : sof = addnodes . start_of_file ( docname = includefile ) sof . children = subtree . children for sectionnode in sof . traverse ( nodes . section ) : if ( 'docname' not in sectionnode ) : sectionnode [ 'docname' ] = includefile newnodes . append ( sof ) toctreenode . parent . replace ( toctreenode , newnodes ) return tree
inline all toctrees in the *tree* .