为 Weblate 模块作贡献

Besides the main repository, Weblate consists of several Python modules. All these follow same structure and this documentation covers them all.

例如,这涵盖了:

代码编写准则

在为 Weblate 编写任何代码时都应该考虑到 通过设计保证安全原则

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.

运行测试

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 中。

将所有这些强制的最简单的方法是安装 pre-commit。仓库为此包含了配置,来确定提交的文件是正常的。安装后(他已经包括在 requirements-lint.txt 中了)通过在 Weblate 的付款台运行 pre-commit install 来将它打开。通过这种方法,所有更改都将被自动检查。

还能够手动触发检查,来检查所有文件的运行:

pre-commit run --all