| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,14 +2,16 @@ name: Build and Deploy to GitHub Pages | |||
| 2 | 2 | ||
| 3 | 3 | on: | |
| 4 | 4 | schedule: | |
| 5 | - - cron: '0 2 * * *' | ||
| 5 | + - cron: '0 2 * * *' | ||
| 6 | 6 | push: | |
| 7 | 7 | branches: | |
| 8 | 8 | - 3.14 | |
| 9 | 9 | workflow_dispatch: | |
| 10 | 10 | ||
| 11 | 11 | permissions: | |
| 12 | - contents: write | ||
| 12 | + contents: read | ||
| 13 | + pages: write | ||
| 14 | + id-token: write | ||
| 13 | 15 | ||
| 14 | 16 | concurrency: | |
| 15 | 17 | group: "pages" | |
@@ -24,41 +26,52 @@ jobs: | |||
| 24 | 26 | with: | |
| 25 | 27 | repository: python/cpython | |
| 26 | 28 | ref: v3.14.6 | |
| 27 | - | ||
| 29 | + | ||
| 28 | 30 | - name: Set up Python | |
| 29 | 31 | uses: actions/setup-python@v4 | |
| 30 | 32 | with: | |
| 31 | 33 | python-version: '3.12' | |
| 32 | - | ||
| 34 | + | ||
| 33 | 35 | - name: Setup virtual environment | |
| 34 | 36 | run: make venv | |
| 35 | 37 | working-directory: ./Doc | |
| 36 | - | ||
| 38 | + | ||
| 37 | 39 | - name: Checkout translation files | |
| 38 | 40 | uses: actions/checkout@v4 | |
| 39 | 41 | with: | |
| 40 | 42 | path: Doc/locales/fa/LC_MESSAGES | |
| 41 | 43 | ||
| 42 | - - name: Install gettext | ||
| 43 | - run: sudo apt-get install -y gettext | ||
| 44 | + - name: Strip stray fuzzy markers | ||
| 45 | + run: python3 Doc/locales/fa/LC_MESSAGES/scripts/strip_fuzzy.py $(find Doc/locales/fa/LC_MESSAGES -name "*.po" -not -path "*/.git/*") | ||
| 44 | 46 | ||
| 45 | 47 | - name: Compile .po files to .mo | |
| 46 | 48 | run: | | |
| 47 | - find Doc/locales/fa/LC_MESSAGES -name "*.po" | while read f; do | ||
| 49 | + find Doc/locales/fa/LC_MESSAGES -name "*.po" -not -path "*/.git/*" | while read f; do | ||
| 48 | 50 | msgfmt "$f" -o "${f%.po}.mo" | |
| 49 | 51 | done | |
| 50 | 52 | ||
| 51 | 53 | - name: Setup problem matcher | |
| 52 | 54 | uses: sphinx-doc/github-problem-matcher@v1.1 | |
| 53 | - | ||
| 55 | + | ||
| 54 | 56 | - name: Build documentation | |
| 55 | 57 | run: make -e SPHINXOPTS="--color -D language='fa' -D gettext_allow_fuzzy_translations=1 --keep-going" html | |
| 56 | 58 | working-directory: ./Doc | |
| 57 | - | ||
| 58 | - - name: Deploy to gh-pages | ||
| 59 | - uses: peaceiris/actions-gh-pages@v4 | ||
| 59 | + | ||
| 60 | + - name: Setup Pages | ||
| 61 | + uses: actions/configure-pages@v4 | ||
| 62 | + | ||
| 63 | + - name: Upload artifact | ||
| 64 | + uses: actions/upload-pages-artifact@v3 | ||
| 60 | 65 | with: | |
| 61 | - github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| 62 | - publish_dir: Doc/build/html | ||
| 63 | - keep_files: true | ||
| 64 | - enable_jekyll: false | ||
| 66 | + path: Doc/build/html | ||
| 67 | + | ||
| 68 | + deploy: | ||
| 69 | + environment: | ||
| 70 | + name: github-pages | ||
| 71 | + url: ${{ steps.deployment.outputs.page_url }} | ||
| 72 | + runs-on: ubuntu-latest | ||
| 73 | + needs: build | ||
| 74 | + steps: | ||
| 75 | + - name: Deploy to GitHub Pages | ||
| 76 | + id: deployment | ||
| 77 | + uses: actions/deploy-pages@v4 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,24 @@ | |||
| 1 | + version: 2 | ||
| 2 | + | ||
| 3 | + build: | ||
| 4 | + os: ubuntu-24.04 | ||
| 5 | + tools: | ||
| 6 | + python: "3.12" | ||
| 7 | + | ||
| 8 | + commands: | ||
| 9 | + - git clone --depth 1 --branch v3.14.6 https://github.com/python/cpython venv/cpython | ||
| 10 | + - pip install -r venv/cpython/Doc/requirements.txt | ||
| 11 | + - mkdir -p venv/cpython/Doc/locales/fa/LC_MESSAGES | ||
| 12 | + - cp --parents *.po venv/cpython/Doc/locales/fa/LC_MESSAGES/ | ||
| 13 | + - find */ -name "*.po" -not -path "venv/*" | xargs -I{} cp --parents {} venv/cpython/Doc/locales/fa/LC_MESSAGES/ | ||
| 14 | + - find venv/cpython/Doc/locales/fa/LC_MESSAGES -name "*.po" | xargs python3 scripts/strip_fuzzy.py | ||
| 15 | + - 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 | ||
| 16 | + - python -m sphinx -T -j auto -b html | ||
| 17 | + -d $READTHEDOCS_OUTPUT/doctrees | ||
| 18 | + -D language=fa | ||
| 19 | + -D locale_dirs=locales | ||
| 20 | + -D gettext_compact=0 | ||
| 21 | + -D gettext_allow_fuzzy_translations=1 | ||
| 22 | + -D html_theme_options.is_rtl=1 | ||
| 23 | + venv/cpython/Doc | ||
| 24 | + $READTHEDOCS_OUTPUT/html | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,29 @@ | |||
| 1 | + #!/usr/bin/env python3 | ||
| 2 | + """Remove '#, fuzzy' marker lines from .po files. | ||
| 3 | + | ||
| 4 | + CPython's Tools/i18n/msgfmt.py treats a stray fuzzy flag on the file | ||
| 5 | + header as applying to every entry in the file, silently producing an | ||
| 6 | + empty .mo catalog. Since our translations are complete (not actually | ||
| 7 | + rough drafts), we strip the marker before compiling. | ||
| 8 | + """ | ||
| 9 | + import sys | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + def strip_fuzzy(path: str) -> None: | ||
| 13 | + with open(path, encoding="utf-8") as f: | ||
| 14 | + lines = f.readlines() | ||
| 15 | + | ||
| 16 | + kept = [line for line in lines if not line.lstrip().startswith("#, fuzzy")] | ||
| 17 | + | ||
| 18 | + if kept != lines: | ||
| 19 | + with open(path, "w", encoding="utf-8") as f: | ||
| 20 | + f.writelines(kept) | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + def main() -> None: | ||
| 24 | + for path in sys.argv[1:]: | ||
| 25 | + strip_fuzzy(path) | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + if __name__ == "__main__": | ||
| 29 | + main() | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments