[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 05/47] qapi/doc.py: Change code templates from function to str
From: |
John Snow |
Subject: |
[PATCH v3 05/47] qapi/doc.py: Change code templates from function to string |
Date: |
Thu, 24 Sep 2020 20:28:18 -0400 |
For whatever reason, when these are stored as functions instead of
strings, it confuses sphinx-autodoc into believing them to be
docstrings, and it chokes on the syntax.
Keeping them as dumb strings instead avoids the problem.
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/qapi/doc.py | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py
index c41e9d29f5..d12eda9e1e 100644
--- a/scripts/qapi/doc.py
+++ b/scripts/qapi/doc.py
@@ -8,26 +8,26 @@
from qapi.gen import QAPIGenDoc, QAPISchemaVisitor
-MSG_FMT = """
+_MSG = '''
@deftypefn {type} {{}} {name}
{body}{members}{features}{sections}
@end deftypefn
-""".format
+'''
-TYPE_FMT = """
+_TYPE = '''
@deftp {{{type}}} {name}
{body}{members}{features}{sections}
@end deftp
-""".format
+'''
-EXAMPLE_FMT = """@example
+_EXAMPLE = '''@example
{code}
@end example
-""".format
+'''
def subst_strong(doc):
@@ -57,7 +57,7 @@ def texi_example(doc):
# function to subst_special() or subs_texi_special(). If we do that, we
# need to delay it until after subst_vars() in texi_format().
doc = subst_braces(doc).strip('\n')
- return EXAMPLE_FMT(code=doc)
+ return _EXAMPLE.format(code=doc)
def texi_format(doc):
@@ -90,7 +90,7 @@ def texi_format(doc):
# Make sure to update section "Documentation markup" in
# docs/devel/qapi-code-gen.txt when fixing this.
if line.startswith('| '):
- line = EXAMPLE_FMT(code=line[2:])
+ line = _EXAMPLE.format(code=line[2:])
elif line.startswith('= '):
line = '@section ' + line[2:]
elif line.startswith('== '):
@@ -217,21 +217,21 @@ def texi_sections(doc, ifcond):
def texi_type(typ, doc, ifcond, members):
- return TYPE_FMT(type=typ,
- name=doc.symbol,
- body=texi_body(doc),
- members=members,
- features=texi_features(doc),
- sections=texi_sections(doc, ifcond))
+ return _TYPE.format(type=typ,
+ name=doc.symbol,
+ body=texi_body(doc),
+ members=members,
+ features=texi_features(doc),
+ sections=texi_sections(doc, ifcond))
def texi_msg(typ, doc, ifcond, members):
- return MSG_FMT(type=typ,
- name=doc.symbol,
- body=texi_body(doc),
- members=members,
- features=texi_features(doc),
- sections=texi_sections(doc, ifcond))
+ return _MSG.format(type=typ,
+ name=doc.symbol,
+ body=texi_body(doc),
+ members=members,
+ features=texi_features(doc),
+ sections=texi_sections(doc, ifcond))
class QAPISchemaGenDocVisitor(QAPISchemaVisitor):
--
2.26.2
- [PATCH v3 09/47] [DO-NOT-MERGE] docs: add scripts/qapi/main to python manual, (continued)
Re: [PATCH v3 12/47] qapi: enforce import order/styling with isort, Cleber Rosa, 2020/09/29
[PATCH v3 10/47] qapi: Prefer explicit relative imports, John Snow, 2020/09/24
[PATCH v3 13/47] qapi: delint using flake8, John Snow, 2020/09/24
[PATCH v3 05/47] qapi/doc.py: Change code templates from function to string,
John Snow <=
[PATCH v3 15/47] qapi/common.py: Remove python compatibility workaround, John Snow, 2020/09/24
[PATCH v3 20/47] qapi/common.py: add type hint annotations, John Snow, 2020/09/24
[PATCH v3 17/47] qapi/common.py: delint with pylint, John Snow, 2020/09/24
[PATCH v3 14/47] qapi: add pylintrc, John Snow, 2020/09/24
[PATCH v3 24/47] qapi/events.py: add type hint annotations, John Snow, 2020/09/24
[PATCH v3 19/47] qapi/common.py: check with pylint, John Snow, 2020/09/24