Skip to content

Commit

Permalink
Explicity control whether menu is rebuilt
Browse files Browse the repository at this point in the history
  • Loading branch information
guyer committed Jul 18, 2023
1 parent ed09b72 commit 1adcc48
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion update_pages/ntd2d_action/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def update_pages(self, branch, sha):
gha_utils.debug(f".nojekyll")

# replace any built documents in directory named for current branch
variant = Variant(repo=self, name=branch)
variant = Variant(repo=self, name=branch, rebuild_menu=True)

gha_utils.debug(f"Variant {variant.name}")

Expand Down
23 changes: 15 additions & 8 deletions update_pages/ntd2d_action/variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
from .files import VariantsFile, MenuFile, IndexFile, CSSFile

class Variant:
def __init__(self, repo, name, true_name=None):
def __init__(self, repo, name, rebuild_menu=False, true_name=None):
self.repo = repo
self.name = name
self.rebuild_menu = rebuild_menu
if true_name is None:
self.true_name = name
else:
Expand Down Expand Up @@ -66,7 +67,10 @@ def clone(self, name, cls=None):
gha_utils.debug(f"{self.name}.clone({name})")
if cls is None:
cls = self.__class__
clone = cls(repo=self.repo, name=name, true_name=self.true_name)
clone = cls(repo=self.repo,
name=name,
rebuild_menu=True,
true_name=self.true_name)
# this will clone any files in _static and _downloads, too
clone.copy_html(src=self.dir)
dst = clone.dir / "_downloads"
Expand All @@ -78,7 +82,9 @@ def clone(self, name, cls=None):

@classmethod
def from_variant(cls, variant):
new_variant = cls(variant.repo, variant.name)
new_variant = cls(repo=variant.repo,
name=variant.name,
rebuild_menu=variant.rebuild_menu)
new_variant.downloads = variant.downloads.copy()

return new_variant
Expand Down Expand Up @@ -112,8 +118,8 @@ class Version(Variant):
InvalidVersion
If the name is not parsable by packaging.version
"""
def __init__(self, repo, name):
super().__init__(repo=repo, name=name)
def __init__(self, repo, name, rebuild_menu=False):
super().__init__(repo=repo, name=name, rebuild_menu=rebuild_menu)
self.version = parse(name)

def __lt__(self, other):
Expand Down Expand Up @@ -237,9 +243,10 @@ def write_files(self, pages_url):
# Need an absolute url because this gets included from
# many different levels
for variant in self.latest + self.stable + [self.current_variant]:
MenuFile(variant=variant,
variants_url=url.geturl()).write()
CSSFile(variant=variant).write()
if variant.rebuild_menu:
MenuFile(variant=variant,
variants_url=url.geturl()).write()
CSSFile(variant=variant).write()


# This can be a relative url, because all variants should
Expand Down

0 comments on commit 1adcc48

Please sign in to comment.