Hi, Bingo! Sphinx uses the pending_xref nodes to realize the cross-reference feature.
Please try to make a node that refers python class like this: ``` node = sphinx.addnodes.pending_xref(refdomain='py', reftype='class', reftarget='stringio.StringIO') node += nodes.Text('stringio.StringIO) ``` The pending_xref node should have three attributes: * refdomain: domain of the reference. For python objects, please set 'py'. * reftype: type of the python object. * reftarget: name of the python object. All you should do is only generating pending_xref node. It will be converted to a cross-reference automatically on the latter step of Sphinx. Please try this in your code. Thanks, Takeshi KOMIYA 2020年12月10日(木) 5:54 Nic30 <nic30origi...@gmail.com>: > > > Basicaly I am trying to generate reference element to a class. > > I am able to get a class object in `Directive.run()` which I want to > reference in documentation. > Currently I am using `sphinx.util.typing.stringify` to get a string and then > returning `docutils.nodes.Text` > > I would like to create href in html documentation which redirects the browser > to the type definition. > > I guess I should use > https://www.sphinx-doc.org/en/master/extdev/nodes.html#sphinx.addnodes.pending_xref > > But I am not sure how or if it is a good idea. I can always craft the link > manually as shown in > https://www.sphinx-doc.org/en/master/development/tutorials/todo.html > Is there a better way? > > I guess that the apidoc or other extensions needs to have function just for > this but I just can't see it. > > Any hit appreciated. > > https://github.com/Nic30/sphinx-hwt/blob/master/sphinx_hwt/directive_params.py#L80 > > -- > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/sphinx-users/f5079d3e-14c5-4966-b33f-d7bc94973b98n%40googlegroups.com. -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/CAFmkQAMb-SrNG7LhwvY0h%3Dk-RxLuF_FUwrY8mequSJw18ZafDg%40mail.gmail.com.