@@ -0,0 +1,1734 @@
+%22%22%22%0AFixes the table of contents in singlehtml mode so that section titles have the%0Acorrect section number in front.%0A%22%22%22%0A%0Afrom docutils import nodes%0Afrom sphinx import addnodes%0A%0Adef stringize_secnum(secnum):%0A    return '.'.join(map(str, secnum))%0A%0Adef doctree_resolved(app, doctree, fromdocname):%0A    if app.builder.name == 'singlehtml':%0A        secnums = app.builder.env.toc_secnumbers%0A        for filenode in doctree.traverse(addnodes.start_of_file):%0A            docname = filenode%5B'docname'%5D%0A            if docname not in secnums:%0A                continue%0A            %0A            doc_secnums = secnums%5Bdocname%5D%0A            first_title_node = filenode.next_node(nodes.title)%0A            if first_title_node is not None and '' in doc_secnums:%0A                file_secnum = stringize_secnum(doc_secnums%5B''%5D)%0A                title_text_node = first_title_node.children%5B0%5D%0A                newtext = file_secnum + ' ' + title_text_node.astext()%0A                first_title_node.replace(title_text_node, nodes.Text(newtext))%0A            %0A            for section_node in filenode.traverse(nodes.section):%0A                for id in section_node%5B'ids'%5D:%0A                    if '#' + id in doc_secnums:%0A                        subsection_num = stringize_secnum(doc_secnums%5B'#' + id%5D)%0A                        first_title_node = section_node.next_node(nodes.title)%0A                        if first_title_node is not None:%0A                            title_text_node = first_title_node.children%5B0%5D%0A                            newtext = subsection_num + ' ' + title_text_node.astext()%0A                            first_title_node.replace(title_text_node, nodes.Text(newtext))%0A%0Adef setup(app):%0A    app.connect('doctree-resolved', doctree_resolved)%0A

Create singlehtml_toc.py