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:
|
jobs:
|
||||||
|
|
||||||
pypi:
|
pypi:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -15,14 +14,10 @@ jobs:
|
|||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: 3.9
|
python-version: 3.9
|
||||||
- name: Install dependencies
|
- name: Install Hatch
|
||||||
run: |
|
run: |
|
||||||
python -m pip install -U hatch babel
|
python -m pip install -U hatch
|
||||||
- name: Compile localization message files
|
- name: Build package
|
||||||
run: |
|
|
||||||
pybabel compile --statistics --directory mkdocs/themes/mkdocs/locales
|
|
||||||
pybabel compile --statistics --directory mkdocs/themes/readthedocs/locales
|
|
||||||
- name: Build
|
|
||||||
run: |
|
run: |
|
||||||
hatch build
|
hatch build
|
||||||
- name: Publish
|
- name: Publish
|
||||||
|
|||||||
20
.github/workflows/tox.yml
vendored
20
.github/workflows/tox.yml
vendored
@@ -93,18 +93,24 @@ jobs:
|
|||||||
if: always()
|
if: always()
|
||||||
run: python -m tox -e codespell
|
run: python -m tox -e codespell
|
||||||
|
|
||||||
translation:
|
package:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: 3.7
|
python-version: 3.9
|
||||||
- name: Install Python dependencies
|
- name: Install Hatch
|
||||||
run: |
|
run: |
|
||||||
python -m pip install babel
|
python -m pip install -U hatch
|
||||||
- name: Compile localization message files
|
- name: Build package
|
||||||
run: |
|
run: |
|
||||||
pybabel compile --statistics --directory mkdocs/themes/mkdocs/locales
|
hatch build
|
||||||
pybabel compile --statistics --directory mkdocs/themes/readthedocs/locales
|
- 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"]
|
include = ["/mkdocs"]
|
||||||
[tool.hatch.build.targets.wheel]
|
[tool.hatch.build.targets.wheel]
|
||||||
exclude = ["/mkdocs/tests/integration", "*.po", "*.pot", "babel.cfg"]
|
exclude = ["/mkdocs/tests/integration", "*.po", "*.pot", "babel.cfg"]
|
||||||
|
[tool.hatch.build.hooks.custom]
|
||||||
|
dependencies = [
|
||||||
|
"babel",
|
||||||
|
]
|
||||||
|
|
||||||
[tool.black]
|
[tool.black]
|
||||||
line-length = 100
|
line-length = 100
|
||||||
|
|||||||
Reference in New Issue
Block a user