def METHOD_NAME(app, doctree, fromdocname):
    container = generate_sidebar(app, fromdocname)
    ctx = app.env.config['html_context']
    ctx['classlist'] = container
    for node in doctree.traverse(classlist):
        node.replace_self([container])
        continue