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
269269
270270 ver = ".".join(map(str, cur_ver))
271271
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:
273273 ret = input("Press Enter to continue or 'a' to abort: ").strip().lower()
274274 if ret == "a":
275275 print("Aborted.")
@@ -300,11 +300,11 @@ class SphinxVenv: · 24 unmodified lines
300300 result = await cmd.run([pip, "freeze"], verbose=False, check=True)
301301
302302 # Pip install succeeded. Write requirements file
303− if args.write:
303+ if args.req_file:
304304 with open(req_file, "w", encoding="utf-8") as fp:
305305 fp.write(result.stdout)
306306
307− if args.make:
307+ if args.build:
308308 start_time = time.time()
309309
310310 # Prepare a venv environment
@@ -317,7 +317,16 @@ class SphinxVenv: · 6 unmodified lines
317317
318318 # Test doc build
319319 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
321330
322331 if args.verbose:
323332 cmd.log(f". {bin_dir}/activate", verbose=True)
@@ -380,7 +389,7 @@ class SphinxVenv: · 56 unmodified lines
380389 await self._handle_version(args, fp, cur_ver, cur_requirements,
381390 python_bin)
382391
383− if args.make:
392+ if args.build:
384393 cmd = AsyncCommands(fp)
385394 cmd.log("\nSummary:", verbose=True)
386395 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
407416 Sphinx versions that are supported by the Linux Kernel build system.
408417
409418 Besides creating the virtual environment, it can also test building
410−the documentation using "make htmldocs".
419+the documentation using "make htmldocs" (and/or other doc targets).
411420
412421 If called without "--versions" argument, it covers the versions shipped
413422 on major distros, plus the lowest supported version:
@@ -418,8 +427,8 @@ A typical usage is to run: · 4 unmodified lines
418427
419428 {SCRIPT} -m -l sphinx_builds.log
420429
421−This will create one virtual env for the default version set and do a
422−full htmldocs build for each version, creating a log file with the
430+This will create one virtual env for the default version set and run
431+"make htmldocs" for each version, creating a log file with the
423432 excecuted commands on it.
424433
425434 NOTE: 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
433442
434443 """
435444
445+MAKE_TARGETS = [
446+ "htmldocs",
447+ "texinfodocs",
448+ "infodocs",
449+ "latexdocs",
450+ "pdfdocs",
451+ "epubdocs",
452+ "xmldocs",
453+]
436454
437455 async def main():
438456 """Main program"""
@@ -440,32 +458,41 @@ async def main(): · 1 unmodified line
440458 parser = argparse.ArgumentParser(description=DESCRIPTION,
441459 formatter_class=argparse.RawDescriptionHelpFormatter)
442460
443− parser.add_argument('-V', '--versions', help='Sphinx versions to test',
444− nargs="*", default=DEFAULT_VERSIONS_TO_TEST,
445− type=parse_version)
446− parser.add_argument('--min-version', "--min", help='Sphinx minimal version',
447− type=parse_version)
448− parser.add_argument('--max-version', "--max", help='Sphinx maximum version',
449− type=parse_version)
450− parser.add_argument('-a', '--make_args',
451− help='extra arguments for make htmldocs, like SPHINXDIRS=netlink/specs',
452− nargs="*")
453− parser.add_argument('-w', '--write', help='write a requirements.txt file',
454− action='store_true')
455− parser.add_argument('-m', '--make',
456− help='Make documentation',
457− action='store_true')
458− parser.add_argument('-f', '--full',
459− help='Add all (major,minor,latest_patch) version to the version list',
460− action='store_true')
461− parser.add_argument('-i', '--wait-input',
462− help='Wait for an enter before going to the next version',
463− action='store_true')
464− parser.add_argument('-v', '--verbose',
465− help='Verbose all commands',
466− action='store_true')
467− parser.add_argument('-l', '--log',
468− help='Log command output on a file')
461+ ver_group = parser.add_argument_group("Version range options")
462+
463+ ver_group.add_argument('-V', '--versions', nargs="*",
464+ default=DEFAULT_VERSIONS_TO_TEST,type=parse_version,
465+ help='Sphinx versions to test')
466+ ver_group.add_argument('--min-version', "--min", type=parse_version,
467+ help='Sphinx minimal version')
468+ ver_group.add_argument('--max-version', "--max", type=parse_version,
469+ help='Sphinx maximum version')
470+ ver_group.add_argument('-f', '--full', action='store_true',
471+ help='Add all Sphinx (major,minor) supported versions to the version range')
472+
473+ build_group = parser.add_argument_group("Build options")
474+
475+ build_group.add_argument('-b', '--build', action='store_true',
476+ help='Build documentation')
477+ build_group.add_argument('-a', '--make-args', nargs="*",
478+ help='extra arguments for make, like SPHINXDIRS=netlink/specs',
479+ )
480+ build_group.add_argument('-t', '--targets', nargs="+", choices=MAKE_TARGETS,
481+ default=[MAKE_TARGETS[0]],
482+ help="make build targets. Default: htmldocs.")
483+ build_group.add_argument("-o", '--output',
484+ help="output directory for the make O=OUTPUT")
485+
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')
469496
470497 args = parser.parse_args()
471498

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