Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ name: Build and Deploy to GitHub Pages

on:
schedule:
- cron: '0 2 * * *'
- cron: '0 2 * * *'
push:
branches:
- 3.14
workflow_dispatch:

permissions:
contents: write
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
Expand All @@ -24,41 +26,52 @@ jobs:
with:
repository: python/cpython
ref: v3.14.6

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Setup virtual environment
run: make venv
working-directory: ./Doc

- name: Checkout translation files
uses: actions/checkout@v4
with:
path: Doc/locales/fa/LC_MESSAGES

- name: Install gettext
run: sudo apt-get install -y gettext
- name: Strip stray fuzzy markers
run: python3 Doc/locales/fa/LC_MESSAGES/scripts/strip_fuzzy.py $(find Doc/locales/fa/LC_MESSAGES -name "*.po" -not -path "*/.git/*")

- name: Compile .po files to .mo
run: |
find Doc/locales/fa/LC_MESSAGES -name "*.po" | while read f; do
find Doc/locales/fa/LC_MESSAGES -name "*.po" -not -path "*/.git/*" | while read f; do
msgfmt "$f" -o "${f%.po}.mo"
done

- name: Setup problem matcher
uses: sphinx-doc/github-problem-matcher@v1.1

- name: Build documentation
run: make -e SPHINXOPTS="--color -D language='fa' -D gettext_allow_fuzzy_translations=1 --keep-going" html
working-directory: ./Doc

- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v4

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: Doc/build/html
keep_files: true
enable_jekyll: false
path: Doc/build/html

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
90 changes: 0 additions & 90 deletions .github/workflows/build-docs-preview.yml

This file was deleted.

149 changes: 0 additions & 149 deletions .github/workflows/comment-docs-preview.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: 2

build:
os: ubuntu-24.04
tools:
python: "3.12"

commands:
- git clone --depth 1 --branch v3.14.6 https://github.com/python/cpython venv/cpython
- pip install -r venv/cpython/Doc/requirements.txt
- mkdir -p venv/cpython/Doc/locales/fa/LC_MESSAGES
- cp --parents *.po venv/cpython/Doc/locales/fa/LC_MESSAGES/
- find */ -name "*.po" -not -path "venv/*" | xargs -I{} cp --parents {} venv/cpython/Doc/locales/fa/LC_MESSAGES/
- find venv/cpython/Doc/locales/fa/LC_MESSAGES -name "*.po" | xargs python3 scripts/strip_fuzzy.py
- find venv/cpython/Doc/locales/fa/LC_MESSAGES -name "*.po" | while read f; do python venv/cpython/Tools/i18n/msgfmt.py -o "${f%.po}.mo" "$f"; done
- python -m sphinx -T -j auto -b html
-d $READTHEDOCS_OUTPUT/doctrees
-D language=fa
-D locale_dirs=locales
-D gettext_compact=0
-D gettext_allow_fuzzy_translations=1
-D html_theme_options.is_rtl=1
venv/cpython/Doc
$READTHEDOCS_OUTPUT/html
29 changes: 29 additions & 0 deletions scripts/strip_fuzzy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python3
"""Remove '#, fuzzy' marker lines from .po files.

CPython's Tools/i18n/msgfmt.py treats a stray fuzzy flag on the file
header as applying to every entry in the file, silently producing an
empty .mo catalog. Since our translations are complete (not actually
rough drafts), we strip the marker before compiling.
"""
import sys


def strip_fuzzy(path: str) -> None:
with open(path, encoding="utf-8") as f:
lines = f.readlines()

kept = [line for line in lines if not line.lstrip().startswith("#, fuzzy")]

if kept != lines:
with open(path, "w", encoding="utf-8") as f:
f.writelines(kept)


def main() -> None:
for path in sys.argv[1:]:
strip_fuzzy(path)


if __name__ == "__main__":
main()
Loading