Skip to contentSkip to conversation

qapi2texi: Suppress unwanted commas in generated output

PATCH In review Stefan Weil 2 participants 2 messages Jan 22, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qapi2texi: Suppress unwanted commas in generated output

Parts of the code use #optional followed by a comma.

We don't want that comma to be part of the generated documentation, so remove it, too.

---

I added the generated documentation to https://qemu.weilnetz.de/doc/.

See https://qemu.weilnetz.de/doc/qemu-qmp-ref.html for an example of the output without this patch (look for ", net").

We could also remove the commas from the code, but I think that removing them programmatically is more robust (and also allows people placing commas as they like).

Regards
Stefan

 scripts/qapi2texi.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/qapi2texi.py +1 -1
index 83ded95c2d..65c4aecfaf 100755
@@ -146,7 +146,7 @@ def texi_body(doc):
             desc = str(section)
             opt = ''
             if "#optional" in desc:
-                desc = desc.replace("#optional", "")
+                desc = re.sub("#optional,?", "", desc)
                 opt = ' (optional)'
             body += "@item @code{'%s'}%s\n%s\n" % (arg, opt,
                                                    texi_format(desc))
Signature · 1 line
2.11.0
#1 lore raw

Hi

Quoted 8 lines · Stefan Weil

Parts of the code use #optional followed by a comma.

We don't want that comma to be part of the generated documentation, so remove it, too.

---

Quoted 9 lines

I added the generated documentation to https://qemu.weilnetz.de/doc/.

See https://qemu.weilnetz.de/doc/qemu-qmp-ref.html for an example of the output without this patch (look for ", net").

We could also remove the commas from the code, but I think that removing them programmatically is more robust (and also allows people placing commas as they like).

Sometime there is also a - : @ipv6: #optional - force the use of ipv6

I think I would rather fix the doc. Making the parser/generator more subtle will also be harder to document or change later on.

Quoted 23 lines

Regards
Stefan

 scripts/qapi2texi.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/qapi2texi.py +1 -2
index 83ded95c2d..65c4aecfaf 100755
@@ -146,7 +146,7 @@ def texi_body(doc):
             desc = str(section)
             opt = ''
             if "#optional" in desc:
-                desc = desc.replace("#optional", "")
+                desc = re.sub("#optional,?", "", desc)
                 opt = ' (optional)'
             body += "@item @code{'%s'}%s\n%s\n" % (arg, opt,
                                                    texi_format(desc))
--

2.11.0

Quoted 1 line

--

Marc-André Lureau