[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 10/11] qapi: Rename QAPIDoc.parser, .section to
From: |
Marc-André Lureau |
Subject: |
Re: [Qemu-devel] [PATCH 10/11] qapi: Rename QAPIDoc.parser, .section to ._parser, ._section |
Date: |
Wed, 4 Oct 2017 12:31:27 +0200 |
On Mon, Oct 2, 2017 at 4:13 PM, Markus Armbruster <address@hidden> wrote:
> Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
> ---
> scripts/qapi.py | 52 ++++++++++++++++++++++++++--------------------------
> 1 file changed, 26 insertions(+), 26 deletions(-)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index e338868a52..43a54bf40f 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -120,11 +120,11 @@ class QAPIDoc(object):
> self.member = member
>
> def __init__(self, parser, info):
> - # self.parser is used to report errors with QAPIParseError. The
> + # self._parser is used to report errors with QAPIParseError. The
> # resulting error position depends on the state of the parser.
> # It happens to be the beginning of the comment. More or less
> # servicable, but action at a distance.
> - self.parser = parser
> + self._parser = parser
> self.info = info
> self.symbol = None
> self.body = QAPIDoc.Section()
> @@ -133,7 +133,7 @@ class QAPIDoc(object):
> # a list of Section
> self.sections = []
> # the current section
> - self.section = self.body
> + self._section = self.body
>
> def has_section(self, name):
> """Return True if we have a section with this name."""
> @@ -150,7 +150,7 @@ class QAPIDoc(object):
> return
>
> if line[0] != ' ':
> - raise QAPIParseError(self.parser, "Missing space after #")
> + raise QAPIParseError(self._parser, "Missing space after #")
> line = line[1:]
>
> # FIXME not nice: things like '# @foo:' and '# @foo: ' aren't
> @@ -159,11 +159,11 @@ class QAPIDoc(object):
> self._append_symbol_line(line)
> elif not self.body.text and line.startswith('@'):
> if not line.endswith(':'):
> - raise QAPIParseError(self.parser, "Line should end with :")
> + raise QAPIParseError(self._parser, "Line should end with :")
> self.symbol = line[1:-1]
> # FIXME invalid names other than the empty string aren't flagged
> if not self.symbol:
> - raise QAPIParseError(self.parser, "Invalid name")
> + raise QAPIParseError(self._parser, "Invalid name")
> else:
> self._append_freeform(line)
>
> @@ -189,48 +189,48 @@ class QAPIDoc(object):
> def _start_args_section(self, name):
> # FIXME invalid names other than the empty string aren't flagged
> if not name:
> - raise QAPIParseError(self.parser, "Invalid parameter name")
> + raise QAPIParseError(self._parser, "Invalid parameter name")
> if name in self.args:
> - raise QAPIParseError(self.parser,
> + raise QAPIParseError(self._parser,
> "'%s' parameter name duplicated" % name)
> if self.sections:
> - raise QAPIParseError(self.parser,
> + raise QAPIParseError(self._parser,
> "'@%s:' can't follow '%s' section"
> % (name, self.sections[0].name))
> self._end_section()
> - self.section = QAPIDoc.ArgSection(name)
> - self.args[name] = self.section
> + self._section = QAPIDoc.ArgSection(name)
> + self.args[name] = self._section
>
> def _start_section(self, name=None):
> if name in ('Returns', 'Since') and self.has_section(name):
> - raise QAPIParseError(self.parser,
> + raise QAPIParseError(self._parser,
> "Duplicated '%s' section" % name)
> self._end_section()
> - self.section = QAPIDoc.Section(name)
> - self.sections.append(self.section)
> + self._section = QAPIDoc.Section(name)
> + self.sections.append(self._section)
>
> def _end_section(self):
> - if self.section:
> - text = self.section.text = self.section.text.strip()
> - if self.section.name and (not text or text.isspace()):
> - raise QAPIParseError(self.parser, "Empty doc section '%s'"
> - % self.section.name)
> - self.section = None
> + if self._section:
> + text = self._section.text = self._section.text.strip()
> + if self._section.name and (not text or text.isspace()):
> + raise QAPIParseError(self._parser, "Empty doc section '%s'"
> + % self._section.name)
> + self._section = None
>
> def _append_freeform(self, line):
> - in_arg = isinstance(self.section, QAPIDoc.ArgSection)
> - if (in_arg and self.section.text.endswith('\n\n')
> + in_arg = isinstance(self._section, QAPIDoc.ArgSection)
> + if (in_arg and self._section.text.endswith('\n\n')
> and line and not line[0].isspace()):
> self._start_section()
> - if (in_arg or not self.section.name
> - or not self.section.name.startswith('Example')):
> + if (in_arg or not self._section.name
> + or not self._section.name.startswith('Example')):
> line = line.strip()
> match = re.match(r'(@\S+:)', line)
> if match:
> - raise QAPIParseError(self.parser,
> + raise QAPIParseError(self._parser,
> "'%s' not allowed in free-form
> documentation"
> % match.group(1))
> - self.section.append(line)
> + self._section.append(line)
>
> def connect_member(self, member):
> if member.name not in self.args:
> --
> 2.13.6
>
>
--
Marc-André Lureau
- Re: [Qemu-devel] [PATCH 07/11] qapi: Unify representation of doc section without name, (continued)
- [Qemu-devel] [PATCH 02/11] qapi: Stop rejecting #optional, Markus Armbruster, 2017/10/02
- [Qemu-devel] [PATCH 03/11] qapi: Eliminate QAPISchemaParser.__init__()'s local fname, Markus Armbruster, 2017/10/02
- [Qemu-devel] [PATCH 05/11] tests/qapi-schema/doc-bad-section: New, factored out of doc-good, Markus Armbruster, 2017/10/02
- [Qemu-devel] [PATCH 06/11] qapi2texi: Clean up texi_sections(), Markus Armbruster, 2017/10/02
- [Qemu-devel] [PATCH 10/11] qapi: Rename QAPIDoc.parser, .section to ._parser, ._section, Markus Armbruster, 2017/10/02
- Re: [Qemu-devel] [PATCH 10/11] qapi: Rename QAPIDoc.parser, .section to ._parser, ._section,
Marc-André Lureau <=
- [Qemu-devel] [PATCH 01/11] qapi-schema: Fix query-vm-generation-id's doc comment markup, Markus Armbruster, 2017/10/02
- [Qemu-devel] [PATCH 11/11] qapi2texi: De-duplicate code to add blank line before symbol, Markus Armbruster, 2017/10/02
- [Qemu-devel] [PATCH 08/11] qapi: Simplify representation of QAPIDoc section text, Markus Armbruster, 2017/10/02
- [Qemu-devel] [PATCH 09/11] qapi2texi: Simplify representation of section text, Markus Armbruster, 2017/10/02