From aeaad60242b2ba63b0c8e83650de5399b86ff83c Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Wed, 20 Nov 2024 00:50:07 +0100 Subject: [PATCH 01/29] Check all against local gettext build --- generate.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/generate.py b/generate.py index d069fe68e..4cb52e6b9 100644 --- a/generate.py +++ b/generate.py @@ -4,13 +4,16 @@ # "potodo", # "jinja2", # ] +# +# [tool.uv.sources] +# potodo = { git = "https://git.afpy.org/maciek/potodo", branch = "pot" } # /// from datetime import datetime, timezone from pathlib import Path from shutil import rmtree from tempfile import TemporaryDirectory from git import Repo, GitCommandError -from potodo.potodo import scan_path +from potodo.potodo import merge_and_scan_path from jinja2 import Template completion_progress = [] @@ -26,7 +29,8 @@ print(f'failed to clone {language} {branch}') continue try: - completion = scan_path(clone_path, no_cache=True, hide_reserved=False, api_url='').completion + with TemporaryDirectory() as tmpdir: + completion = merge_and_scan_path(clone_path, pot_path=Path('../cpython/Doc/build/gettext'), tmpdir=Path(tmpdir), hide_reserved=False, api_url='').completion except OSError: print(f'failed to scan {language} {branch}') rmtree(clone_path) From c8ef090ea626c7d4e49536d0d50cfd7efe23689b Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Wed, 20 Nov 2024 00:51:05 +0100 Subject: [PATCH 02/29] Remove branch info as superfluous --- generate.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/generate.py b/generate.py index 4cb52e6b9..2a768706d 100644 --- a/generate.py +++ b/generate.py @@ -37,7 +37,7 @@ continue else: break - completion_progress.append((language, completion, branch)) + completion_progress.append((language, completion)) print(completion_progress[-1]) template = Template(""" @@ -50,13 +50,12 @@

Python Docs Translation Dashboard

- + -{% for language, completion, branch in completion_progress | sort(attribute=1) | reverse %} +{% for language, completion in completion_progress | sort(attribute=1) | reverse %} - From c2cd2f7c51dd960cd2085de68e7fc59876e43da1 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Wed, 20 Nov 2024 01:08:14 +0100 Subject: [PATCH 03/29] Clone CPython repo and build gettext --- generate.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/generate.py b/generate.py index 2a768706d..d40c2afd2 100644 --- a/generate.py +++ b/generate.py @@ -11,6 +11,7 @@ from datetime import datetime, timezone from pathlib import Path from shutil import rmtree +from subprocess import run from tempfile import TemporaryDirectory from git import Repo, GitCommandError from potodo.potodo import merge_and_scan_path @@ -19,7 +20,9 @@ completion_progress = [] generation_time = datetime.now(timezone.utc) -with TemporaryDirectory() as tmpdir: +with TemporaryDirectory() as clones_dir: + Repo.clone_from(f'https://github.com/python/cpython.git', Path(clones_dir, 'cpython'), depth=1, branch='3.13') + run(['make', '-C', Path(clones_dir, 'cpython/Doc'), 'gettext'], check=True) for language in ('es', 'fr', 'id', 'it', 'ja', 'ko', 'pl', 'pt-br', 'tr', 'uk', 'zh-cn', 'zh-tw'): clone_path = Path(tmpdir, language) for branch in ('3.13', '3.12', '3.11', '3.10', '3.9'): @@ -30,7 +33,7 @@ continue try: with TemporaryDirectory() as tmpdir: - completion = merge_and_scan_path(clone_path, pot_path=Path('../cpython/Doc/build/gettext'), tmpdir=Path(tmpdir), hide_reserved=False, api_url='').completion + completion = merge_and_scan_path(clone_path, pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), tmpdir=Path(tmpdir), hide_reserved=False, api_url='').completion except OSError: print(f'failed to scan {language} {branch}') rmtree(clone_path) From a2391005257d7a4d2423e57703183280103c6690 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Wed, 20 Nov 2024 01:14:17 +0100 Subject: [PATCH 04/29] Add Sphinx dependency --- generate.py | 1 + 1 file changed, 1 insertion(+) diff --git a/generate.py b/generate.py index d40c2afd2..964474f6a 100644 --- a/generate.py +++ b/generate.py @@ -3,6 +3,7 @@ # "gitpython", # "potodo", # "jinja2", +# "sphinx", # ] # # [tool.uv.sources] From e342c7482a6b7532851616e83baf7a447312b2f9 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Wed, 20 Nov 2024 01:15:39 +0100 Subject: [PATCH 05/29] Add blurb dependency --- generate.py | 1 + 1 file changed, 1 insertion(+) diff --git a/generate.py b/generate.py index 964474f6a..f0361fe7d 100644 --- a/generate.py +++ b/generate.py @@ -4,6 +4,7 @@ # "potodo", # "jinja2", # "sphinx", +# "blurb", # ] # # [tool.uv.sources] From b97808dc5d5a9a250e66c085d437fd459d182c33 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Wed, 20 Nov 2024 01:18:03 +0100 Subject: [PATCH 06/29] Fix clone path --- generate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate.py b/generate.py index f0361fe7d..f11d6a331 100644 --- a/generate.py +++ b/generate.py @@ -26,7 +26,7 @@ Repo.clone_from(f'https://github.com/python/cpython.git', Path(clones_dir, 'cpython'), depth=1, branch='3.13') run(['make', '-C', Path(clones_dir, 'cpython/Doc'), 'gettext'], check=True) for language in ('es', 'fr', 'id', 'it', 'ja', 'ko', 'pl', 'pt-br', 'tr', 'uk', 'zh-cn', 'zh-tw'): - clone_path = Path(tmpdir, language) + clone_path = Path(clones_dir, language) for branch in ('3.13', '3.12', '3.11', '3.10', '3.9'): try: Repo.clone_from(f'https://github.com/python/python-docs-{language}.git', clone_path, depth=1, branch=branch) From c5a19abfb8867df81059f1ab8c04f4ffa0d94c97 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Wed, 20 Nov 2024 01:20:47 +0100 Subject: [PATCH 07/29] Debug log --- generate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generate.py b/generate.py index f11d6a331..bef0d4ca5 100644 --- a/generate.py +++ b/generate.py @@ -36,8 +36,8 @@ try: with TemporaryDirectory() as tmpdir: completion = merge_and_scan_path(clone_path, pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), tmpdir=Path(tmpdir), hide_reserved=False, api_url='').completion - except OSError: - print(f'failed to scan {language} {branch}') + except OSError as e: + print(f'failed to scan {language} {branch}: {e}') rmtree(clone_path) continue else: From 058edc717f67834aa292b2a3f56c921baa16d730 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Wed, 20 Nov 2024 01:29:46 +0100 Subject: [PATCH 08/29] Install gettext in the workflow --- .github/workflows/update.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index c8bcec4c3..243346469 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -15,6 +15,7 @@ jobs: - uses: actions/setup-python@main - uses: astral-sh/setup-uv@main - uses: actions/checkout@main + - run: sudo apt-get install -y gettext - run: uv run generate.py # generates "index.html" - run: mkdir -p build && cp index.html style.css build - name: Deploy 🚀 From 14b44e9d1f88fd013bab4af183088e123f509fa7 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Wed, 20 Nov 2024 01:42:40 +0100 Subject: [PATCH 09/29] Format with black --- generate.py | 66 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/generate.py b/generate.py index bef0d4ca5..2921a34ea 100644 --- a/generate.py +++ b/generate.py @@ -29,13 +29,21 @@ clone_path = Path(clones_dir, language) for branch in ('3.13', '3.12', '3.11', '3.10', '3.9'): try: - Repo.clone_from(f'https://github.com/python/python-docs-{language}.git', clone_path, depth=1, branch=branch) + Repo.clone_from( + f'https://github.com/python/python-docs-{language}.git', clone_path, depth=1, branch=branch + ) except GitCommandError: print(f'failed to clone {language} {branch}') continue try: with TemporaryDirectory() as tmpdir: - completion = merge_and_scan_path(clone_path, pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), tmpdir=Path(tmpdir), hide_reserved=False, api_url='').completion + completion = merge_and_scan_path( + clone_path, + pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), + tmpdir=Path(tmpdir), + hide_reserved=False, + api_url='', + ).completion except OSError as e: print(f'failed to scan {language} {branch}: {e}') rmtree(clone_path) @@ -45,33 +53,33 @@ completion_progress.append((language, completion)) print(completion_progress[-1]) -template = Template(""" - - -Python Docs Translation Dashboard - - - -

Python Docs Translation Dashboard

-
languagebranchcompletion
languagecompletion
{{ language }}{{ branch }}
{{ completion | round(2) }}%
- - - - -{% for language, completion in completion_progress | sort(attribute=1) | reverse %} - - - - -{% endfor %} - -
languagecompletion
{{ language }} -
{{ completion | round(2) }}%
-
-

Last updated at {{ generation_time.strftime('%A, %d %B %Y, %X %Z') }}.

- - -""") +template = Template( + """ + + Python Docs Translation Dashboard + + + +

Python Docs Translation Dashboard

+ + + + + + {% for language, completion in completion_progress | sort(attribute=1) | reverse %} + + + + + {% endfor %} + +
languagecompletion
{{ language }} +
{{ completion | round(2) }}%
+
+

Last updated at {{ generation_time.strftime('%A, %d %B %Y, %X %Z') }}.

+ + """ +) output = template.render(completion_progress=completion_progress, generation_time=generation_time) From 2bfe4b79d8512e364ad723f34cdba4d8cf09c980 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Wed, 20 Nov 2024 13:31:43 +0100 Subject: [PATCH 10/29] Skip OSError handling -- covered by potodo now --- generate.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/generate.py b/generate.py index 2921a34ea..86e114f20 100644 --- a/generate.py +++ b/generate.py @@ -35,21 +35,14 @@ except GitCommandError: print(f'failed to clone {language} {branch}') continue - try: - with TemporaryDirectory() as tmpdir: - completion = merge_and_scan_path( - clone_path, - pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), - tmpdir=Path(tmpdir), - hide_reserved=False, - api_url='', - ).completion - except OSError as e: - print(f'failed to scan {language} {branch}: {e}') - rmtree(clone_path) - continue - else: - break + with TemporaryDirectory() as tmpdir: + completion = merge_and_scan_path( + clone_path, + pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), + tmpdir=Path(tmpdir), + hide_reserved=False, + api_url='', + ).completion completion_progress.append((language, completion)) print(completion_progress[-1]) From e82581092a2f7c36d58ca4679064a000004e6a75 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Wed, 20 Nov 2024 14:14:30 +0100 Subject: [PATCH 11/29] Improve styling --- style.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/style.css b/style.css index dd07efeb2..8346115ac 100644 --- a/style.css +++ b/style.css @@ -24,7 +24,7 @@ th { min-width: 50px; box-sizing: border-box; } -td:nth-child(3) { +td:last-child { width: 100%; } @media screen and (max-width: 600px) { @@ -52,7 +52,7 @@ td:nth-child(3) { left: 10px; position: absolute; } - td:nth-child(3) { + td:last-child { width: inherit; } .progress-bar { From 98207f7fe337e40fb9d17626fbc31e04a627df64 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Thu, 21 Nov 2024 11:28:11 +0100 Subject: [PATCH 12/29] Simplify scan after upstream change --- generate.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/generate.py b/generate.py index 86e114f20..6b2477848 100644 --- a/generate.py +++ b/generate.py @@ -35,14 +35,12 @@ except GitCommandError: print(f'failed to clone {language} {branch}') continue - with TemporaryDirectory() as tmpdir: - completion = merge_and_scan_path( - clone_path, - pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), - tmpdir=Path(tmpdir), - hide_reserved=False, - api_url='', - ).completion + completion = merge_and_scan_path( + clone_path, + pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), + hide_reserved=False, + api_url='', + ).completion completion_progress.append((language, completion)) print(completion_progress[-1]) From dd27f5544ff8464ce2398ca0eb2a86945c32157e Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Thu, 21 Nov 2024 11:29:11 +0100 Subject: [PATCH 13/29] Remove unused import --- generate.py | 1 - 1 file changed, 1 deletion(-) diff --git a/generate.py b/generate.py index 6b2477848..bc5fb2312 100644 --- a/generate.py +++ b/generate.py @@ -12,7 +12,6 @@ # /// from datetime import datetime, timezone from pathlib import Path -from shutil import rmtree from subprocess import run from tempfile import TemporaryDirectory from git import Repo, GitCommandError From f420781b35a785313e02db0f68367d509fab2776 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Thu, 21 Nov 2024 12:08:32 +0100 Subject: [PATCH 14/29] Fix: break the versions loop when cloned --- generate.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/generate.py b/generate.py index bc5fb2312..83bca2650 100644 --- a/generate.py +++ b/generate.py @@ -34,12 +34,11 @@ except GitCommandError: print(f'failed to clone {language} {branch}') continue - completion = merge_and_scan_path( - clone_path, - pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), - hide_reserved=False, - api_url='', - ).completion + else: + break + completion = merge_and_scan_path( + clone_path, pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), hide_reserved=False, api_url='' + ).completion completion_progress.append((language, completion)) print(completion_progress[-1]) From 83a785d3714f2216ab9b6b9865a68ef16985fb77 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Fri, 22 Nov 2024 12:05:46 +0100 Subject: [PATCH 15/29] Make cpython docs venv --- generate.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/generate.py b/generate.py index 83bca2650..dd1ac8543 100644 --- a/generate.py +++ b/generate.py @@ -3,8 +3,6 @@ # "gitpython", # "potodo", # "jinja2", -# "sphinx", -# "blurb", # ] # # [tool.uv.sources] @@ -23,6 +21,7 @@ with TemporaryDirectory() as clones_dir: Repo.clone_from(f'https://github.com/python/cpython.git', Path(clones_dir, 'cpython'), depth=1, branch='3.13') + run(['make', '-C', Path(clones_dir, 'cpython/Doc'), 'venv'], check=True) run(['make', '-C', Path(clones_dir, 'cpython/Doc'), 'gettext'], check=True) for language in ('es', 'fr', 'id', 'it', 'ja', 'ko', 'pl', 'pt-br', 'tr', 'uk', 'zh-cn', 'zh-tw'): clone_path = Path(clones_dir, language) From 26db37b6f762a1011ab5adb9f6c22b2bcd36d202 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Fri, 22 Nov 2024 12:36:34 +0100 Subject: [PATCH 16/29] fix: bring back outer temp directory --- generate.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/generate.py b/generate.py index dd1ac8543..974ba32a7 100644 --- a/generate.py +++ b/generate.py @@ -35,9 +35,10 @@ continue else: break - completion = merge_and_scan_path( - clone_path, pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), hide_reserved=False, api_url='' - ).completion + with TemporaryDirectory() as tmpdir: + completion = merge_and_scan_path( + clone_path, pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), hide_reserved=False, api_url='', tmpdir=Path(tmpdir) + ).completion completion_progress.append((language, completion)) print(completion_progress[-1]) From 681a306917130b8ee2acc33152b48812ca4f982b Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Fri, 22 Nov 2024 12:37:53 +0100 Subject: [PATCH 17/29] revert format on template --- generate.py | 52 +++++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/generate.py b/generate.py index 974ba32a7..a4363add4 100644 --- a/generate.py +++ b/generate.py @@ -42,33 +42,31 @@ completion_progress.append((language, completion)) print(completion_progress[-1]) -template = Template( - """ - - Python Docs Translation Dashboard - - - -

Python Docs Translation Dashboard

- - - - - - {% for language, completion in completion_progress | sort(attribute=1) | reverse %} - - - - - {% endfor %} - -
languagecompletion
{{ language }} -
{{ completion | round(2) }}%
-
-

Last updated at {{ generation_time.strftime('%A, %d %B %Y, %X %Z') }}.

- - """ -) +template = Template(""" + + Python Docs Translation Dashboard + + + +

Python Docs Translation Dashboard

+ + + + + +{% for language, completion in completion_progress | sort(attribute=1) | reverse %} + + + + +{% endfor %} + +
languagecompletion
{{ language }} +
{{ completion | round(2) }}%
+
+

Last updated at {{ generation_time.strftime('%A, %d %B %Y, %X %Z') }}.

+ +""") output = template.render(completion_progress=completion_progress, generation_time=generation_time) From 9aa811727ec12a9ba05b6ddcae4c22d53b9faa61 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Thu, 5 Dec 2024 08:33:55 +0100 Subject: [PATCH 18/29] update call argument name --- generate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate.py b/generate.py index 1b7294f14..72ed33898 100644 --- a/generate.py +++ b/generate.py @@ -37,7 +37,7 @@ break with TemporaryDirectory() as tmpdir: completion = merge_and_scan_path( - clone_path, pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), hide_reserved=False, api_url='', tmpdir=Path(tmpdir) + clone_path, pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), hide_reserved=False, api_url='', merge_path=Path(tmpdir) ).completion completion_progress.append((language, completion)) print(completion_progress[-1]) From da92325d592d30c3e75eaeb3752267b74cb11453 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Sun, 8 Dec 2024 22:15:21 +0100 Subject: [PATCH 19/29] Remove custom potodo version and a note from template --- generate.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/generate.py b/generate.py index 72ed33898..8d2057f56 100644 --- a/generate.py +++ b/generate.py @@ -4,9 +4,6 @@ # "potodo", # "jinja2", # ] -# -# [tool.uv.sources] -# potodo = { git = "https://git.afpy.org/maciek/potodo", branch = "pot" } # /// from datetime import datetime, timezone from pathlib import Path @@ -42,7 +39,8 @@ completion_progress.append((language, completion)) print(completion_progress[-1]) -template = Template(""" +template = Template(""" + Python Docs Translation Dashboard @@ -69,9 +67,9 @@

Last updated at {{ generation_time.strftime('%A, %d %B %Y, %X %Z') }}.

-

Note that the completion value is based on files available in language Git repository and may not include e.g. resources which translation hasn't yet started.

-""") + +""") output = template.render(completion_progress=completion_progress, generation_time=generation_time) From 6323a16a1603d7dccad94ec6bb29300dfd7236f2 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Sun, 8 Dec 2024 23:47:52 +0100 Subject: [PATCH 20/29] Install GNU Gettext in Read the Docs, reorder arguments --- .readthedocs.yml | 1 + generate.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 7d3909c07..04cbf25df 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -12,6 +12,7 @@ build: - asdf plugin add uv - asdf install uv latest - asdf global uv latest + - sudo apt-get install -y gettext - uv run generate.py - mkdir -p _readthedocs/html - mv index.html style.css _readthedocs/html diff --git a/generate.py b/generate.py index 8d2057f56..1e564de14 100644 --- a/generate.py +++ b/generate.py @@ -34,7 +34,7 @@ break with TemporaryDirectory() as tmpdir: completion = merge_and_scan_path( - clone_path, pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), hide_reserved=False, api_url='', merge_path=Path(tmpdir) + clone_path, pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), merge_path=Path(tmpdir), hide_reserved=False, api_url='' ).completion completion_progress.append((language, completion)) print(completion_progress[-1]) From 484bea9e208959e9f9d306716ede7e5c91f03a9d Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Sun, 8 Dec 2024 23:50:59 +0100 Subject: [PATCH 21/29] Remove sudo call in Read the Docs command --- .readthedocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 04cbf25df..02b8e3f32 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -12,7 +12,7 @@ build: - asdf plugin add uv - asdf install uv latest - asdf global uv latest - - sudo apt-get install -y gettext + - apt-get install -y gettext - uv run generate.py - mkdir -p _readthedocs/html - mv index.html style.css _readthedocs/html From c00b88bf1a5b608eb6de1474718a29393238a838 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Mon, 9 Dec 2024 01:09:46 +0100 Subject: [PATCH 22/29] Add gettext with apt_packages (test) --- .readthedocs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 02b8e3f32..443d25618 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -8,11 +8,12 @@ build: os: ubuntu-24.04 tools: python: "3" + apt_packages: + - gettext commands: - asdf plugin add uv - asdf install uv latest - asdf global uv latest - - apt-get install -y gettext - uv run generate.py - mkdir -p _readthedocs/html - mv index.html style.css _readthedocs/html From dec5e014f10b66d064f98f6f769f77902863c07a Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Mon, 9 Dec 2024 22:10:45 +0100 Subject: [PATCH 23/29] convert command to jobs --- .readthedocs.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 443d25618..0660cf1db 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -10,10 +10,15 @@ build: python: "3" apt_packages: - gettext - commands: - - asdf plugin add uv - - asdf install uv latest - - asdf global uv latest - - uv run generate.py - - mkdir -p _readthedocs/html - - mv index.html style.css _readthedocs/html + jobs: + post_checkout: + - asdf plugin add uv + install: + - asdf install uv latest + pre_build: + - asdf global uv latest + build: + html: + - uv run generate.py + - mkdir -p _readthedocs/html + - mv index.html style.css _readthedocs/html From 44551e6816b5bd004e3f90705e6c5b13ce4b033c Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Mon, 9 Dec 2024 22:14:36 +0100 Subject: [PATCH 24/29] move plugin add to install group --- .readthedocs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 0660cf1db..59be58c86 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -11,9 +11,9 @@ build: apt_packages: - gettext jobs: - post_checkout: - - asdf plugin add uv + post_checkout: [] install: + - asdf plugin add uv - asdf install uv latest pre_build: - asdf global uv latest From 77be670da90afd0762761490c99033288f04aef1 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Mon, 9 Dec 2024 22:30:37 +0100 Subject: [PATCH 25/29] Align visitors number to right --- style.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/style.css b/style.css index 8346115ac..e1e6c11a5 100644 --- a/style.css +++ b/style.css @@ -24,6 +24,9 @@ th { min-width: 50px; box-sizing: border-box; } +td:nth-child(2) { + text-align: right; +} td:last-child { width: 100%; } From 65ef8c62f101fa34143a981157a2e563f0221c04 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Mon, 9 Dec 2024 22:32:11 +0100 Subject: [PATCH 26/29] Revert "Align visitors number to right" This reverts commit 77be670da90afd0762761490c99033288f04aef1. --- style.css | 3 --- 1 file changed, 3 deletions(-) diff --git a/style.css b/style.css index e1e6c11a5..8346115ac 100644 --- a/style.css +++ b/style.css @@ -24,9 +24,6 @@ th { min-width: 50px; box-sizing: border-box; } -td:nth-child(2) { - text-align: right; -} td:last-child { width: 100%; } From d7683c65f4c8fd82515554f85bf5479110ce9ed8 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Mon, 9 Dec 2024 23:54:32 +0100 Subject: [PATCH 27/29] Add missing import --- completion.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/completion.py b/completion.py index 9d12a8658..1ea3cc1ae 100644 --- a/completion.py +++ b/completion.py @@ -1,5 +1,6 @@ import shutil from pathlib import Path +from tempfile import TemporaryDirectory import git from potodo import potodo @@ -17,7 +18,7 @@ def get_completion(clones_dir: str, language: str) -> float: continue else: break - with TemporaryDirectory() as tmpdir: + with tempfile.TemporaryDirectory() as tmpdir: completion = potodo.merge_and_scan_path( clone_path, pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), merge_path=Path(tmpdir), hide_reserved=False, api_url='' ).completion From 828ea976601eb2d2f4f53ace4f27b8a201641d56 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Tue, 10 Dec 2024 00:01:19 +0100 Subject: [PATCH 28/29] Update completion.py: fix reference --- completion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/completion.py b/completion.py index 1ea3cc1ae..eec8a9026 100644 --- a/completion.py +++ b/completion.py @@ -18,7 +18,7 @@ def get_completion(clones_dir: str, language: str) -> float: continue else: break - with tempfile.TemporaryDirectory() as tmpdir: + with TemporaryDirectory() as tmpdir: completion = potodo.merge_and_scan_path( clone_path, pot_path=Path(clones_dir, 'cpython/Doc/build/gettext'), merge_path=Path(tmpdir), hide_reserved=False, api_url='' ).completion From 6067937d45539b7b51e7990cc9ad7ff2d1915161 Mon Sep 17 00:00:00 2001 From: Maciej Olko Date: Tue, 10 Dec 2024 04:06:26 +0100 Subject: [PATCH 29/29] Add missing CPython clone code --- generate.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/generate.py b/generate.py index a00e145fa..7f4e93d78 100644 --- a/generate.py +++ b/generate.py @@ -6,9 +6,12 @@ # "requests", # ] # /// +import subprocess from datetime import datetime, timezone +from pathlib import Path from tempfile import TemporaryDirectory +from git import Repo from jinja2 import Template import completion @@ -18,6 +21,9 @@ generation_time = datetime.now(timezone.utc) with TemporaryDirectory() as clones_dir: + Repo.clone_from(f'https://github.com/python/cpython.git', Path(clones_dir, 'cpython'), depth=1, branch='3.13') + subprocess.run(['make', '-C', Path(clones_dir, 'cpython/Doc'), 'venv'], check=True) + subprocess.run(['make', '-C', Path(clones_dir, 'cpython/Doc'), 'gettext'], check=True) for language in ('es', 'fr', 'id', 'it', 'ja', 'ko', 'pl', 'pt-br', 'tr', 'uk', 'zh-cn', 'zh-tw'): completion_number = completion.get_completion(clones_dir, language) visitors_number = visitors.get_number_of_visitors(language)