1

As part of a custom directive I am trying to support nested references. I have re-worked the todo example to demonstrate what I am looking for.

The complete repo is here:

https://github.com/martynp/sphinx_nested

The commit with the changes I would like to work are here:

https://github.com/martynp/sphinx_nested/commit/c973db1bbb4018306bea4b3fdd465c795ac1c1ec

Which makes someotherfile.rst:

bar
===

Some more text here... :ref:`foo reference`

.. todo:: Fix that :ref:`foo reference`

The error I get is:

preparing documents... done
/home/martyn/work/sphinx_example/someotherfile.rst:6: WARNING: unknown node type: <pending_xref: <inline...>>                                                                                                   

Exception occurred:
  File "/home/martyn/.local/lib/python3.10/site-packages/docutils/nodes.py", line 2040, in unknown_departure
    raise NotImplementedError(
NotImplementedError: <class 'sphinx.writers.html5.HTML5Translator'> departing unknown node type: pending_xref

I expect it might just be my lack of correct terminology limited my search result - but any help/pointers would be greatly appreciated.


More detail:

The error is being emitted because the process_todo_nodes method is being attached to doctree-resolved.

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

At this point I do not think there is a state which can be passed to nested_parser(...) to resolve the reference node.

Removing the above line runs without error.

MartynP
  • 11
  • 2
  • Link-based source code/info have risk of link going dead. Please provide enough source code, config or steps from link to reproduce/explain the problem. – Azhar Khan Jan 22 '23 at 08:19
  • Don't use spaces in ref names. – Steve Piercy Jan 22 '23 at 09:37
  • Any particular reason not to use spaces? Can't see restrictions in any documentation. – MartynP Jan 23 '23 at 10:49
  • What do you mean by "nested reference"? How exactly did you re-work the todo example (https://www.sphinx-doc.org/en/master/development/tutorials/todo.html#writing-the-extension)? – mzjn Jan 24 '23 at 18:37
  • I think a better description is nested role. I did no re-work to the Todo example, just added a :ref: role in the content of the Todo and get the above error. I used the nested word as it's the nested_parser call which handles the nested directive processing. – MartynP Jan 25 '23 at 19:14

0 Answers0