qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 21/29] scripts/qapi: Move doc-comment whitespace stripping to doc


From: Peter Maydell
Subject: [PATCH 21/29] scripts/qapi: Move doc-comment whitespace stripping to doc.py
Date: Thu, 6 Feb 2020 17:30:32 +0000

As we accumulate lines from doc comments when parsing the JSON, the
QAPIDoc class generally strips leading and trailing whitespace using
line.strip() when it calls _append_freeform().  This is fine for
texinfo, but for rST leading whitespace is significant.  We'd like to
move to having the text in doc comments be rST format rather than a
custom syntax, so move the removal of leading whitespace from the
QAPIDoc class to the texinfo-specific processing code in
texi_format() in qapi/doc.py.

(Trailing whitespace will always be stripped by the rstrip() in
Section::append regardless.)

In a followup commit we will make the whitespace in the lines of doc
comment sections more consistently follow the input source.

There is no change to the generated .texi files before and after this
commit.

Signed-off-by: Peter Maydell <address@hidden>
---
 scripts/qapi/doc.py    |  1 +
 scripts/qapi/parser.py | 12 ++++--------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py
index 6f1c17f71f7..96346c9b14f 100644
--- a/scripts/qapi/doc.py
+++ b/scripts/qapi/doc.py
@@ -80,6 +80,7 @@ def texi_format(doc):
     inlist = ''
     lastempty = False
     for line in doc.split('\n'):
+        line = line.strip()
         empty = line == ''
 
         # FIXME: Doing this in a single if / elif chain is
diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index 342792e4103..2196ec5de1e 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -422,10 +422,10 @@ class QAPIDoc(object):
                 self._append_line = self._append_various_line
                 self._append_various_line(line)
             else:
-                self._append_freeform(line.strip())
+                self._append_freeform(line)
         else:
             # This is a free-form documentation block
-            self._append_freeform(line.strip())
+            self._append_freeform(line)
 
     def _append_args_line(self, line):
         """
@@ -458,7 +458,7 @@ class QAPIDoc(object):
                 self._append_various_line(line)
             return
 
-        self._append_freeform(line.strip())
+        self._append_freeform(line)
 
     def _append_features_line(self, line):
         name = line.split(' ', 1)[0]
@@ -477,7 +477,7 @@ class QAPIDoc(object):
             self._append_various_line(line)
             return
 
-        self._append_freeform(line.strip())
+        self._append_freeform(line)
 
     def _append_various_line(self, line):
         """
@@ -500,10 +500,6 @@ class QAPIDoc(object):
             line = line[len(name)+1:]
             self._start_section(name[:-1])
 
-        if (not self._section.name or
-                not self._section.name.startswith('Example')):
-            line = line.strip()
-
         self._append_freeform(line)
 
     def _start_symbol_section(self, symbols_dict, name):
-- 
2.20.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]