diff --git a/.github/ISSUE_TEMPLATE/file_reservation.md b/.github/ISSUE_TEMPLATE/file_reservation.md index c498b2327..beefb3dbd 100644 --- a/.github/ISSUE_TEMPLATE/file_reservation.md +++ b/.github/ISSUE_TEMPLATE/file_reservation.md @@ -8,4 +8,5 @@ assignees: '' diff --git a/.github/workflows/pr_limit.yml b/.github/workflows/pr_limit.yml new file mode 100644 index 000000000..d8f77be25 --- /dev/null +++ b/.github/workflows/pr_limit.yml @@ -0,0 +1,87 @@ +name: pr-limit +# Contributors may have at most MAX_OPEN_PRS open pull requests at a time. +# This labels and comments on pull requests over the limit, +# and removes the label once the author is back under it. +# +# pull_request_target runs with a write token, so this workflow must never +# check out or run code from the pull request. It only calls the GitHub API. +on: + pull_request_target: + types: [opened, reopened, closed] +permissions: + issues: write + pull-requests: write +env: + MAX_OPEN_PRS: 3 + LABEL: too-many-prs +jobs: + check: + runs-on: ubuntu-latest + # Maintainers and bots are exempt. + if: >- + github.event.pull_request.user.type != 'Bot' && + !contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association) + steps: + - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const max = Number(process.env.MAX_OPEN_PRS); + const label = process.env.LABEL; + const { owner, repo } = context.repo; + const pr = context.payload.pull_request; + const author = pr.user.login; + + const open = ( + await github.paginate(github.rest.pulls.list, { + owner, repo, state: "open", per_page: 100, + }) + ).filter((p) => p.user.login === author); + core.info(`${author} has ${open.length} open pull request(s).`); + + const hasLabel = (p) => p.labels.some((l) => l.name === label); + + if (context.payload.action === "closed") { + if (open.length > max) return; + for (const p of open.filter(hasLabel)) { + await github.rest.issues.removeLabel({ + owner, repo, issue_number: p.number, name: label, + }); + } + return; + } + + if (open.length <= max) return; + + try { + await github.rest.issues.getLabel({ owner, repo, name: label }); + } catch (error) { + if (error.status !== 404) throw error; + await github.rest.issues.createLabel({ + owner, repo, name: label, color: "D93F0B", + description: `Author has more than ${max} open pull requests`, + }); + } + await github.rest.issues.addLabels({ + owner, repo, issue_number: pr.number, labels: [label], + }); + + const readme = `${context.serverUrl}/${owner}/${repo}/blob/HEAD/README.md`; + const list = open + .filter((p) => p.number !== pr.number) + .map((p) => `- #${p.number}`) + .join("\n"); + await github.rest.issues.createComment({ + owner, repo, issue_number: pr.number, + body: [ + `Merhaba @${author}, katkınız için teşekkürler!`, + "", + `Şu anda ${open.length} açık pull request'iniz var.`, + `Her katkıyı dikkatle inceleyebilmek için bir kişinin aynı anda en fazla ${max} açık pull request'i olabilir.`, + "Lütfen yeni bir pull request açmadan önce açık olanlardan birinin birleştirilmesini ya da kapatılmasını bekleyin.", + "", + "Diğer açık pull request'leriniz:", + list, + "", + `Ayrıntılar için [README](${readme}) dosyasına bakabilirsiniz.`, + ].join("\n"), + }); diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 000000000..6d549923d --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,79 @@ +# AGENTS.md + +Guidance for coding agents (Claude Code, Codex, Copilot, Cursor, and others) +working in this repository. +The human-facing guide is [README.md](README.md), written in Turkish. +When the two disagree, the README wins. + +## What this repository is + +The Turkish translation of the Python documentation. +Each `.po` file mirrors one `.rst` file under `Doc/` in +[python/cpython](https://github.com/python/cpython), +at the path and branch named in the `Makefile` +(`BRANCH` and `CPYTHON_CURRENT_COMMIT`). + +- The default branch is `3.15`. Open pull requests against it. +- `msgid` is the English source. Only `msgstr` is translated. +- Never edit a `msgid`, the file header, or the `#:` location comments by hand. + `merge.py` regenerates them from CPython once a month (`.github/workflows/update_doc.yml`). + +## Contribution rules + +- **At most 3 open pull requests per author at a time.** + `.github/workflows/pr_limit.yml` labels and comments on PRs over the limit. + Finish or close one before you open another. +- Work on one `.po` file per branch and pull request, as the README's steps do. +- Reserve a file before translating it, + with the "Rezervasyon" issue template (`.github/ISSUE_TEMPLATE/file_reservation.md`). + Do not translate a file someone else has reserved. +- Entries flagged `#, fuzzy` are not used in the build. + Remove the flag only after you have checked and updated the translation. + +## Translation rules + +- Keep role and link targets in English, or the Sphinx build fails + (`i18n.inconsistent_references`). + - Roles: translate only the shown text, + e.g. `` :term:`dosya nesnesi ` ``. + A bare `` :func:`len` `` stays as it is. + - Named links: leave `` `Documentation bugs`_ `` untouched. +- Keep reST markup, code samples, literals (` ``...`` `), and placeholders + (`%s`, `{name}`) exactly as in the `msgid`. +- Use the term already used elsewhere in the repository. + For example `string` is `dize`, not `metin`. + Search existing `msgstr` entries with `rg` before choosing a term. +- Write correct Turkish spelling, checked against the + [TDK dictionary](https://sozluk.gov.tr/). + +## Commands + +Set up: + +```sh +python -m pip install --upgrade -r requirements-dev.txt +pre-commit install +``` + +Before committing a `.po` file: + +```sh +powrap path/to/file.po # rewrap to the project's line width +pre-commit run --files path/to/file.po +``` + +Build the HTML docs locally (clones CPython into `venv/cpython`): + +```sh +make +``` + +Other `Makefile` targets: `make todo` (progress), `make fuzzy`, `make verifs`. + +## Layout + +- `*.po`, `
/*.po`: translations, laid out like CPython's `Doc/`. +- `merge.py`: pulls new strings from CPython into the `.po` files. +- `scripts/`: helper scripts (`format_check.py`, `progress.py`, `translate.py`). +- `.github/workflows/`: CI, monthly CPython sync, rewrap, and the PR limit check. +- `TRANSLATORS`: contributor credits. diff --git a/README.md b/README.md index a11117cf8..587525e90 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Bu proje gönüllü çevirmenler ve python-docs-tr ekibi iş birliğinde sürdü 1. TRANSLATORS dosyasına isminizi ekleyin. (Çeviri kabul edilirse yaptığınız katkı için övgü toplayabilirsiniz.) 2. GitHub üzerinden çevirilerinizi göndermek için ``3.15`` branch'ine bir pull request oluşturun. + - Aynı anda en fazla **3** açık pull request'iniz olabilir. Daha fazlasını açarsanız pull request'iniz ``too-many-prs`` etiketiyle işaretlenir. Yeni bir pull request açmadan önce açık olanlardan birinin birleştirilmesini ya da kapatılmasını bekleyin. 3. Çevirilerinizin kabul edilmesini bekleyin. - Bu süreçte çevirileriniz, uygunluğunu ve yazım hatalarını değerlendirmek için birkaç kişi tarafından incelenecektir. - İncelemenin sonucunda bazı değişiklikler yapmanız istenebilir.