[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 04/32] qapi2texi: Fix for '@' not followed by \w
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [RFC PATCH 04/32] qapi2texi: Fix for '@' not followed by \w character |
Date: |
Mon, 2 Oct 2017 17:25:24 +0200 |
Signed-off-by: Markus Armbruster <address@hidden>
---
scripts/qapi2texi.py | 22 ++++++++++++----------
tests/qapi-schema/doc-good.json | 2 +-
tests/qapi-schema/doc-good.out | 2 +-
tests/qapi-schema/doc-good.texi | 2 +-
4 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
index 1500afc553..cfcd8a19f0 100755
--- a/scripts/qapi2texi.py
+++ b/scripts/qapi2texi.py
@@ -41,14 +41,17 @@ def subst_emph(doc):
return re.sub(r'\b_([^_\n]+)_\b', r'@emph{\1}', doc)
-def subst_vars(doc):
- """Replaces @var by @code{var}"""
- return re.sub(r'@([\w-]+)', r'@code{\1}', doc)
-
-
-def subst_braces(doc):
- """Replaces {} with @{ @}"""
- return doc.replace('{', '@{').replace('}', '@}')
+def subst_special(doc):
+ ret = ''
+ for m in re.finditer(r'(address@hidden)(@([-\w]*)|[{}])?', doc):
+ ret += m.group(1)
+ if m.group(3):
+ # format @NAME as @code{NAME}
+ ret += '@code{' + m.group(3) + '}'
+ elif m.group(2):
+ # escape Texinfo's special characters
+ ret += '@' + m.group(2)
+ return ret
def texi_example(doc):
@@ -71,8 +74,7 @@ def texi_format(doc):
- */-: generates an @itemize list
"""
ret = ''
- doc = subst_braces(doc)
- doc = subst_vars(doc)
+ doc = subst_special(doc)
doc = subst_emph(doc)
doc = subst_strong(doc)
inlist = ''
diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
index 54a0012d5f..274004a8b6 100644
--- a/tests/qapi-schema/doc-good.json
+++ b/tests/qapi-schema/doc-good.json
@@ -10,7 +10,7 @@
#
# *strong* _with emphasis_
# @var {in braces}
-# lone @ BUG: gets passed to Texinfo unescaped
+# lone @
# * List item one
# - Two, multiple
# lines
diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
index a62d2d879c..46261d5010 100644
--- a/tests/qapi-schema/doc-good.out
+++ b/tests/qapi-schema/doc-good.out
@@ -38,7 +38,7 @@ doc freeform
*strong* _with emphasis_
@var {in braces}
-lone @ BUG: gets passed to Texinfo unescaped
+lone @
* List item one
- Two, multiple
lines
diff --git a/tests/qapi-schema/doc-good.texi b/tests/qapi-schema/doc-good.texi
index 3b77f2f675..8777cbb7fb 100644
--- a/tests/qapi-schema/doc-good.texi
+++ b/tests/qapi-schema/doc-good.texi
@@ -4,7 +4,7 @@
@strong{strong} @emph{with emphasis}
@code{var} @{in address@hidden
-lone @ BUG: gets passed to Texinfo unescaped
+lone @@
@itemize @bullet
@item
List item one
--
2.13.6
- Re: [Qemu-devel] [RFC PATCH 02/32] texi2pod: Support @verbatim environment, (continued)
[Qemu-devel] [RFC PATCH 24/32] qapi-options: Generate help string, Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 18/32] docs/devel/qapi-code-gen.txt: Rewrite section on schema syntax, Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 16/32] qapi: Factor out _make_implicit_wrapper_type(), Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 01/32] tests/qapi-schema: Improve coverage of '@', Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 04/32] qapi2texi: Fix for '@' not followed by \w character,
Markus Armbruster <=
[Qemu-devel] [RFC PATCH 09/32] qapi: check_type() parameter allow_optional is now unused, drop, Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 13/32] qapi: Use argparse to open schema file, Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 06/32] qapi2texi: Drop | example markup, Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 29/32] qapi/options: QAPIfy --echr argument type, Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 32/32] qapi/options: QAPIfy --add-fd argument type, Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 22/32] qapi: New helper c_string(), Markus Armbruster, 2017/10/02
[Qemu-devel] [RFC PATCH 30/32] qapi/options: QAPIfy --watchdog-action argument type, Markus Armbruster, 2017/10/02