Add config option in `build.py` for Sphinx builders (#1988)

This commit is contained in:
Adam Turner 2021-06-09 14:02:16 +01:00 committed by GitHub
parent ec52afb543
commit c69fdbf5e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View File

@ -66,8 +66,12 @@ pages: rss
sphinx:
$(SPHINX_BUILD)
fail_on_warning:
# for building Sphinx without a web-server
sphinx-local:
$(SPHINX_BUILD) --build-files
fail-warning:
$(SPHINX_BUILD) --fail-on-warning
check_links:
check-links:
$(SPHINX_BUILD) --check-links

View File

@ -10,9 +10,11 @@ def create_parser():
parser = argparse.ArgumentParser(description="Build PEP documents")
# alternative builders:
parser.add_argument("-l", "--check-links", action="store_true")
parser.add_argument("-f", "--build-files", action="store_true")
parser.add_argument("-d", "--build-dirs", action="store_true")
# flags / options
parser.add_argument("-f", "--fail-on-warning", action="store_true")
parser.add_argument("-w", "--fail-on-warning", action="store_true")
parser.add_argument("-n", "--nitpicky", action="store_true")
parser.add_argument("-j", "--jobs", type=int, default=1)
@ -31,9 +33,15 @@ if __name__ == "__main__":
doctree_directory = build_directory / ".doctrees"
# builder configuration
if args.build_files:
sphinx_builder = "html"
elif args.build_dirs:
sphinx_builder = "dirhtml"
if args.check_links:
elif args.check_links:
sphinx_builder = "linkcheck"
else:
# default builder
sphinx_builder = "dirhtml"
# other configuration
config_overrides = {}