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 | 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 file | 302 | # 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 environment | 310 | # Prepare a venv environment |
| @@ -317,7 +317,16 @@ class SphinxVenv: · 6 unmodified lines | |||
| 317 | 317 | ||
| 318 | # Test doc build | 318 | # 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 | |||
| 407 | Sphinx versions that are supported by the Linux Kernel build system. | 416 | Sphinx versions that are supported by the Linux Kernel build system. |
| 408 | 417 | ||
| 409 | Besides creating the virtual environment, it can also test building | 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 | If called without "--versions" argument, it covers the versions shipped | 421 | If called without "--versions" argument, it covers the versions shipped |
| 413 | on major distros, plus the lowest supported version: | 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 | {SCRIPT} -m -l sphinx_builds.log | 428 | {SCRIPT} -m -l sphinx_builds.log |
| 420 | 429 | ||
| 421 | This will create one virtual env for the default version set and do a | 430 | This will create one virtual env for the default version set and run |
| 422 | full htmldocs build for each version, creating a log file with the | 431 | "make htmldocs" for each version, creating a log file with the |
| 423 | excecuted commands on it. | 432 | excecuted commands on it. |
| 424 | 433 | ||
| 425 | NOTE: The build time can be very long, specially on old versions. Also, there | 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 | async def main(): | 455 | async 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 | ||