0

The following ReStructuredText contains the :ref: role, which is a Sphinx-extension:

Read more in :ref:`section-target`.

.. _section-target:

Section Title
=============
Text body.

Where

:ref:`section-target`

is parsed to the following doctree:

<reference internal="True" refid="section-target"><inline classes="std std-ref">Section Title</inline></reference>

You can reproduce this by storing the above reStructuredText into sphinx_input/index.rst and run sphinx-build -b xml -C sphinx_input sphinx_ouptut.

Is there an equivalent that I can use to generate this exact same doctree that only uses docutils restructuredtext? (Thus no Sphinx-specific roles or directives). I don't care about readability, since this will be machine-parsed only.

So far, the closest I got was:

`Section Title <section-target>`_

which resulted in:

<reference name="Section Title" refuri="section-target">Section Title</reference>

That's close, but it defines a refuri, not a refid.

Regretfully, the documentation of the reference doctree is missing.

MacFreek
  • 3,207
  • 2
  • 31
  • 41
  • How did you convert the doctree contents to human readable form? – bad_coder Feb 14 '21 at 21:59
  • @bad_coder: in this case the output is xml, but my question is what is the best input, not about the output. – MacFreek Feb 15 '21 at 07:56
  • Ok, but when I generate my doctress as usual I get the pickled file that is full of unreadable characters. I want to generate a readeable XML file like you are showing, that's why I'm asking. It would make it easier for me to answer the question. – bad_coder Feb 15 '21 at 11:33
  • @bad_coder. I added the command to reproduce in the question. Thanks for the suggestion. – MacFreek Feb 17 '21 at 16:52

0 Answers0