From d1b06b28bae6075275840489ef8bf992f79aa522 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:16:07 -0400 Subject: [PATCH 01/11] Add a docs-generating batch file for Windows users, add a workflow to test the batch file --- .github/workflows/windows-docs.yml | 46 ++++++++++++++++++++++++++++++ make-docs.bat | 41 ++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 .github/workflows/windows-docs.yml create mode 100644 make-docs.bat diff --git a/.github/workflows/windows-docs.yml b/.github/workflows/windows-docs.yml new file mode 100644 index 00000000..b89ac0e0 --- /dev/null +++ b/.github/workflows/windows-docs.yml @@ -0,0 +1,46 @@ +name: Windows Docs Testing - WIP + +on: + pull_request: + +concurrency: + # For a given workflow, if we push to the same branch, cancel all previous builds on that branch except on master. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +permissions: + contents: read + +jobs: + lint: + name: Make Docs + runs-on: windows-latest + strategy: + matrix: + python-version: + - "3.x" + steps: + - name: Harden Runner + uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1 + with: + disable-sudo: true + egress-policy: block + allowed-endpoints: > + files.pythonhosted.org:443 + github.com:443 + pypi.org:443 + - name: Checkout Repository + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - name: Set up Python${{ matrix.python-version }} + uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 + with: + python-version: ${{ matrix.python-version }} + - name: Install CI libraries + run: | + python -m pip install --require-hashes -r CI/requirements_ci.txt + - name: Install xhydro with docs extras + run: | + python -m pip install --editable ".[docs]" + - name: Generate Docs + run: | + .\make-docs.bat diff --git a/make-docs.bat b/make-docs.bat new file mode 100644 index 00000000..1a9eecc0 --- /dev/null +++ b/make-docs.bat @@ -0,0 +1,41 @@ +@echo off +rem Batch script to clean docs artifacts and generate Sphinx HTML documentation + +rem Remove docs/notebooks/_data/ +if exist docs\notebooks\_data\ ( + rd /s /q docs\notebooks\_data\ +) + +rem Remove docs/notebooks/.ipynb_checkpoints/ +if exist docs\notebooks\.ipynb_checkpoints\ ( + rd /s /q docs\notebooks\.ipynb_checkpoints\ +) + +rem Remove specific rst files from docs/apidoc +del /q docs\apidoc\xhydro*.rst +del /q docs\apidoc\modules.rst + +rem Remove French locale .mo files +del /q docs\locales\fr\LC_MESSAGES\*.mo + +rem Generate API documentation +sphinx-apidoc -o docs\apidoc --private --module-first src\xhydro + +rem Generate gettext files +sphinx-build -b gettext docs docs\_build\gettext + +rem Run sphinx-intl update +sphinx-intl update -p docs\_build\gettext -d docs\locales -l fr + +rem Generate Sphinx HTML documentation in English +nmake -C docs html BUILDDIR=_build\html\en + +rem Generate Sphinx HTML documentation in French +nmake -C docs html BUILDDIR=_build\html\fr SPHINXOPTS=-D language=fr + +if %ERRORLEVEL% neq 0 ( + echo Error occurred during documentation update. + exit /b %ERRORLEVEL% +) + +echo Documentation generation completed successfully. From 6f9ff03df59b52d424608c0b2c75b8a491365eaf Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:31:08 -0400 Subject: [PATCH 02/11] try using conda --- .github/workflows/windows-docs.yml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/windows-docs.yml b/.github/workflows/windows-docs.yml index b89ac0e0..2f6c4708 100644 --- a/.github/workflows/windows-docs.yml +++ b/.github/workflows/windows-docs.yml @@ -18,29 +18,25 @@ jobs: strategy: matrix: python-version: - - "3.x" + - "3.10" steps: - name: Harden Runner uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1 with: disable-sudo: true - egress-policy: block - allowed-endpoints: > - files.pythonhosted.org:443 - github.com:443 - pypi.org:443 + egress-policy: audit - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - name: Set up Python${{ matrix.python-version }} - uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 + - name: Setup Conda (Micromamba) with Python${{ matrix.python-version }} + uses: mamba-org/setup-micromamba@f8b8a1e23a26f60a44c853292711bacfd3eac822 # v1.9.0 with: - python-version: ${{ matrix.python-version }} - - name: Install CI libraries - run: | - python -m pip install --require-hashes -r CI/requirements_ci.txt + cache-downloads: true + environment-file: environment-dev.yml + create-args: >- + python=${{ matrix.python-version }} - name: Install xhydro with docs extras run: | - python -m pip install --editable ".[docs]" + python -m pip install --editable --no-deps . - name: Generate Docs run: | .\make-docs.bat From 17529a81f1906634fee197f62e1682c7baffb513 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:40:03 -0400 Subject: [PATCH 03/11] adjustments --- .github/workflows/windows-docs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-docs.yml b/.github/workflows/windows-docs.yml index 2f6c4708..9f89a894 100644 --- a/.github/workflows/windows-docs.yml +++ b/.github/workflows/windows-docs.yml @@ -31,12 +31,13 @@ jobs: uses: mamba-org/setup-micromamba@f8b8a1e23a26f60a44c853292711bacfd3eac822 # v1.9.0 with: cache-downloads: true + cache-environment: true environment-file: environment-dev.yml create-args: >- python=${{ matrix.python-version }} - name: Install xhydro with docs extras run: | - python -m pip install --editable --no-deps . + python -m pip install --editable . - name: Generate Docs run: | .\make-docs.bat From 47354e54f039e60c6a5d299422c6a70109ab11dd Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:03:56 -0400 Subject: [PATCH 04/11] use powershell by default --- .github/workflows/windows-docs.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/windows-docs.yml b/.github/workflows/windows-docs.yml index 9f89a894..3c1d0967 100644 --- a/.github/workflows/windows-docs.yml +++ b/.github/workflows/windows-docs.yml @@ -19,6 +19,9 @@ jobs: matrix: python-version: - "3.10" + defaults: + run: + shell: powershell steps: - name: Harden Runner uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1 @@ -33,6 +36,7 @@ jobs: cache-downloads: true cache-environment: true environment-file: environment-dev.yml + init-shell: powershell create-args: >- python=${{ matrix.python-version }} - name: Install xhydro with docs extras From 2c872d94b2921a94fb019a7a6d25eeddeb5e6e71 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:21:50 -0400 Subject: [PATCH 05/11] try mocking esmf dependencies --- .github/workflows/windows-docs.yml | 2 +- docs/conf.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-docs.yml b/.github/workflows/windows-docs.yml index 3c1d0967..32b83a5b 100644 --- a/.github/workflows/windows-docs.yml +++ b/.github/workflows/windows-docs.yml @@ -39,7 +39,7 @@ jobs: init-shell: powershell create-args: >- python=${{ matrix.python-version }} - - name: Install xhydro with docs extras + - name: Install xhydro run: | python -m pip install --editable . - name: Generate Docs diff --git a/docs/conf.py b/docs/conf.py index b1aff1d1..a57cb6c5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -62,6 +62,8 @@ "special-members": False, } +autodoc_mock_imports = ["esmpy", "xesmf"] + # For styling class attributes napoleon_use_ivar = True From 483c0582147b19e1cdf9dcb35fbc6c2bfdeadbe1 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:49:00 -0400 Subject: [PATCH 06/11] try pinning esmf higher, call to batch file --- environment-dev.yml | 3 +++ make-docs.bat | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/environment-dev.yml b/environment-dev.yml index fb90ef49..3af4d7bb 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -66,3 +66,6 @@ dependencies: # Notebooks - hvplot - xagg + # WIP + - esmf >=8.6.0 + - esmpy >=8.6.0 diff --git a/make-docs.bat b/make-docs.bat index 1a9eecc0..2763fa89 100644 --- a/make-docs.bat +++ b/make-docs.bat @@ -28,10 +28,10 @@ rem Run sphinx-intl update sphinx-intl update -p docs\_build\gettext -d docs\locales -l fr rem Generate Sphinx HTML documentation in English -nmake -C docs html BUILDDIR=_build\html\en +call docs\make.bat html "-D language=en" rem Generate Sphinx HTML documentation in French -nmake -C docs html BUILDDIR=_build\html\fr SPHINXOPTS=-D language=fr +call docs\make.bat html "-D language=fr" if %ERRORLEVEL% neq 0 ( echo Error occurred during documentation update. From 581d646cfae24d24e9981c8083b94d04cb69fde6 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:26:40 -0400 Subject: [PATCH 07/11] try a workaround for esmpy --- environment-dev.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/environment-dev.yml b/environment-dev.yml index 3af4d7bb..e9254d86 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -66,6 +66,5 @@ dependencies: # Notebooks - hvplot - xagg - # WIP - - esmf >=8.6.0 - - esmpy >=8.6.0 + # wip + - esmpy <8.4.0,>=8.6 From 496554860a385170c2979c1055d77a3c5c9e77da Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:38:40 -0400 Subject: [PATCH 08/11] try pinning importlib-metadata --- environment-dev.yml | 3 +-- environment.yml | 1 + pyproject.toml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/environment-dev.yml b/environment-dev.yml index e9254d86..bd8587d3 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -8,6 +8,7 @@ dependencies: - cartopy - geopandas - haversine + - importlib-metadata <8.0 # Required for xesmf >=8.4.0,<8.6 to work on Windows - leafmap - numpy <2.0.0 - pandas >=2.2.0 @@ -66,5 +67,3 @@ dependencies: # Notebooks - hvplot - xagg - # wip - - esmpy <8.4.0,>=8.6 diff --git a/environment.yml b/environment.yml index b4f35183..7deefc61 100644 --- a/environment.yml +++ b/environment.yml @@ -9,6 +9,7 @@ dependencies: - cartopy - geopandas - haversine + - importlib-metadata <8.0 # Required for xesmf >=8.4.0,<8.6 to work on Windows - leafmap - numpy <2.0.0 - pandas >=2.2.0 diff --git a/pyproject.toml b/pyproject.toml index 05133561..9b9c613b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ dependencies = [ "cartopy", "geopandas", "haversine", + "importlib-metadata <8.0", # Required for xesmf >=8.4.0,<8.6 to work on Windows "leafmap", "numpy <2.0.0", "pandas >=2.2.0", From 4f53eac7b5e1307529e8b22748c6332aaf2e4e44 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 11 Sep 2024 10:37:35 -0400 Subject: [PATCH 09/11] update CHANGELOG.rst, remove testing workflow --- .github/workflows/windows-docs.yml | 47 ------------------------------ CHANGELOG.rst | 1 + 2 files changed, 1 insertion(+), 47 deletions(-) delete mode 100644 .github/workflows/windows-docs.yml diff --git a/.github/workflows/windows-docs.yml b/.github/workflows/windows-docs.yml deleted file mode 100644 index 32b83a5b..00000000 --- a/.github/workflows/windows-docs.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Windows Docs Testing - WIP - -on: - pull_request: - -concurrency: - # For a given workflow, if we push to the same branch, cancel all previous builds on that branch except on master. - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} - -permissions: - contents: read - -jobs: - lint: - name: Make Docs - runs-on: windows-latest - strategy: - matrix: - python-version: - - "3.10" - defaults: - run: - shell: powershell - steps: - - name: Harden Runner - uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1 - with: - disable-sudo: true - egress-policy: audit - - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - name: Setup Conda (Micromamba) with Python${{ matrix.python-version }} - uses: mamba-org/setup-micromamba@f8b8a1e23a26f60a44c853292711bacfd3eac822 # v1.9.0 - with: - cache-downloads: true - cache-environment: true - environment-file: environment-dev.yml - init-shell: powershell - create-args: >- - python=${{ matrix.python-version }} - - name: Install xhydro - run: | - python -m pip install --editable . - - name: Generate Docs - run: | - .\make-docs.bat diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 25f5d815..2809d8c7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -23,6 +23,7 @@ Internal changes * Warnings in Pull Requests from forks are now less buggy. * A new pre-commit hook and linting step for validating numpy docstrings has been added (`numpydoc`). * All `pip`-based dependencies used to run in CI are now managed by a ``CI/requirements_ci.txt`` that uses hashes of packages for security. +* Added a new Batch (`.bat`) file to help facilitate the translation and generation of the `xhydro` documentation in Windows environments. (:pull:`196`). Breaking changes ^^^^^^^^^^^^^^^^ From b0a83e0664a47a7a5f12e76bdef33f7bdf76d518 Mon Sep 17 00:00:00 2001 From: RondeauG Date: Wed, 18 Sep 2024 16:30:37 -0400 Subject: [PATCH 10/11] support for WindowsPath, fix bug with old entries --- CI/translator.py | 168 ++++++++++++++++++++++++----------------------- 1 file changed, 86 insertions(+), 82 deletions(-) diff --git a/CI/translator.py b/CI/translator.py index 7191dedd..68046d1b 100644 --- a/CI/translator.py +++ b/CI/translator.py @@ -35,8 +35,10 @@ def translate_missing_po_entries( # noqa: C901 The target language of the .po files. Defaults to "fr". clean_old_entries : bool Whether to clean old entries in the .po files. Defaults to True. + These are entries that do not exist anymore in the source code, but are still present in the .po files. overwrite_fuzzy : bool Whether to overwrite fuzzy entries in the .po files. Defaults to True. + Fuzzy entries are entries that have been marked as needing review, so they are usually wrong. \*\*kwargs : dict Additional keyword arguments to pass to the translator. """ @@ -49,91 +51,93 @@ def translate_missing_po_entries( # noqa: C901 ) # Get all .po files - files = Path(dir_path).rglob("*.po") + files = [ + f + for f in Path(dir_path).rglob("*.po") + if not any(d in str(f) for d in ["changelog", "apidoc"]) + ] number_of_calls = 0 for file_path in files: - if not any( - dont_translate in file_path for dont_translate in ["changelog", "apidoc"] - ): - with Path(file_path).open("r+", encoding="utf-8") as file: - content = file.read() - - # Find all fuzzy entries - fuzzy_entries = fuzzy_pattern.findall(str(content)) - if len(fuzzy_entries) > 0 and overwrite_fuzzy: - msg = f"Found {len(fuzzy_entries)} fuzzy entries in {file_path}" - logger.info(msg) - for i in fuzzy_entries: - entry = i[1].split("\nmsgstr ") - # Remove the fuzzy entry - content = content.replace(entry[1], '""\n\n') - # Since we can't guarantee the exact way the fuzzy entry was written - # we remove the fuzzy tag in 2 steps - content = content.replace(", fuzzy", "") - content = content.replace("#\nmsgid", "msgid") - - # Find all msgid and msgstr pairs - msgids = [] - msgstrs = [] - for i in msg_pattern.findall(str(content)): - ids, strs = i[0].split("\nmsgstr ") - ids = ids if ids != '""' else "" - strs = strs.replace('\\"', "'").replace('"', "").replace("\n", "") - msgids.extend([ids]) - msgstrs.extend([strs]) - - # Track if the file was modified - modified = False - - for msgid, msgstr in zip(msgids, msgstrs): - # Check if translation is missing - if msgid and not msgstr: - # Translate the missing string - translated_text = translator.translate( - msgid.replace('\\"', "'").replace('"', "").replace("\n", "") - ) - - # Split the translated text into lines of max 60 characters - if len(translated_text) > 70: # 70 to include the spaces - words = translated_text.split() - length = 0 - words[0] = '"\n"' + words[0] - for i in range(len(words)): - length += len(words[i]) - if length > 60: - words[i] = '"\n"' + words[i] - length = 0 - translated_text = " ".join(words) - - # Replace the empty msgstr with the translated text - content = content.replace( - f'msgid {msgid}\nmsgstr ""', - f'msgid {msgid}\nmsgstr "{translated_text}"', - 1, - ) - modified = True - - # Sleep to avoid rate limiting - number_of_calls += 1 - if number_of_calls % 100 == 0: - time.sleep(60) - else: - time.sleep(1) - - if clean_old_entries: - is_old = str(content).split("#~") - if len(is_old) > 1: - content = is_old[0] - modified = True - - # If modifications were made, write them back to the file - if modified: - msg = f"Updating translations in {file_path}" - logger.info(msg) - file.seek(0) - file.write(content) - file.truncate() + with Path(file_path).open("r+", encoding="utf-8") as file: + content = file.read() + + # Find all fuzzy entries + fuzzy_entries = fuzzy_pattern.findall(str(content)) + if len(fuzzy_entries) > 0 and overwrite_fuzzy: + msg = f"Found {len(fuzzy_entries)} fuzzy entries in {file_path}" + logger.info(msg) + for i in fuzzy_entries: + entry = i[1].split("\nmsgstr ") + # Remove the fuzzy entry + content = content.replace(entry[1], '""\n\n') + # Since we can't guarantee the exact way the fuzzy entry was written + # we remove the fuzzy tag in 2 steps + content = content.replace(", fuzzy", "") + content = content.replace("#\nmsgid", "msgid") + + # Find all msgid and msgstr pairs + msgids = [] + msgstrs = [] + content_valid = content.split("#~")[0] # Skip old entries + for i in msg_pattern.findall(str(content_valid)): + ids, strs = i[0].split("\nmsgstr ") + ids = ids if ids != '""' else "" + strs = strs.replace('\\"', "'").replace('"', "").replace("\n", "") + msgids.extend([ids]) + msgstrs.extend([strs]) + + # Track if the file was modified + modified = False + + for msgid, msgstr in zip(msgids, msgstrs): + # Check if translation is missing + if msgid and not msgstr: + # Translate the missing string + translated_text = translator.translate( + msgid.replace('\\"', "'").replace('"', "").replace("\n", "") + ) + + # Split the translated text into lines of max 60 characters + if len(translated_text) > 70: # 70 to include the spaces + words = translated_text.split() + length = 0 + words[0] = '"\n"' + words[0] + for i in range(len(words)): + length += len(words[i]) + if length > 60: + words[i] = '"\n"' + words[i] + length = 0 + translated_text = " ".join(words) + + # Replace the empty msgstr with the translated text + content = content.replace( + f'msgid {msgid}\nmsgstr ""', + f'msgid {msgid}\nmsgstr "{translated_text}"', + 1, + ) + modified = True + + # Sleep to avoid rate limiting + number_of_calls += 1 + if number_of_calls % 100 == 0: + time.sleep(60) + else: + time.sleep(1) + + if clean_old_entries: + is_old = str(content).split("#~") + if len(is_old) > 1: + content = is_old[0] + modified = True + + # If modifications were made, write them back to the file + if modified: + msg = f"Updating translations in {file_path}" + logger.info(msg) + file.seek(0) + file.write(content) + file.truncate() # FIXME: Add argparse to make it a command-line tool From 8a4bfc8d482809591f1da1723ac7e68dbe143a39 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 19 Sep 2024 15:41:59 -0400 Subject: [PATCH 11/11] split batch file, update CHANGELOG.rst --- CHANGELOG.rst | 8 +++----- make-docs.bat | 11 +---------- make-translations.bat | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 make-translations.bat diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 41966d75..1baf2027 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,9 +9,7 @@ Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Gabriel R New features and enhancements ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * `xhydro` now supports `RavenPy` v0.15.0 (`RavenHydroFramework` v3.8.1). (:pull:`161`). -* Regional frequency analysis functions have been added under `xhydro.frequency_analysis` module. (:pull:`186`). -* Ressampling function for uncertainitieshave been added under `xhydro.frequency_analysis` module. (:pull:`186`). - +* Regional frequency analysis functions as well as Resampling function for uncertainties have been added to the ``xhydro.frequency_analysis`` module. (:pull:`186`). Internal changes ^^^^^^^^^^^^^^^^ @@ -20,13 +18,13 @@ Internal changes * The `conda` environment now relies on the newly created `xdatasets` package. (:pull:`164`). * The cookiecutter has been updated to the latest commit. Changes include workflow fixes, stricter coding standards, and many small adjustments to the documentation. (:pull:`164`). * A previously uncaught YAML formatting issue has been addressed. Stricter style conventions are now enforced. (:pull:`174`). -* Chunking was adjusted in a few functions to work with the new requirements of `apply_ufunc`. (:pull:`180`). +* Chunking was adjusted in a few functions to work with the new requirements of ``apply_ufunc``. (:pull:`180`). * Updated the cookiecutter template to the latest commit. (:pull:`177`): * Actions have been updated and synchronized. * Warnings in Pull Requests from forks are now less buggy. * A new pre-commit hook and linting step for validating numpy docstrings has been added (`numpydoc`). * All `pip`-based dependencies used to run in CI are now managed by a ``CI/requirements_ci.txt`` that uses hashes of packages for security. -* Added a new Batch (`.bat`) file to help facilitate the translation and generation of the `xhydro` documentation in Windows environments. (:pull:`196`). +* Added two new Batch (`.bat`) files to help facilitate the translation of and the generation of the `xhydro` documentation in Windows environments. (:pull:`196`). Breaking changes ^^^^^^^^^^^^^^^^ diff --git a/make-docs.bat b/make-docs.bat index 2763fa89..f92e1af1 100644 --- a/make-docs.bat +++ b/make-docs.bat @@ -15,18 +15,9 @@ rem Remove specific rst files from docs/apidoc del /q docs\apidoc\xhydro*.rst del /q docs\apidoc\modules.rst -rem Remove French locale .mo files -del /q docs\locales\fr\LC_MESSAGES\*.mo - rem Generate API documentation sphinx-apidoc -o docs\apidoc --private --module-first src\xhydro -rem Generate gettext files -sphinx-build -b gettext docs docs\_build\gettext - -rem Run sphinx-intl update -sphinx-intl update -p docs\_build\gettext -d docs\locales -l fr - rem Generate Sphinx HTML documentation in English call docs\make.bat html "-D language=en" @@ -34,7 +25,7 @@ rem Generate Sphinx HTML documentation in French call docs\make.bat html "-D language=fr" if %ERRORLEVEL% neq 0 ( - echo Error occurred during documentation update. + echo Error occurred during documentation generation. exit /b %ERRORLEVEL% ) diff --git a/make-translations.bat b/make-translations.bat new file mode 100644 index 00000000..ea4307ee --- /dev/null +++ b/make-translations.bat @@ -0,0 +1,18 @@ +@echo off +rem Batch script to handle translation work + +rem Remove French locale .mo files +del /q docs\locales\fr\LC_MESSAGES\*.mo + +rem Generate gettext files +sphinx-build -b gettext docs docs\_build\gettext + +rem Run sphinx-intl update +sphinx-intl update -p docs\_build\gettext -d docs\locales -l fr + +if %ERRORLEVEL% neq 0 ( + echo Error occurred during translation update. + exit /b %ERRORLEVEL% +) + +echo Translation update completed successfully.