def METHOD_NAME(collapse=True, maxdepth=-1, includehidden=True, titles_only=False):
    if "page_source_suffix" in context and context["page_source_suffix"] == ".md":
        fromdocname = context["current_page_name"]
    else:
        fromdocname = "" if "title" not in context else context["title"]
    fulltoc = generate_sidebar(app, fromdocname)
    rendered_toc = app.builder.render_partial(fulltoc)['fragment']
    return rendered_toc