From d3abad979ccf06e6d17e9a06537ee763a486606f Mon Sep 17 00:00:00 2001 From: Tim Grelka Date: Wed, 12 Nov 2025 10:37:21 +0100 Subject: [PATCH] feat: add current element to progress bar --- src/build.py | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/build.py b/src/build.py index 171d62c..260a706 100644 --- a/src/build.py +++ b/src/build.py @@ -280,28 +280,20 @@ class Build: TextColumn("[progress.description]{task.description}"), transient=True, ) as progress: - for number, chapter in enumerate( - progress.track(chapters, description=f"Building edition {edition}"), 1 - ): + chapter_task = progress.add_task(f"Building edition {edition} ...") + for number, chapter in enumerate(progress.track(chapters, task_id=chapter_task), 1): + progress.update(chapter_task, description=f"Buildign edition {edition}: Chapter {chapter['title']}") next_chapter = chapters[number] if number < len(chapters) else None self.__build_chapter(edition, edition_name, number, chapter, next_chapter) self.__build_chapter_slidedeck(edition, chapter, chapter["sections"], next_chapter) - with Progress( - TaskProgressColumn(), - BarColumn(), - TimeRemainingColumn(), - TextColumn("[progress.description]{task.description}"), - transient=True, - ) as section_progress: - for i, section in enumerate( - section_progress.track( - chapter["sections"], description=f"Rendering chapter {chapter['title']}" - ), - 1, - ): - next_section = chapter["sections"][i] if i < len(chapter["sections"]) else None - self.__build_section(edition, edition_name, section, i, chapter, next_section, next_chapter) + section_task = progress.add_task(description="Rendering sections ...") + for i, section in enumerate(progress.track(chapter["sections"], task_id=section_task), 1): + progress.update(section_task, description=f"Rendering section {section['title']}") + next_section = chapter["sections"][i] if i < len(chapter["sections"]) else None + self.__build_section(edition, edition_name, section, i, chapter, next_section, next_chapter) + progress.remove_task(section_task) + progress.remove_task(chapter_task) def build_assets(self): self.config.p_build.mkdir(exist_ok=True)