Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning and Note blocks are rendered out of order #889

Open
HappyCerberus opened this issue Feb 17, 2023 · 8 comments
Open

Warning and Note blocks are rendered out of order #889

HappyCerberus opened this issue Feb 17, 2023 · 8 comments

Comments

@HappyCerberus
Copy link

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
Copy link
Collaborator

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
Copy link
Contributor

intelkevinputnam commented Apr 27, 2023

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
Copy link
Contributor

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
Copy link
Contributor

intelkevinputnam commented Apr 27, 2023

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
Copy link
Contributor

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

@vermeeren
Copy link
Collaborator

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 #910 (comment).

@cjdb
Copy link

cjdb commented May 15, 2023

This also happens for inline tables.

:this will: appear out of order like a note

@2bndy5
Copy link
Contributor

2bndy5 commented Mar 25, 2024

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 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants