[PATCH 1/7] qapi: make since sections special WIP

Markus Armbruster posted 7 patches 6 months, 3 weeks ago
Maintainers: Markus Armbruster <armbru@redhat.com>, Michael Roth <michael.roth@amd.com>, Peter Maydell <peter.maydell@linaro.org>, Eric Blake <eblake@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Gonglei (Arei)" <arei.gonglei@huawei.com>, Zhenwei Pi <pizhenwei@bytedance.com>, John Snow <jsnow@redhat.com>, Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Jason Wang <jasowang@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>, Jiri Pirko <jiri@resnulli.us>, Stefan Berger <stefanb@linux.vnet.ibm.com>, Stefan Hajnoczi <stefanha@redhat.com>, Mads Ynddal <mads@ynddal.dk>, Lukas Straub <lukasstraub2@web.de>, Konstantin Kostiuk <kkostiuk@redhat.com>
[PATCH 1/7] qapi: make since sections special WIP
Posted by Markus Armbruster 6 months, 3 weeks ago
since moves to end in generated output
---
 docs/sphinx/qapidoc.py         | 22 +++++++++++++++++-----
 scripts/qapi/parser.py         |  5 +++--
 tests/qapi-schema/test-qapi.py |  2 ++
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/docs/sphinx/qapidoc.py b/docs/sphinx/qapidoc.py
index 8d428c64b0..ac81003f0e 100644
--- a/docs/sphinx/qapidoc.py
+++ b/docs/sphinx/qapidoc.py
@@ -250,6 +250,13 @@ def _nodes_for_features(self, doc):
         section += dlnode
         return [section]
 
+    def _nodes_for_since(self, doc):
+        if doc.since:
+            section = self._make_section('Since')
+            self._parse_text_into_node(doc.since.text, section)
+            return [section]
+        return []
+
     def _nodes_for_example(self, exampletext):
         """Return list of doctree nodes for a code example snippet"""
         return [nodes.literal_block(exampletext, exampletext)]
@@ -305,7 +312,8 @@ def visit_enum_type(self, name, info, ifcond, features, members, prefix):
                       self._nodes_for_enum_values(doc)
                       + self._nodes_for_features(doc)
                       + self._nodes_for_sections(doc)
-                      + self._nodes_for_if_section(ifcond))
+                      + self._nodes_for_if_section(ifcond)
+                      + self._nodes_for_since(doc))
 
     def visit_object_type(self, name, info, ifcond, features,
                           base, members, variants):
@@ -316,7 +324,8 @@ def visit_object_type(self, name, info, ifcond, features,
                       self._nodes_for_members(doc, 'Members', base, variants)
                       + self._nodes_for_features(doc)
                       + self._nodes_for_sections(doc)
-                      + self._nodes_for_if_section(ifcond))
+                      + self._nodes_for_if_section(ifcond)
+                      + self._nodes_for_since(doc))
 
     def visit_alternate_type(self, name, info, ifcond, features, variants):
         doc = self._cur_doc
@@ -324,7 +333,8 @@ def visit_alternate_type(self, name, info, ifcond, features, variants):
                       self._nodes_for_members(doc, 'Members')
                       + self._nodes_for_features(doc)
                       + self._nodes_for_sections(doc)
-                      + self._nodes_for_if_section(ifcond))
+                      + self._nodes_for_if_section(ifcond)
+                      + self._nodes_for_since(doc))
 
     def visit_command(self, name, info, ifcond, features, arg_type,
                       ret_type, gen, success_response, boxed, allow_oob,
@@ -335,7 +345,8 @@ def visit_command(self, name, info, ifcond, features, arg_type,
                                                 arg_type if boxed else None)
                       + self._nodes_for_features(doc)
                       + self._nodes_for_sections(doc)
-                      + self._nodes_for_if_section(ifcond))
+                      + self._nodes_for_if_section(ifcond)
+                      + self._nodes_for_since(doc))
 
     def visit_event(self, name, info, ifcond, features, arg_type, boxed):
         doc = self._cur_doc
@@ -344,7 +355,8 @@ def visit_event(self, name, info, ifcond, features, arg_type, boxed):
                                                 arg_type if boxed else None)
                       + self._nodes_for_features(doc)
                       + self._nodes_for_sections(doc)
-                      + self._nodes_for_if_section(ifcond))
+                      + self._nodes_for_if_section(ifcond)
+                      + self._nodes_for_since(doc))
 
     def symbol(self, doc, entity):
         """Add documentation for one symbol to the document tree
diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index 7b13a583ac..0237d13da9 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -646,7 +646,7 @@ def __init__(self, info: QAPISourceInfo, symbol: Optional[str] = None):
         self.errors: Optional[QAPIDoc.Section] = None
         # "Since" section
         self.since: Optional[QAPIDoc.Section] = None
-        # sections other than .body, .args, .features
+        # sections other than .body, .args, .features, .since
         self.sections: List[QAPIDoc.Section] = []
 
     def end(self) -> None:
@@ -683,7 +683,8 @@ def new_tagged_section(self, info: QAPISourceInfo, tag: str) -> None:
                 raise QAPISemError(
                     info, "duplicated '%s' section" % tag)
             self.since = section
-        self.sections.append(section)
+        if tag != 'Since':
+            self.sections.append(section)
         self.all_sections.append(section)
 
     def _new_description(self, info: QAPISourceInfo, name: str,
diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
index 40095431ae..642daa29a4 100755
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -131,6 +131,8 @@ def test_frontend(fname):
             print('    feature=%s\n%s' % (feat, section.text))
         for section in doc.sections:
             print('    section=%s\n%s' % (section.tag, section.text))
+        if doc.since:
+            print('    section=%s\n%s' % (doc.since.tag, doc.since.text))
 
 
 def open_test_result(dir_name, file_name, update):
-- 
2.44.0
Re: [PATCH 1/7] qapi: make since sections special WIP
Posted by Markus Armbruster 6 months, 3 weeks ago
Markus Armbruster <armbru@redhat.com> writes:

> since moves to end in generated output

Sent by accident, please ignore.
Re: [PATCH 1/7] qapi: make since sections special WIP
Posted by Philippe Mathieu-Daudé 6 months, 3 weeks ago
On 6/5/24 13:02, Markus Armbruster wrote:
> since moves to end in generated output
> ---
>   docs/sphinx/qapidoc.py         | 22 +++++++++++++++++-----
>   scripts/qapi/parser.py         |  5 +++--
>   tests/qapi-schema/test-qapi.py |  2 ++
>   3 files changed, 22 insertions(+), 7 deletions(-)

Alternatively use git-publish to send pull requests :)

$ git publish --pull-request --sign-pull

https://github.com/stefanha/git-publish/blob/master/git-publish.pod
Re: [PATCH 1/7] qapi: make since sections special WIP
Posted by Markus Armbruster 6 months, 3 weeks ago
Philippe Mathieu-Daudé <philmd@linaro.org> writes:

> On 6/5/24 13:02, Markus Armbruster wrote:
>> since moves to end in generated output
>> ---
>>   docs/sphinx/qapidoc.py         | 22 +++++++++++++++++-----
>>   scripts/qapi/parser.py         |  5 +++--
>>   tests/qapi-schema/test-qapi.py |  2 ++
>>   3 files changed, 22 insertions(+), 7 deletions(-)
>
> Alternatively use git-publish to send pull requests :)

Touché; I'm a troglodyte ;)

> $ git publish --pull-request --sign-pull
>
> https://github.com/stefanha/git-publish/blob/master/git-publish.pod