Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 596bfad

Browse files
committedSep 25, 2024·
Add --select-output
1 parent bce1bed commit 596bfad

File tree

2 files changed

+43
-44
lines changed

2 files changed

+43
-44
lines changed
 

‎.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
/www/
44
# temporary lock file created while building the docs
55
build_docs.lock
6+
build_docs_archives.lock
7+
build_docs_html.lock
68

79

810
# Created by https://www.gitignore.io/api/python

‎build_docs.py

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from string import Template
4545
from textwrap import indent
4646
from time import perf_counter, sleep
47-
from typing import Iterable
47+
from typing import Iterable, Literal
4848
from urllib.parse import urljoin
4949

5050
import jinja2
@@ -487,11 +487,16 @@ def parse_args():
487487
parser = ArgumentParser(
488488
description="Runs a build of the Python docs for various branches."
489489
)
490+
parser.add_argument(
491+
"--select-output",
492+
choices=("no-html", "only-html"),
493+
help="Choose what outputs to build.",
494+
)
490495
parser.add_argument(
491496
"-q",
492497
"--quick",
493498
action="store_true",
494-
help="Make HTML files only (Makefile rules suffixed with -html).",
499+
help="Run a quick build (only HTML files).",
495500
)
496501
parser.add_argument(
497502
"-b",
@@ -589,23 +594,18 @@ class DocBuilder:
589594
cpython_repo: Repository
590595
build_root: Path
591596
www_root: Path
597+
select_output: Literal["no-html", "only-html"] | None
592598
quick: bool
593599
group: str
594600
log_directory: Path
595601
skip_cache_invalidation: bool
596602
theme: Path
597603

598604
@property
599-
def full_build(self):
600-
"""Tell if a full build is needed.
601-
602-
A full build is slow; it builds pdf, txt, epub, texinfo, and
603-
archives everything.
604-
605-
A partial build only builds HTML and does not archive, it's
606-
fast.
607-
"""
608-
return not self.quick and not self.language.html_only
605+
def html_only(self):
606+
return (
607+
self.select_output == "only-html" or self.quick or self.language.html_only
608+
)
609609

610610
def run(self, http: urllib3.PoolManager) -> bool:
611611
"""Build and publish a Python doc, for a language, and a version."""
@@ -698,15 +698,13 @@ def build(self):
698698

699699
if self.version.status == "EOL":
700700
sphinxopts.append("-D html_context.outdated=1")
701-
maketarget = (
702-
"autobuild-"
703-
+ (
704-
"dev"
705-
if self.version.status in ("in development", "pre-release")
706-
else "stable"
707-
)
708-
+ ("" if self.full_build else "-html")
709-
)
701+
702+
if self.version.status in ("in development", "pre-release"):
703+
maketarget = "autobuild-dev"
704+
else:
705+
maketarget = "autobuild-stable"
706+
if self.html_only:
707+
maketarget += "-html"
710708
logging.info("Running make %s", maketarget)
711709
python = self.venv / "bin" / "python"
712710
sphinxbuild = self.venv / "bin" / "sphinx-build"
@@ -815,28 +813,18 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
815813
";",
816814
]
817815
)
818-
if self.full_build:
819-
run(
820-
[
821-
"rsync",
822-
"-a",
823-
"--delete-delay",
824-
"--filter",
825-
"P archives/",
826-
str(self.checkout / "Doc" / "build" / "html") + "/",
827-
target,
828-
]
829-
)
830-
else:
831-
run(
832-
[
833-
"rsync",
834-
"-a",
835-
str(self.checkout / "Doc" / "build" / "html") + "/",
836-
target,
837-
]
838-
)
839-
if self.full_build:
816+
run(
817+
[
818+
"rsync",
819+
"-a",
820+
"--delete-delay",
821+
"--filter",
822+
"P archives/",
823+
str(self.checkout / "Doc" / "build" / "html") + "/",
824+
target,
825+
]
826+
)
827+
if not self.quick:
840828
logging.debug("Copying dist files.")
841829
run(
842830
[
@@ -1201,8 +1189,17 @@ def main():
12011189
args = parse_args()
12021190
setup_logging(args.log_directory)
12031191

1192+
if args.select_output is None:
1193+
build_docs_with_lock(args, "build_docs.lock")
1194+
elif args.select_output == "no-html":
1195+
build_docs_with_lock(args, "build_docs_archives.lock")
1196+
elif args.select_output == "only-html":
1197+
build_docs_with_lock(args, "build_docs_html.lock")
1198+
1199+
1200+
def build_docs_with_lock(args, lockfile_name):
12041201
try:
1205-
lock = zc.lockfile.LockFile(HERE / "build_docs.lock")
1202+
lock = zc.lockfile.LockFile(HERE / lockfile_name)
12061203
except zc.lockfile.LockError:
12071204
logging.info("Another builder is running... dying...")
12081205
return EX_FAILURE

0 commit comments

Comments
 (0)
Please sign in to comment.