On Tue, Oct 9, 2018 at 2:08 AM Noah Watkins  wrote:
>
> Hi,
>
> I'm working on a custom directive, and have made a lot of progress, but I'm 
> hitting a bit of a wall. My directive is fundamentally simple: I'm rendering 
> a source json file to table format. I've used other extensions as a reference 
> and have gotten this to work well.
>
> The problem I'm trying to solve now is resolving references (e.g. to section 
> labels, etc...) that are specified in the json source. I don't need to worry 
> about any internal references within the source.

If I understood correctly what you want to do, you can insert nodes of
the type "sphinx.addnodes.pending_xref" to your document.

http://www.sphinx-doc.org/en/master/extdev/nodes.html#sphinx.addnodes.pending_xref

The documentation is a bit sparse, those are the arguments I've used so far:

reftype='ref' or reftype='doc' or ...: the type of reference

reftarget='my-reference': the actual reference, e.g. a label or document name

refdomain='std': This is typically 'std', but there are other domains

refwarn=True, refexplicit=True: I don't remember what they do

refdoc=env.docname: I guess the name of the current doc, I've used
"env.docname".

> Unfortunately, I haven't been able to find any sample code that does this, to 
> use a model. The todo extension comes close: it seems to resolve references 
> within the todo items, but the extension itself is built quite differently, 
> and the resolution occurs after 'doctree-resolved' fires and uses custom 
> nodes etc...

I don't know if that helps, but I've created some labels and
references in my extension "nbsphinx":
https://github.com/spatialaudio/nbsphinx/blob/master/src/nbsphinx.py
Just search for "pending_xref".

cheers,
Matthias

> Any pointers or suggestions would be useful. Thanks.
>
> - Noah

-- 
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 sphinx-users+unsubscr...@googlegroups.com.
To post to this group, send email to sphinx-users@googlegroups.com.
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