History

scripts: test_doc_build.py: regroup and rename arguments

The script now have lots or arguments. Better organize and name them, for it to be a little bit more intuitive.

Mauro Carvalho Chehab committed 1 year ago

Commit bb4c5c51 parent 61aeda11 file · +61 −34Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/test_doc_build.py+61−34
@@ -269,7 +269,7 @@ class SphinxVenv: · 268 unmodified lines
269 269
270 ver = ".".join(map(str, cur_ver))270 ver = ".".join(map(str, cur_ver))
271 271
272 if not self.first_run and args.wait_input and args.make:272 if not self.first_run and args.wait_input and args.build:
273 ret = input("Press Enter to continue or 'a' to abort: ").strip().lower()273 ret = input("Press Enter to continue or 'a' to abort: ").strip().lower()
274 if ret == "a":274 if ret == "a":
275 print("Aborted.")275 print("Aborted.")
@@ -300,11 +300,11 @@ class SphinxVenv: · 24 unmodified lines
300 result = await cmd.run([pip, "freeze"], verbose=False, check=True)300 result = await cmd.run([pip, "freeze"], verbose=False, check=True)
301 301
302 # Pip install succeeded. Write requirements file302 # Pip install succeeded. Write requirements file
303 if args.write:303 if args.req_file:
304 with open(req_file, "w", encoding="utf-8") as fp:304 with open(req_file, "w", encoding="utf-8") as fp:
305 fp.write(result.stdout)305 fp.write(result.stdout)
306 306
307 if args.make:307 if args.build:
308 start_time = time.time()308 start_time = time.time()
309 309
310 # Prepare a venv environment310 # Prepare a venv environment
@@ -317,7 +317,16 @@ class SphinxVenv: · 6 unmodified lines
317 317
318 # Test doc build318 # Test doc build
319 await cmd.run(["make", "cleandocs"], env=env, check=True)319 await cmd.run(["make", "cleandocs"], env=env, check=True)
320 make = ["make"] + args.make_args + ["htmldocs"]320 make = ["make"]
321
322 if args.output:
323 sphinx_build = os.path.realpath(f"{bin_dir}/sphinx-build")
324 make += [f"O={args.output}", f"SPHINXBUILD={sphinx_build}"]
325
326 if args.make_args:
327 make += args.make_args
328
329 make += args.targets
321 330
322 if args.verbose:331 if args.verbose:
323 cmd.log(f". {bin_dir}/activate", verbose=True)332 cmd.log(f". {bin_dir}/activate", verbose=True)
@@ -380,7 +389,7 @@ class SphinxVenv: · 56 unmodified lines
380 await self._handle_version(args, fp, cur_ver, cur_requirements,389 await self._handle_version(args, fp, cur_ver, cur_requirements,
381 python_bin)390 python_bin)
382 391
383 if args.make:392 if args.build:
384 cmd = AsyncCommands(fp)393 cmd = AsyncCommands(fp)
385 cmd.log("\nSummary:", verbose=True)394 cmd.log("\nSummary:", verbose=True)
386 for ver, elapsed_time in sorted(self.built_time.items()):395 for ver, elapsed_time in sorted(self.built_time.items()):
@@ -407,7 +416,7 @@ This tool allows creating Python virtual environments for different · 20 unmodified lines
407Sphinx versions that are supported by the Linux Kernel build system.416Sphinx versions that are supported by the Linux Kernel build system.
408 417
409Besides creating the virtual environment, it can also test building418Besides creating the virtual environment, it can also test building
410the documentation using "make htmldocs".419the documentation using "make htmldocs" (and/or other doc targets).
411 420
412If called without "--versions" argument, it covers the versions shipped421If called without "--versions" argument, it covers the versions shipped
413on major distros, plus the lowest supported version:422on major distros, plus the lowest supported version:
@@ -418,8 +427,8 @@ A typical usage is to run: · 4 unmodified lines
418 427
419 {SCRIPT} -m -l sphinx_builds.log428 {SCRIPT} -m -l sphinx_builds.log
420 429
421This will create one virtual env for the default version set and do a430This will create one virtual env for the default version set and run
422full htmldocs build for each version, creating a log file with the431"make htmldocs" for each version, creating a log file with the
423excecuted commands on it.432excecuted commands on it.
424 433
425NOTE: The build time can be very long, specially on old versions. Also, there434NOTE: The build time can be very long, specially on old versions. Also, there
@@ -433,6 +442,15 @@ reduce the number of threads from "-jauto" to, for instance, "-j4": · 7 unmodified lines
433 442
434"""443"""
435 444
445MAKE_TARGETS = [
446 "htmldocs",
447 "texinfodocs",
448 "infodocs",
449 "latexdocs",
450 "pdfdocs",
451 "epubdocs",
452 "xmldocs",
453]
436 454
437async def main():455async def main():
438 """Main program"""456 """Main program"""
@@ -440,32 +458,41 @@ async def main(): · 1 unmodified line
440 parser = argparse.ArgumentParser(description=DESCRIPTION,458 parser = argparse.ArgumentParser(description=DESCRIPTION,
441 formatter_class=argparse.RawDescriptionHelpFormatter)459 formatter_class=argparse.RawDescriptionHelpFormatter)
442 460
443 parser.add_argument('-V', '--versions', help='Sphinx versions to test',461 ver_group = parser.add_argument_group("Version range options")
444 nargs="*", default=DEFAULT_VERSIONS_TO_TEST,462
445 type=parse_version)463 ver_group.add_argument('-V', '--versions', nargs="*",
446 parser.add_argument('--min-version', "--min", help='Sphinx minimal version',464 default=DEFAULT_VERSIONS_TO_TEST,type=parse_version,
447 type=parse_version)465 help='Sphinx versions to test')
448 parser.add_argument('--max-version', "--max", help='Sphinx maximum version',466 ver_group.add_argument('--min-version', "--min", type=parse_version,
449 type=parse_version)467 help='Sphinx minimal version')
450 parser.add_argument('-a', '--make_args',468 ver_group.add_argument('--max-version', "--max", type=parse_version,
451 help='extra arguments for make htmldocs, like SPHINXDIRS=netlink/specs',469 help='Sphinx maximum version')
452 nargs="*")470 ver_group.add_argument('-f', '--full', action='store_true',
453 parser.add_argument('-w', '--write', help='write a requirements.txt file',471 help='Add all Sphinx (major,minor) supported versions to the version range')
454 action='store_true')472
455 parser.add_argument('-m', '--make',473 build_group = parser.add_argument_group("Build options")
456 help='Make documentation',474
457 action='store_true')475 build_group.add_argument('-b', '--build', action='store_true',
458 parser.add_argument('-f', '--full',476 help='Build documentation')
459 help='Add all (major,minor,latest_patch) version to the version list',477 build_group.add_argument('-a', '--make-args', nargs="*",
460 action='store_true')478 help='extra arguments for make, like SPHINXDIRS=netlink/specs',
461 parser.add_argument('-i', '--wait-input',479 )
462 help='Wait for an enter before going to the next version',480 build_group.add_argument('-t', '--targets', nargs="+", choices=MAKE_TARGETS,
463 action='store_true')481 default=[MAKE_TARGETS[0]],
464 parser.add_argument('-v', '--verbose',482 help="make build targets. Default: htmldocs.")
465 help='Verbose all commands',483 build_group.add_argument("-o", '--output',
466 action='store_true')484 help="output directory for the make O=OUTPUT")
467 parser.add_argument('-l', '--log',485
468 help='Log command output on a file')486 other_group = parser.add_argument_group("Other options")
487
488 other_group.add_argument('-r', '--req-file', action='store_true',
489 help='write a requirements.txt file')
490 other_group.add_argument('-l', '--log',
491 help='Log command output on a file')
492 other_group.add_argument('-v', '--verbose', action='store_true',
493 help='Verbose all commands')
494 other_group.add_argument('-i', '--wait-input', action='store_true',
495 help='Wait for an enter before going to the next version')
469 496
470 args = parser.parse_args()497 args = parser.parse_args()
471 498

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t