36
36
import sys
37
37
import time
38
38
from bisect import bisect_left as bisect
39
- from collections import OrderedDict , namedtuple
39
+ from collections import OrderedDict
40
40
from contextlib import contextmanager
41
41
from pathlib import Path
42
42
from string import Template
@@ -637,15 +637,32 @@ def setup_logging(log_directory: Path):
637
637
logging .getLogger ().setLevel (logging .DEBUG )
638
638
639
639
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 :
647
642
"""Builder for a cpython version and a language."""
648
643
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
+
649
666
def run (self ):
650
667
"""Build and publish a Python doc, for a language, and a version."""
651
668
try :
@@ -718,7 +735,7 @@ def build(self):
718
735
if self .version .status in ("in development" , "pre-release" )
719
736
else "stable"
720
737
)
721
- + ("-html " if self .quick or self . language . html_only else "" )
738
+ + ("" if self .full_build else "-html " )
722
739
)
723
740
logging .info ("Running make %s" , maketarget )
724
741
python = self .venv / "bin" / "python"
@@ -830,11 +847,14 @@ def copy_build_to_webroot(self):
830
847
";" ,
831
848
]
832
849
)
833
- if self .quick :
850
+ if self .full_build :
834
851
run (
835
852
[
836
853
"rsync" ,
837
854
"-a" ,
855
+ "--delete-delay" ,
856
+ "--filter" ,
857
+ "P archives/" ,
838
858
str (self .checkout / "Doc" / "build" / "html" ) + "/" ,
839
859
target ,
840
860
]
@@ -844,14 +864,11 @@ def copy_build_to_webroot(self):
844
864
[
845
865
"rsync" ,
846
866
"-a" ,
847
- "--delete-delay" ,
848
- "--filter" ,
849
- "P archives/" ,
850
867
str (self .checkout / "Doc" / "build" / "html" ) + "/" ,
851
868
target ,
852
869
]
853
870
)
854
- if not self .quick :
871
+ if self .full_build :
855
872
logging .debug ("Copying dist files" )
856
873
run (
857
874
[
@@ -986,7 +1003,7 @@ def purge_path(www_root: Path, path: Path):
986
1003
run (["curl" , "-XPURGE" , f"https://docs.python.org/{{{ ',' .join (to_purge )} }}" ])
987
1004
988
1005
989
- def main ():
1006
+ def main () -> None :
990
1007
"""Script entry point."""
991
1008
args = parse_args ()
992
1009
setup_logging (args .log_directory )
0 commit comments