3636import sys
3737import time
3838from bisect import bisect_left as bisect
39- from collections import OrderedDict , namedtuple
39+ from collections import OrderedDict
4040from contextlib import contextmanager
4141from pathlib import Path
4242from string import Template
@@ -637,15 +637,32 @@ def setup_logging(log_directory: Path):
637637 logging .getLogger ().setLevel (logging .DEBUG )
638638
639639
640- class DocBuilder (
641- namedtuple (
642- "DocBuilder" ,
643- "version, language, build_root, www_root, quick, group, "
644- "log_directory, skip_cache_invalidation, theme" ,
645- )
646- ):
640+ @dataclass
641+ class DocBuilder :
647642 """Builder for a cpython version and a language."""
648643
644+ version : Version
645+ language : Language
646+ build_root : Path
647+ www_root : Path
648+ quick : bool
649+ group : str
650+ log_directory : Path
651+ skip_cache_invalidation : bool
652+ theme : Path
653+
654+ @property
655+ def full_build (self ):
656+ """Tell if a full build is needed.
657+
658+ A full build is slow, it builds pdf, txt, epub, texinfo, and
659+ archives everything.
660+
661+ A partial build only builds HTML and does not archive, it's
662+ fast.
663+ """
664+ return not self .quick and not self .language .html_only
665+
649666 def run (self ):
650667 """Build and publish a Python doc, for a language, and a version."""
651668 try :
@@ -718,7 +735,7 @@ def build(self):
718735 if self .version .status in ("in development" , "pre-release" )
719736 else "stable"
720737 )
721- + ("-html " if self .quick or self . language . html_only else "" )
738+ + ("" if self .full_build else "-html " )
722739 )
723740 logging .info ("Running make %s" , maketarget )
724741 python = self .venv / "bin" / "python"
@@ -830,11 +847,14 @@ def copy_build_to_webroot(self):
830847 ";" ,
831848 ]
832849 )
833- if self .quick :
850+ if self .full_build :
834851 run (
835852 [
836853 "rsync" ,
837854 "-a" ,
855+ "--delete-delay" ,
856+ "--filter" ,
857+ "P archives/" ,
838858 str (self .checkout / "Doc" / "build" / "html" ) + "/" ,
839859 target ,
840860 ]
@@ -844,14 +864,11 @@ def copy_build_to_webroot(self):
844864 [
845865 "rsync" ,
846866 "-a" ,
847- "--delete-delay" ,
848- "--filter" ,
849- "P archives/" ,
850867 str (self .checkout / "Doc" / "build" / "html" ) + "/" ,
851868 target ,
852869 ]
853870 )
854- if not self .quick :
871+ if self .full_build :
855872 logging .debug ("Copying dist files" )
856873 run (
857874 [
@@ -986,7 +1003,7 @@ def purge_path(www_root: Path, path: Path):
9861003 run (["curl" , "-XPURGE" , f"https://docs.python.org/{{{ ',' .join (to_purge )} }}" ])
9871004
9881005
989- def main ():
1006+ def main () -> None :
9901007 """Script entry point."""
9911008 args = parse_args ()
9921009 setup_logging (args .log_directory )
0 commit comments