The script now have lots or arguments. Better organize and name them, for it to be a little bit more intuitive.
Showing the changes to scripts (1 of 1 file). Show all
Unified · Split
| @@ -269,7 +269,7 @@ class SphinxVenv: · 268 unmodified lines | ||
| 269 | 269 | |
| 270 | 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 | 273 | ret = input("Press Enter to continue or 'a' to abort: ").strip().lower() |
| 274 | 274 | if ret == "a": |
| 275 | 275 | print("Aborted.") |
| @@ -300,11 +300,11 @@ class SphinxVenv: · 24 unmodified lines | ||
| 300 | 300 | result = await cmd.run([pip, "freeze"], verbose=False, check=True) |
| 301 | 301 | |
| 302 | 302 | # Pip install succeeded. Write requirements file |
| 303 | − if args.write: | |
| 303 | + if args.req_file: | |
| 304 | 304 | with open(req_file, "w", encoding="utf-8") as fp: |
| 305 | 305 | fp.write(result.stdout) |
| 306 | 306 | |
| 307 | − if args.make: | |
| 307 | + if args.build: | |
| 308 | 308 | start_time = time.time() |
| 309 | 309 | |
| 310 | 310 | # Prepare a venv environment |
| @@ -317,7 +317,16 @@ class SphinxVenv: · 6 unmodified lines | ||
| 317 | 317 | |
| 318 | 318 | # Test doc build |
| 319 | 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 | 331 | if args.verbose: |
| 323 | 332 | cmd.log(f". {bin_dir}/activate", verbose=True) |
| @@ -380,7 +389,7 @@ class SphinxVenv: · 56 unmodified lines | ||
| 380 | 389 | await self._handle_version(args, fp, cur_ver, cur_requirements, |
| 381 | 390 | python_bin) |
| 382 | 391 | |
| 383 | − if args.make: | |
| 392 | + if args.build: | |
| 384 | 393 | cmd = AsyncCommands(fp) |
| 385 | 394 | cmd.log("\nSummary:", verbose=True) |
| 386 | 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 | ||
| 407 | 416 | Sphinx versions that are supported by the Linux Kernel build system. |
| 408 | 417 | |
| 409 | 418 | 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). | |
| 411 | 420 | |
| 412 | 421 | If called without "--versions" argument, it covers the versions shipped |
| 413 | 422 | on major distros, plus the lowest supported version: |
| @@ -418,8 +427,8 @@ A typical usage is to run: · 4 unmodified lines | ||
| 418 | 427 | |
| 419 | 428 | {SCRIPT} -m -l sphinx_builds.log |
| 420 | 429 | |
| 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 | |
| 423 | 432 | excecuted commands on it. |
| 424 | 433 | |
| 425 | 434 | 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 | ||
| 433 | 442 | |
| 434 | 443 | """ |
| 435 | 444 | |
| 445 | +MAKE_TARGETS = [ | |
| 446 | + "htmldocs", | |
| 447 | + "texinfodocs", | |
| 448 | + "infodocs", | |
| 449 | + "latexdocs", | |
| 450 | + "pdfdocs", | |
| 451 | + "epubdocs", | |
| 452 | + "xmldocs", | |
| 453 | +] | |
| 436 | 454 | |
| 437 | 455 | async def main(): |
| 438 | 456 | """Main program""" |
| @@ -440,32 +458,41 @@ async def main(): · 1 unmodified line | ||
| 440 | 458 | parser = argparse.ArgumentParser(description=DESCRIPTION, |
| 441 | 459 | formatter_class=argparse.RawDescriptionHelpFormatter) |
| 442 | 460 | |
| 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') | |
| 469 | 496 | |
| 470 | 497 | args = parser.parse_args() |
| 471 | 498 | |