From: Mauro Carvalho Chehab <mauro.chehab@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 5/5] igt_doc.py: move the main code to a main() function
Date: Tue, 28 Nov 2023 11:49:00 +0100 [thread overview]
Message-ID: <20231128105054.24317-6-mauro.chehab@linux.intel.com> (raw)
In-Reply-To: <20231128105054.24317-1-mauro.chehab@linux.intel.com>
From: Mauro Carvalho Chehab <mchehab@kernel.org>
That avoids having global variables inside the script and
makes easier to add IGT-specific classes there.
No functional changes.
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
scripts/igt_doc.py | 122 ++++++++++++++++++++++++---------------------
1 file changed, 65 insertions(+), 57 deletions(-)
diff --git a/scripts/igt_doc.py b/scripts/igt_doc.py
index 86e49970ea28..ab6179366831 100755
--- a/scripts/igt_doc.py
+++ b/scripts/igt_doc.py
@@ -15,69 +15,77 @@ import sys
from test_list import TestList
-IGT_BUILD_PATH = 'build'
+def main():
+ """
+ Main logic
+ """
-parser = argparse.ArgumentParser(description = "Print formatted kernel documentation to stdout.",
- formatter_class = argparse.ArgumentDefaultsHelpFormatter,
- epilog = 'If no action specified, assume --rest.')
-parser.add_argument("--config", required = True,
- help="JSON file describing the test plan template")
-parser.add_argument("--rest",
- help="Output documentation from the source files in REST file.")
-parser.add_argument("--per-test", action="store_true",
- help="Modifies ReST output to print subtests per test.")
-parser.add_argument("--to-json",
- help="Output test documentation in JSON format as TO_JSON file")
-parser.add_argument("--show-subtests", action="store_true",
- help="Shows the name of the documented subtests in alphabetical order.")
-parser.add_argument("--sort-field",
- help="modify --show-subtests to sort output based on SORT_FIELD value")
-parser.add_argument("--filter-field", nargs='*',
- help="filter subtests based on regular expressions given by FILTER_FIELD=~'regex'")
-parser.add_argument("--check-testlist", action="store_true",
- help="Compare documentation against IGT built tests.")
-parser.add_argument("--include-plan", action="store_true",
- help="Include test plans, if any.")
-parser.add_argument("--igt-build-path",
- help="Path to the IGT build directory. Used by --check-testlist.",
- default=IGT_BUILD_PATH)
-parser.add_argument("--gen-testlist",
- help="Generate documentation at the GEN_TESTLIST directory, using SORT_FIELD to split the tests. Requires --sort-field.")
-parser.add_argument('--files', nargs='+',
- help="File name(s) to be processed")
+ igt_build_path = 'build'
-parse_args = parser.parse_args()
+ parser = argparse.ArgumentParser(description = "Print formatted kernel documentation to stdout.",
+ formatter_class = argparse.ArgumentDefaultsHelpFormatter,
+ epilog = 'If no action specified, assume --rest.')
+ parser.add_argument("--config", required = True,
+ help="JSON file describing the test plan template")
+ parser.add_argument("--rest",
+ help="Output documentation from the source files in REST file.")
+ parser.add_argument("--per-test", action="store_true",
+ help="Modifies ReST output to print subtests per test.")
+ parser.add_argument("--to-json",
+ help="Output test documentation in JSON format as TO_JSON file")
+ parser.add_argument("--show-subtests", action="store_true",
+ help="Shows the name of the documented subtests in alphabetical order.")
+ parser.add_argument("--sort-field",
+ help="modify --show-subtests to sort output based on SORT_FIELD value")
+ parser.add_argument("--filter-field", nargs='*',
+ help="filter subtests based on regular expressions given by FILTER_FIELD=~'regex'")
+ parser.add_argument("--check-testlist", action="store_true",
+ help="Compare documentation against IGT built tests.")
+ parser.add_argument("--include-plan", action="store_true",
+ help="Include test plans, if any.")
+ parser.add_argument("--igt-build-path",
+ help="Path to the IGT build directory. Used by --check-testlist.",
+ default=igt_build_path)
+ parser.add_argument("--gen-testlist",
+ help="Generate documentation at the GEN_TESTLIST directory, using SORT_FIELD to split the tests. Requires --sort-field.")
+ parser.add_argument('--files', nargs='+',
+ help="File name(s) to be processed")
-tests = TestList(config_fname = parse_args.config,
- include_plan = parse_args.include_plan,
- file_list = parse_args.files,
- igt_build_path = parse_args.igt_build_path)
+ parse_args = parser.parse_args()
-if parse_args.filter_field:
- for filter_expr in parse_args.filter_field:
- tests.add_filter(filter_expr)
+ tests = TestList(config_fname = parse_args.config,
+ include_plan = parse_args.include_plan,
+ file_list = parse_args.files,
+ igt_build_path = parse_args.igt_build_path)
-RUN = 0
-if parse_args.show_subtests:
- RUN = 1
- tests.show_subtests(parse_args.sort_field)
+ if parse_args.filter_field:
+ for filter_expr in parse_args.filter_field:
+ tests.add_filter(filter_expr)
-if parse_args.check_testlist:
- RUN = 1
- tests.check_tests()
+ run = False
+ if parse_args.show_subtests:
+ run = True
+ tests.show_subtests(parse_args.sort_field)
-if parse_args.gen_testlist:
- RUN = 1
- if not parse_args.sort_field:
- sys.exit("Need a field to split the testlists")
- tests.gen_testlist(parse_args.gen_testlist, parse_args.sort_field)
+ if parse_args.check_testlist:
+ run = True
+ tests.check_tests()
-if parse_args.to_json:
- RUN = 1
- tests.print_json(parse_args.to_json)
+ if parse_args.gen_testlist:
+ run = True
+ if not parse_args.sort_field:
+ sys.exit("Need a field to split the testlists")
+ tests.gen_testlist(parse_args.gen_testlist, parse_args.sort_field)
-if not RUN or parse_args.rest:
- if parse_args.per_test:
- tests.print_rest_flat(parse_args.rest)
- else:
- tests.print_nested_rest(parse_args.rest)
+ if parse_args.to_json:
+ run = True
+ tests.print_json(parse_args.to_json)
+
+ if not run or parse_args.rest:
+ if parse_args.per_test:
+ tests.print_rest_flat(parse_args.rest)
+ else:
+ tests.print_nested_rest(parse_args.rest)
+
+if __name__ == '__main__':
+ main()
--
2.42.0
next prev parent reply other threads:[~2023-11-28 10:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-28 10:48 [igt-dev] [PATCH i-g-t 0/5] Do dome cleanups at IGT doc tools Mauro Carvalho Chehab
2023-11-28 10:48 ` [igt-dev] [PATCH i-g-t 1/5] scripts/test_list.py: better expand subtests Mauro Carvalho Chehab
2023-11-28 10:48 ` [igt-dev] [PATCH i-g-t 2/5] scripts/test_list.py: don't add a blank description Mauro Carvalho Chehab
2023-11-28 15:51 ` Kamil Konieczny
2023-11-28 10:48 ` [igt-dev] [PATCH i-g-t 3/5] scripts/test_list.py: Fix trivial pylint issues Mauro Carvalho Chehab
2023-11-28 15:44 ` Kamil Konieczny
2023-11-28 10:48 ` [igt-dev] [PATCH i-g-t 4/5] scripts/test_list.py: fix indent at get_subtests() Mauro Carvalho Chehab
2023-11-28 15:57 ` Kamil Konieczny
2023-11-28 10:49 ` Mauro Carvalho Chehab [this message]
2023-11-28 15:59 ` [igt-dev] [PATCH i-g-t 5/5] igt_doc.py: move the main code to a main() function Kamil Konieczny
2023-11-28 11:59 ` [igt-dev] ✓ CI.xeBAT: success for Do dome cleanups at IGT doc tools 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=20231128105054.24317-6-mauro.chehab@linux.intel.com \
--to=mauro.chehab@linux.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