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:

Coding guidelines

編寫 Weblate 的任何代碼應該時刻記得 `Security by Design Principles`_(由設計原理來提供安全性)。

Any code should come with documentation explaining the behavior. Don’t forget documenting methods, complex code blocks, or user visible features.

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,推薦的插件列在 .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

也參考

Weblate 源代碼