mirror of
https://github.com/mkdocs/mkdocs.git
synced 2026-03-27 01:48:30 +07:00
Integrate Babel build steps as a Hatch hook (#2992)
This commit is contained in:
11
.github/workflows/deploy-release.yml
vendored
11
.github/workflows/deploy-release.yml
vendored
@@ -6,7 +6,6 @@ on:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
|
||||
pypi:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -15,14 +14,10 @@ jobs:
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.9
|
||||
- name: Install dependencies
|
||||
- name: Install Hatch
|
||||
run: |
|
||||
python -m pip install -U hatch babel
|
||||
- name: Compile localization message files
|
||||
run: |
|
||||
pybabel compile --statistics --directory mkdocs/themes/mkdocs/locales
|
||||
pybabel compile --statistics --directory mkdocs/themes/readthedocs/locales
|
||||
- name: Build
|
||||
python -m pip install -U hatch
|
||||
- name: Build package
|
||||
run: |
|
||||
hatch build
|
||||
- name: Publish
|
||||
|
||||
20
.github/workflows/tox.yml
vendored
20
.github/workflows/tox.yml
vendored
@@ -93,18 +93,24 @@ jobs:
|
||||
if: always()
|
||||
run: python -m tox -e codespell
|
||||
|
||||
translation:
|
||||
package:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.7
|
||||
- name: Install Python dependencies
|
||||
python-version: 3.9
|
||||
- name: Install Hatch
|
||||
run: |
|
||||
python -m pip install babel
|
||||
- name: Compile localization message files
|
||||
python -m pip install -U hatch
|
||||
- name: Build package
|
||||
run: |
|
||||
pybabel compile --statistics --directory mkdocs/themes/mkdocs/locales
|
||||
pybabel compile --statistics --directory mkdocs/themes/readthedocs/locales
|
||||
hatch build
|
||||
- name: Check packaged files
|
||||
shell: bash -e -x {0}
|
||||
run: |
|
||||
expected_wheel=(-emkdocs/{templates/sitemap.xml,config/base.py,py.typed,contrib/search/lunr-language/lunr.nl.js,themes/{mkdocs,readthedocs}/{base.html,locales/{de,es}/LC_MESSAGES/messages.mo}})
|
||||
expected_sdist=("${expected_wheel[@]}" -e{pyproject.toml,hatch_build.py})
|
||||
test "$(tar -ztf dist/mkdocs-*.tar.gz | grep -F "${expected_sdist[@]}" | tee /dev/stderr | wc -l)" -eq "${#expected_sdist[@]}"
|
||||
test "$(unzip -l dist/mkdocs-*any.whl | grep -F "${expected_wheel[@]}" | tee /dev/stderr | wc -l)" -eq "${#expected_wheel[@]}"
|
||||
|
||||
14
hatch_build.py
Normal file
14
hatch_build.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import os
|
||||
|
||||
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
||||
|
||||
|
||||
class CustomBuildHook(BuildHookInterface):
|
||||
def initialize(self, version, build_data):
|
||||
from babel.messages.frontend import compile_catalog
|
||||
|
||||
for theme in 'mkdocs', 'readthedocs':
|
||||
cmd = compile_catalog()
|
||||
cmd.directory = os.path.join('mkdocs', 'themes', theme, 'locales')
|
||||
cmd.finalize_options()
|
||||
cmd.run()
|
||||
@@ -75,6 +75,10 @@ artifacts = ["/mkdocs/**/*.mo"]
|
||||
include = ["/mkdocs"]
|
||||
[tool.hatch.build.targets.wheel]
|
||||
exclude = ["/mkdocs/tests/integration", "*.po", "*.pot", "babel.cfg"]
|
||||
[tool.hatch.build.hooks.custom]
|
||||
dependencies = [
|
||||
"babel",
|
||||
]
|
||||
|
||||
[tool.black]
|
||||
line-length = 100
|
||||
|
||||
Reference in New Issue
Block a user