Contributing to Weblate modules
Besides the main repository, Weblate consists of several Python modules. All these follow same structure and this documentation covers them all.
For example, this covers:
wlc, Python client library, see Клиент Weblate
translation-finder, used to discover translatable files in the repository
language-data, language definitions for Weblate, see Определение языков
Coding guidelines
Любой код для Weblate’а должен писаться с оглядкой на Принципы «безопасности по проектированию» (Security by Design).
Весь код должен сопровождаться документацией, поясняющей его работу. Не забывайте документировать методы, сложные блоки кода и функционал, доступный пользователям.
Any new code should utilize PEP 484 type hints. We’re not checking this in our CI yet as existing code does not yet include them.
Running tests
The tests are executed using py.test. First you need to install test requirements:
pip install -r requirements-test.txt
You can then execute the testsuite in the repository checkout:
py.test
См.также
The CI integration is very similar to Система автоматического тестирования и непрерывной интеграции Weblate.
Coding standard and linting the code
Код должен соответствовать рекомендациям по кодированию PEP-8 и должен быть отформатирован с использованием инструмента форматирования кода black.
Для проверки качества кода можно использовать flake8, рекомендуемые плагины перечислены в :file:``.pre-commit-config.yaml`, а их настройки находятся в setup.cfg
.
The easiest approach to enforce all this is to install pre-commit. The
repository contains configuration for it to verify the committed files are sane.
After installing it (it is already included in the
requirements-lint.txt
) turn it on by running pre-commit install
in
Weblate checkout. This way all your changes will be automatically checked.
Также вы можете запустить эту проверку вручную, чтобы проверить все файлы, запустите:
pre-commit run --all
См.также