mirror of
https://github.com/open-mmlab/mmselfsup.git
synced 2025-06-03 14:59:38 +08:00
* Update contribution_guides.md * Update contribution_guides.md * Update contribution_guides.md * Update faq.md * Update faq.md * Update faq.md * Update changelog.md * Update changelog.md * Update changelog.md * Update changelog.md * m * Update changelog.md * Update contribution_guides.md * Update contribution_guide.md * Update faq.md * Update faq.md * update * Update docs/zh_cn/notes/changelog.md * Update contribution_guides.md * Update contribution_guides.md * Update faq.md * Update contribution_guides.md Co-authored-by: Yixiao Fang <36138628+fangyixiao18@users.noreply.github.com>
79 lines
2.9 KiB
Markdown
79 lines
2.9 KiB
Markdown
# 向MMSelfSup贡献代码
|
||
|
||
- [向MMSelfSup贡献代码](#向MMSelfSup贡献代码)
|
||
- [流程](#流程)
|
||
- [代码风格](#代码风格)
|
||
- [Python](#python)
|
||
- [C++ and CUDA](#c-and-cuda)
|
||
|
||
感谢您对参与 MMSelfsup 贡献的兴趣。我们欢迎各种形式的贡献,包括但不限于:
|
||
|
||
- 修复 bug 或者错误
|
||
- 添加或翻译文档为另外一种语言
|
||
- 添加新特性或者组件
|
||
|
||
## 流程
|
||
|
||
我们推荐潜在的贡献者使用下面的流程来添加贡献:
|
||
|
||
1. Fork 并 pull 最新的 MMSelfSup 仓库,并根据 [get_started](../get_started.md) 来配置环境。
|
||
2. Checkout 一个新的分支 (**不要使用 master/dev branch 提交 PR**)
|
||
|
||
请从 `dev-1.x` 分支 checkout 一个新的分支,并按照下面指令:
|
||
|
||
```bash
|
||
git clone git@github.com:open-mmlab/mmselfsup.git
|
||
cd mmselfsup
|
||
git checkout dev-1.x
|
||
git checkout -b xxxx # xxxx is the name of new branch
|
||
```
|
||
|
||
3. 根据后面提到的代码风格编辑相关的文件
|
||
4. 使用 **pre-commit hook** 来检查和格式化您的修改。
|
||
5. 提交您的修改。
|
||
6. 创建一个 PR,并往 dev-1.x 合入。
|
||
|
||
```{note}
|
||
如果您计划去增添一些涉及到很大变化的新特性,我们推荐您先创建一个 issue 与我们讨论。
|
||
```
|
||
|
||
## 代码风格
|
||
|
||
### Python
|
||
|
||
我们采用 [PEP8](https://www.python.org/dev/peps/pep-0008/) 作为我们的代码风格。
|
||
我们采用一下工具来进行 linting 和 formatting:
|
||
|
||
- [flake8](https://github.com/PyCQA/flake8): 一个 linter 工具装饰器.
|
||
- [isort](https://github.com/timothycrosley/isort): 一个为 Python 导入排序的工具。
|
||
- [yapf](https://github.com/google/yapf): 一个为 Python 文件格式化的工具。
|
||
- [codespell](https://github.com/codespell-project/codespell): 一个修改错误拼写的 Python 工具。
|
||
- [mdformat](https://github.com/executablebooks/mdformat): Mdformat 是一个可选的 Markdorn 的格式化工具,可以让 Markdown 文件中的格式保持一致。
|
||
- [docformatter](https://github.com/myint/docformatter): 一个格式化 docstring 的工具.
|
||
|
||
配置 yapf 和 isort 放在在 [setup.cfg](./setup.cfg)中。
|
||
|
||
我们使用 [pre-commit hook](https://pre-commit.com/) 来检查和格式化`flake8`, `yapf`, `isort`, `trailing whitespaces`, `markdown files`,自动修改`end-of-files`, `double-quoted-strings`, `python-encoding-pragma`, `mixed-line-ending`, sorts `requirments.txt` 在每一次提交。
|
||
为 pre-commit hook 的配置储存在 [.pre-commit-config](./.pre-commit-config.yaml)。
|
||
|
||
在您 clone 仓库之后,您需要安装并初始化 pre-commit hook。
|
||
|
||
```shell
|
||
pip install -U pre-commit
|
||
```
|
||
|
||
在仓库的文件夹中
|
||
|
||
```shell
|
||
pre-commit install
|
||
pre-commit run
|
||
```
|
||
|
||
在此之后,在每一次提交时 linters 和 formatter 都会进行。
|
||
|
||
> 在您创建一个 PR 前,请确保您的代码 lint 并被 yapf 格式化过。
|
||
|
||
### C++ and CUDA
|
||
|
||
我们采用[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html)。
|