Hi list,


I have the same problem as at 
http://stackoverflow.com/questions/33637299/modify-sphinx-toc-tree - I can 
read all the elements of a TOC, but cannot save these modifications back to 
the tree. 

I know I have to replace a node, but I need to resolve it to a TOC to fnd 
properties etc. 


Any help appreciated,


Seth




from sphinx import addnodes

def setup(app):

    def update_toctree(app, doctree, docname):

        if docname != 'index': # only run on the index page
            return

        for toctreenode in doctree.traverse(addnodes.toctree):
            all_nodes = []
            toc = app.env.resolve_toctree(docname, app.builder, toctreenode 
)
            bullet_list = toc.children[0]
            for list_item in bullet_list:
                paragraph = list_item.children[0] # 
sphinx.addnodes.compact_paragraph 
http://www.sphinx-doc.org/en/stable/extdev/nodes.html#sphinx.addnodes.compact_paragraph
                # 
http://epydoc.sourceforge.net/docutils/private/docutils.nodes.paragraph-class.html
 
         

                ref = paragraph.children[0]
                refuri = ref.get("refuri") # e.g. folder/page.html
                if refuri == 'example':

                    paragraph.set_class("video")

                list_item.replace_self(list_item)

            #toctreenode.replace_self()

    # connect to the doctree-resolved' event

    app.connect('doctree-resolved', update_toctree)


-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to