-
Notifications
You must be signed in to change notification settings - Fork 1
Compile catalogs to top-level turtle_docstringdict_<lang> modules
#2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5f026ef
Compile catalogs to top-level `turtle_docstringdict_<lang>` modules, …
StanFromIreland 56c2a5b
Apply batched suggestions from code review
StanFromIreland 44e788e
Add an integration test
StanFromIreland 2a8706c
Avoid duplicate runs
StanFromIreland 0a66a26
Check non-existent entry is dropped from dict
StanFromIreland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| name: Integration test | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| FORCE_COLOR: 1 | ||
|
|
||
| jobs: | ||
| integration: | ||
| name: Translate, build & install on Python ${{ matrix.python }} | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python: [3.13, 3.14, 3.15] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | ||
| with: | ||
| python-version: ${{ matrix.python }} | ||
| allow-prereleases: true | ||
|
|
||
| - name: Install build dependencies | ||
| run: python -m pip install babel hatchling build | ||
|
|
||
| - name: Create a new translation | ||
| run: | | ||
| python scripts/i18n.py extract | ||
| python scripts/i18n.py init eo | ||
|
|
||
| - name: Translate one docstring | ||
| run: | | ||
| python - <<'PY' | ||
| import sys | ||
| sys.path.insert(0, "scripts") | ||
| import i18n | ||
|
|
||
| path = i18n.PO_DIR / "eo.po" | ||
| catalog = i18n.read_catalog(path) | ||
| for message in catalog: | ||
| if "turtle.Turtle.forward" in message.auto_comments: | ||
| message.string = "Movu la testudon antaŭen." | ||
| break | ||
| # A nonexistent name to check it is dropped at import. | ||
| catalog.add("Not a real docstring.", "Ne vera dokumentaĵo.", | ||
| auto_comments=["turtle.Turtle.nonexistent"]) | ||
| i18n.write_catalog(catalog, path) | ||
| PY | ||
| python scripts/i18n.py stats | ||
|
|
||
| - name: Build and install the wheel | ||
| run: | | ||
| python -m build --wheel | ||
| python -m pip install dist/*.whl | ||
|
|
||
| - name: Check the translated docstring is used | ||
| working-directory: ${{ runner.temp }} | ||
| run: | | ||
| echo "language = eo" > turtle.cfg | ||
| cat > check.py <<'PY' | ||
| import contextlib | ||
| import io | ||
|
|
||
| # turtle prints errors for names it cannot resolve. | ||
| with contextlib.redirect_stdout(io.StringIO()) as output: | ||
| import turtle | ||
| assert output.getvalue() == "" | ||
|
|
||
| assert turtle.Turtle.forward.__doc__ == "Movu la testudon antaŭen." | ||
| assert turtle.forward.__doc__ == "Movu la testudon antaŭen." | ||
| assert "Move the turtle backward" in turtle.back.__doc__ | ||
|
|
||
| import turtle_docstringdict_eo | ||
| assert "Turtle.nonexistent" not in turtle_docstringdict_eo.docsdict | ||
| assert not hasattr(turtle.Turtle, "nonexistent") | ||
| PY | ||
| python check.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ name: Upload package | |
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| release: | ||
| types: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we were to go ahead with this, could we please cover this fragment with a test that ensures it doesn't fail in runtime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, I've added an integration test that runs with 3.13, 3.14 and 3.15 and asserts this works. I'll look into cherry-picking your (more precise) tests from the other PR and including one for this.