Thanks for the resolve_references() in environment.py hint. I followed
that
code and inserted my own references. Unfortunately the docutils/
writers/html4css1/__init__.py
chokes on that. The assertion below fails:

    def visit_reference(self, node):
        atts = {'class': 'reference'}
        if node.has_key('refuri'):
            atts['href'] = node['refuri']
            if ( self.settings.cloak_email_addresses
                 and atts['href'].startswith('mailto:')):
                atts['href'] = self.cloak_mailto(atts['href'])
                self.in_mailto = 1
            atts['class'] += ' external'
        else:
            assert node.has_key('refid'), \
                   'References must have "refuri" or "refid"
attribute.'
            atts['href'] = '#' + node['refid']
            atts['class'] += ' internal'
        if not isinstance(node.parent, nodes.TextElement):
--->            assert len(node) == 1 and isinstance(node[0],
nodes.image) <--- This one fails
            atts['class'] += ' image-reference'
        self.body.append(self.starttag(node, 'a', '', **atts))

I tried to set the parent node of the reference node manually, but
somehow it gets replaced.
If I use the debugger an print node at that position I get:

p node.parent
<section "todo list":
<title...><paragraph...><todoNode...><reference...><todo ...>

Here is how I construct the reference in the process_todolist
callback:

r = []
for (docname, todoNode, target) in env.all_todos:

    newnode = nodes.reference('', '')
    innernode = nodes.emphasis("Dummy", "Dummy")
    newnode['refdocname'] = docname
    newnode['refuri'] = "../not/yet/correct/TBD#soon"
    newnode.append(innernode)
    r += [newnode, todoNode.deepcopy()]
node.replace_self(r)

I basically copied that from environment.py . Did I miss something
there? Any ideas?

Cheers, Daniel

On Nov 9, 12:02 pm, Georg Brandl <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] schrieb:
>
> > Thanks for your quick help. I managed to make todos show up as 'Todo:
> > content of todo'. It
> > did not work by simply putting 'Todo' in the argument list. It showed
> > up then as 'Note: Todo:'.
> > I needed to create a new node type 'todoNode' and add appropriate
> > visitors. The Sphinx documentation
> > is not up to date I think, addNode does not take any visitor arguments
> > anymore, so I helped myself
> > by using setattr on the translator object. This did the job. Maybe
> > there is a better way?
>
> It is the other way around :) The visitor arguments are new in the tip,
> which will be 0.5 shortly, while you are using 0.4.3.
>
> > I manged to include a target node for each todo item, but I did not
> > find how to actually insert a
> > reference to these labels in the todolist. How is this done? I cannot
> > find the code that actually
> > generates the index pages.
>
> > I also collect all todo nodes at the environment object now.
>
> > I have put the current version here:
>
> >http://pastebin.com/m2b02f72b
>
> If you want to include references to the target nodes, you have to
> construct some reference nodes and let them point to the target nodes.
> You'll have to include the docname of the todo node in the entry in
> all_todos, and then best look into resolve_references() in environment.py
> how to get reference nodes.
>
> Some other minor comments:
>
> * there is still allTodos in class todolist.
> * the target node should come before the todo node in the return of
>   todo_directive().
> * the global "app" isn't needed AFAICS.
> * instead of setting tagname to the todo node, you can use
>   ``doctree.traverse(todoNode)``.
>
> cheers,
> Georg

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sphinx-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to