breathe-doc / breathe

ReStructuredText and Sphinx bridge to Doxygen
https://breathe-doc.org
Other
741 stars 198 forks source link

Warning and Note blocks are rendered out of order #889

Open HappyCerberus opened 1 year ago

HappyCerberus commented 1 year ago

I'm not 100% sure whether this is an issue with Breathe or Sphinx itself, but:

/** \brief A custom type

This is a longer description for a custom type.

\verbatim embed:rst
Some extended information:

.. warning::

    This is a warning.

An inline example for MyType.

.. code-block:: cpp
    :linenos:

    MyType x;
    x.foo();

\endverbatim
*/
struct MyType {
    /** \brief Do a lot of foo */
    void foo();
};

With the following Restructured text:

.. doxygenstruct:: MyType

Will generate the following output:

The warning block is ordered after the code block. You can also see it in action here: https://simontoth.eu/modern-documentation/other.html

michaeljones commented 1 year ago

Thanks for providing a good description fo the issue along with examples.

I don't think we do anything special with the embed:rst stuff. I can't imagine us reordering things. I guess it might be something do with the nodes that can generated and maybe one node is considered to be an invalid child for another one and so is somehow bumped to the end of it or something.

I'm afraid we don't have the resources to support this project super well at the moment but it is something we can look into when we have time.

intelkevinputnam commented 1 year ago

I haven't dived fully into the code yet, but I think I know the basics of what is going on here. Notes and Warnings appear as <simplesect kind="note"> and <simplesect kind="warning"> in the Doxygen xml. All simplesects are gathered together in the Breathe parser and then rendered together (likely at the end of the output) in the Breathe renderer. This is what I see in Docutils xml.

This explains the behavior, which I am seeing where all the notes and warnings appear together out of context at the end of the Breathe output:

image

Time permitting, I'll put together a PR soon.

intelkevinputnam commented 1 year ago

Sorry, I spoke too soon, not being familiar with how Verbatim works. My case is different as the warnings and notes are generated from Markdown content and rendered into Doxygen XML as noted above. It looks like verbatim XML elements should remain in context. I'll look at both cases as I work through this.

intelkevinputnam commented 1 year ago

So completely wrong with my guess. The culprit for both problems is sphinxrenderer.py lines 889 and 890:

            pullup(candNode, nodes.note, admonitions)
            pullup(candNode, nodes.warning, admonitions)
intelkevinputnam commented 1 year ago

Is there a reason that this would be a good idea, since it appears to be on purpose?

vermeeren commented 1 year ago

Is there a reason that this would be a good idea, since it appears to be on purpose?

For future reference, I replied in PR https://github.com/breathe-doc/breathe/pull/910#issuecomment-1531640467.

cjdb commented 1 year ago

This also happens for inline tables.

:this will: appear out of order like a note
2bndy5 commented 3 months ago

This seems related to #835, but I was focused on the doxygenpage directive's output. Also, I didn't describe the process to reproduce as well 👍🏼