Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v2 07/19] scripts/igt_doc.py: improve multi-line logic
Date: Fri, 10 Mar 2023 20:41:13 +0100	[thread overview]
Message-ID: <20230310194125.14781-8-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20230310194125.14781-1-zbigniew.kempczynski@intel.com>

From: Mauro Carvalho Chehab <mchehab@kernel.org>

Currently, there's no way to use something like:
	/**
	 ...
	 * Issue:
	 *	https://foo.bar

as https would be mis-interpreted as a field.

Fix it by always requiring one or more spaces/tabs on continuation
lines.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Acked-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
---
 scripts/igt_doc.py | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/scripts/igt_doc.py b/scripts/igt_doc.py
index c06c6e4eae..cd8dccecb4 100755
--- a/scripts/igt_doc.py
+++ b/scripts/igt_doc.py
@@ -832,6 +832,8 @@ class TestList:
             subtest_number = 0
 
             for file_ln,file_line in enumerate(handle):
+                file_line = file_line.rstrip()
+
                 if re.match(r'^\s*\*$', file_line):
                     continue
 
@@ -850,7 +852,7 @@ class TestList:
                 if not handle_section:
                     continue
 
-                file_line = re.sub(r'^\s*\*\s*', '', file_line)
+                file_line = re.sub(r'^\s*\* ?', '', file_line)
 
                 # Handle only known sections
                 if handle_section == '1':
@@ -966,21 +968,17 @@ class TestList:
                     if cur_arg not in self.doc[current_test]["arg"][arg_ref]:
                         self.doc[current_test]["arg"][arg_ref][cur_arg] = {}
 
-                    values = match.group(2).split(",")
+                    values = match.group(2).replace(" ", "").split(",")
                     for split_val in values:
                         if split_val == "":
                             continue
-                        self.doc[current_test]["arg"][arg_ref][cur_arg][split_val.strip()] = split_val.strip()
+                        self.doc[current_test]["arg"][arg_ref][cur_arg][split_val] = split_val
 
                     continue
 
-                if (match := re.match(r'^(.*):', file_line)):
-                    sys.exit(f"{fname}:{file_ln + 1}: Error: unrecognized field '%s'. Need to add at %s" %
-                            (match.group(1), self.config_fname))
-
                 # Handle multi-line field contents
                 if current_field:
-                    if (match := re.match(r'\s*(.*)', file_line)):
+                    if (match := re.match(r'\s+(.*)', file_line)):
                         if handle_section == 'test':
                             dic = self.doc[current_test]
                         else:
@@ -989,12 +987,11 @@ class TestList:
                         if dic[current_field] != '':
                             dic[current_field] += " "
                         dic[current_field] += match.group(1)
-
-                    continue
+                        continue
 
                 # Handle multi-line argument contents
                 if cur_arg >= 0 and arg_ref is not None:
-                    if (match := re.match(r'\s*\*?\s*(.*)', file_line)):
+                    if (match := re.match(r'\s+\*?\s*(.*)', file_line)):
                         match_val = match.group(1)
 
                         match = re.match(r'^(\<.*)\>$',self.doc[current_test]["arg"][arg_ref][cur_arg][cur_arg_element])
@@ -1006,6 +1003,10 @@ class TestList:
                             self.doc[current_test]["arg"][arg_ref][cur_arg][cur_arg_element] += match_val
                     continue
 
+                re.sub(r"\n$","", file_line)
+                sys.exit(f"{fname}:{file_ln + 1}: Error: unrecognized line. Need to add field at %s?\n\t==> %s" %
+                         (self.config_fname, file_line))
+
 #
 # Main
 #
-- 
2.34.1

  parent reply	other threads:[~2023-03-10 19:42 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10 19:41 [igt-dev] [PATCH i-g-t v2 00/19] Add igt_doc.py Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 01/19] scripts/igt_doc.py: beautify its code Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 02/19] scripts/igt_doc.py: add JSON file output Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 03/19] scripts/igt_doc.py: dynamically create fields array from a JSON file Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 04/19] scripts/igt_doc.py: add support to specify numeric values Zbigniew Kempczyński
2023-03-13  6:50   ` Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 05/19] scripts/igt_doc.py: improve --show-subtests logic Zbigniew Kempczyński
2023-03-13  6:54   ` Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 06/19] scripts/igt_doc.py: add error handler for subprocess Zbigniew Kempczyński
2023-03-13  6:55   ` Zbigniew Kempczyński
2023-03-10 19:41 ` Zbigniew Kempczyński [this message]
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 08/19] scripts/igt_doc.py: don't use ":=" operator Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 09/19] scripts/igt_doc.py: make it compatible with Python 3.6 Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 10/19] scripts/igt_doc.py: sets the minimal version to run the script Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 11/19] scripts/igt_doc.py: use a different logic to get IGT prefix Zbigniew Kempczyński
2023-03-13  7:08   ` Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 12/19] testplan/meson.build: add targets to build Xe test documentation Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 13/19] xe/xe_test_config.json: cleanup the field struct Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 14/19] xe/xe_huc_copy: add GPU dependency to its documentation Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 15/19] xe/xe_*: add TEST/SUBTEST documentation Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 16/19] xe-fast-feedback.testlist: update debugfs tests Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 17/19] xe_mmap: skip VRAM tests if no VRAM is found Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 18/19] meson: replace "igt@xe/" by "igt@" Zbigniew Kempczyński
2023-03-10 19:41 ` [igt-dev] [PATCH i-g-t v2 19/19] scripts/igt_doc.py: set have_implemented when --files is used Zbigniew Kempczyński
2023-03-13  7:10   ` Zbigniew Kempczyński
2023-03-10 20:34 ` [igt-dev] ✓ Fi.CI.BAT: success for Add igt_doc.py (rev2) Patchwork
2023-03-13 18:34 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230310194125.14781-8-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox