code: def get_rendered_toctree(builder, docname, prune=False, collapse=True):
      
      fulltoc = build_full_toctree(builder,
                                   docname,
                                   prune=prune,
                                   collapse=collapse,
                                   )
      rendered_toc = builder.render_partial(fulltoc)['fragment']
      return rendered_toc
docs: Build the toctree relative to the named document,
      with the given parameters, and then return the rendered
      HTML fragment.