From: John Snow <[email protected]> In 43e7ad1a3fa5, I adjusted the insertion algorithm for inserting something after the "introduction" to cope with both the old and new syntax while we converted QAPI to the new syntax. There's a bug in that code that only shows up in a handful of cases and only when using the new syntax while this affordance/flex code is still enabled.
In the case that we do actually have a real bona-fide intro section, we want to insert directly after that real-deal intro section, not after any plaintext sections that may follow it. This code adjusts the temporary code to strongly prefer inserting after the actual intro section if it exists. Once again: once conversion is done, you will be delighted by how much of this ugly code goes away. Signed-off-by: John Snow <[email protected]> Message-ID: <[email protected]> Reviewed-by: Markus Armbruster <[email protected]> Signed-off-by: Markus Armbruster <[email protected]> --- scripts/qapi/parser.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 9e14c2f792..dcc04b2663 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -845,6 +845,14 @@ def _insert_after_intro( needed and ``_insert_near_kind(QAPIDoc.Kind.INTRO, ...)`` will be sufficient. """ + first = self.all_sections[0] + if first.text and first.kind == QAPIDoc.Kind.INTRO: + # First section is introduction and is non-empty: insert here. + # Rest assured all of this ugliness will very soon go away. + # Pinkie-swear. + self.all_sections.insert(1, section) + return + index = 0 for index, ref_section in enumerate(self.all_sections): if ref_section.kind.name in ("PLAIN", "INTRO"): -- 2.55.0
