Skip to content

Commit 4d7d30b

Browse files
jnsnowMarkus Armbruster
authored andcommitted
qapi/parser: add undocumented stub members to all_sections
Parser and doc generator cooperate on generating stub documentation for undocumented members. The parser makes up an ArgSection with an empty description, and the doc generator makes up a description. Right now, the made-up ArgSections go into doc.args. However, the new doc generator uses .all_sections, not .args. So put them into .all_sections, too. Insert them right after existing 'member' sections. If there are none, insert directly after the leading section. Doesn't affect the old generator, because that one doesn't use .all_sections. Signed-off-by: John Snow <[email protected]> Message-ID: <[email protected]> Reviewed-by: Markus Armbruster <[email protected]> [Commit message rewritten] Signed-off-by: Markus Armbruster <[email protected]>
1 parent 565274d commit 4d7d30b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

scripts/qapi/parser.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,8 +789,23 @@ def connect_member(self, member: 'QAPISchemaMember') -> None:
789789
raise QAPISemError(member.info,
790790
"%s '%s' lacks documentation"
791791
% (member.role, member.name))
792-
self.args[member.name] = QAPIDoc.ArgSection(
792+
# Insert stub documentation section for missing member docs.
793+
# TODO: drop when undocumented members are outlawed
794+
795+
section = QAPIDoc.ArgSection(
793796
self.info, QAPIDoc.Kind.MEMBER, member.name)
797+
self.args[member.name] = section
798+
799+
# Determine where to insert stub doc - it should go at the
800+
# end of the members section(s), if any. Note that index 0
801+
# is assumed to be an untagged intro section, even if it is
802+
# empty.
803+
index = 1
804+
if len(self.all_sections) > 1:
805+
while self.all_sections[index].kind == QAPIDoc.Kind.MEMBER:
806+
index += 1
807+
self.all_sections.insert(index, section)
808+
794809
self.args[member.name].connect(member)
795810

796811
def connect_feature(self, feature: 'QAPISchemaFeature') -> None:

0 commit comments

Comments
 (0)