Hi, Hi, Thanks for your feedback - it's very helpful.
On Sat, Jan 8, 2011 at 6:36 PM, Georg Brandl <ge...@python.org> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 >> Second question: for obvious reasons I found I wanted to handle the >> missing-reference event, but the event parameters weren't enough to do >> what I wanted. Specifically, what I needed to do with the missing >> reference was (from sphinx/environment.py around 1343): >> >> newnode = make_refnode(builder, fromdocname, docname, >> labelid, contnode) >> >> but, the missing-reference event only gives me:: >> >> missing-reference(app, env, node, contnode) >> >> I can get the builder, and docname and labelid, and I've been passed >> the contnode, but there does not appear to be a way to get the >> 'fromdocname' that I needed. I think that's the same as for this >> post: >> >> http://www.mail-archive.com/sphinx-dev@googlegroups.com/msg01895.html > > Oh, indeed. Originally, missing-reference was designed for the intersphinx > extension, which doesn't need fromdocname since it returns an absolute URI > to another site. > > I can fix this for 1.1 by adding more arguments to missing-reference, which > will be an incompatibility but a necessary one, since there aren't so many > uses for the missing-reference as it is now anyway. That would be very good. >> In the end I resorted to this - hack: >> >> def doctree_read(app, doctree): >> """ Give each pending citation its docname """ >> for pref in doctree.traverse(addnodes.pending_xref): >> if pref['reftype'] != 'citation': >> continue >> pref['docname'] = app.env.docname >> >> I wanted ask whether there is a better way to do this? > > Unfortunately, this isn't perfectly correct either, since the fromdocname > isn't always the document in which the reference node occurs. This problem > occurs in builders that lump together nodes from multiple source files, > like the "singlehtml" builder. I suspected as much. So would it be fair to say that there is currently no way of doing what I need to do other than modifying the sphinx source or monkeypatching? >> Lastly, I noticed that the code still raises a warning that it didn't >> find my citations, even when the missing-reference event returned a >> citation, because of the code around 1340 in environment.py in my >> version. Would you be interested in a patch to defer this warning >> until after checking the missing-reference? > > I've only recently refactored this code for Sphinx 1.1, and there the > warning shouldn't occur. Excellent - thanks a lot, Matthew -- You received this message because you are subscribed to the Google Groups "sphinx-dev" group. To post to this group, send email to sphinx-...@googlegroups.com. To unsubscribe from this group, send email to sphinx-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sphinx-dev?hl=en.