Skip to content

Commit

Permalink
Fix a number of nox -s translate issues.
Browse files Browse the repository at this point in the history
Really all the `nox -s translate -- <target>` should be tested. At least
with mypy, it woudl catch most errors
  • Loading branch information
Carreau committed Aug 20, 2024
1 parent 26fd0fb commit 6b87c32
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,24 @@ jobs:
- name: "Run accessibility tests with playwright 🎭"
# build PST, build docs, then run a11y-tests
run: python -Im tox run -e py312-docs,a11y-tests
nox-tests:
name: "nox tests (ubuntu-latest, 3.12)"
runs-on: ubuntu-latest
steps:
- name: "Checkout repository 🛎"
uses: actions/checkout@v4
- name: "Setup CI environment 🛠"
uses: ./.github/actions/set-dev-env
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
- name: "Run various nox commands"
# build PST, build docs, then run a11y-tests
run: |
pip install nox
nox -s translate -- init
nox -s translate -- extract
nox -s translate -- update
nox -s translate -- compile
# Build our docs (PST) on major OSes and check for warnings
build-site:
Expand Down
21 changes: 15 additions & 6 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def translate(session: nox.Session) -> None:
pybabel_cmd, found = (c, True)

if found is False:
print(
raise ValueError(
"No translate command found. Use like: `nox -s translate -- COMMAND`."
"\ndefaulting to `update`"
"\nAvailable commands: extract, update, compile, init"
Expand All @@ -166,18 +166,28 @@ def translate(session: nox.Session) -> None:
lan = "en" if len(session.posargs) < 2 else session.posargs[-1]

# get the path to the differnet local related pieces
locale_dir = str(ROOT / "src" / "pydata_sphinx_theme" / "locale")
locale_dir_p = ROOT / "src" / "pydata_sphinx_theme" / "locale"
locale_dir = str(locale_dir_p)
babel_cfg = str(ROOT / "babel.cfg")
pot_file = str(locale_dir / "sphinx.pot")
pot_file = str(locale_dir_p / "sphinx.pot")

# install deps
session.install("Babel")
session.install("jinja2")

# build the command from the parameters
cmd = ["pybabel", pybabel_cmd]

if pybabel_cmd == "extract":
cmd += [ROOT, "-F", babel_cfg, "-o", pot_file, "-k", "_ __ l_ lazy_gettext"]
cmd += [
str(ROOT),
"-F",
babel_cfg,
"-o",
pot_file,
"-k",
"_ __ l_ lazy_gettext",
]

elif pybabel_cmd == "update":
cmd += ["-i", pot_file, "-d", locale_dir, "-D", "sphinx"]
Expand All @@ -187,8 +197,7 @@ def translate(session: nox.Session) -> None:

elif pybabel_cmd == "init":
cmd += ["-i", pot_file, "-d", locale_dir, "-D", "sphinx", "-l", lan]

session.run(cmd)
session.run(*cmd)


@nox.session()
Expand Down

0 comments on commit 6b87c32

Please sign in to comment.