Skip to content

Commit a9a9e5f

Browse files
authored
[Docs][hook] add a pre-commit hook to automatically insert space to cn and en char (#4973)
* replace tab with spaces * CRLF -> LF * trim trailing whitespace * ensure-final-newline and trim-trailing-blank-lines * insert-whitespace-between-cn-and-en-char * fix check_api_cn script to ignore some files not include sample code * use COPY-FROM to avoid some ci error * make pre-commit also check rst * remove missing `.. code-block:: python` * update api_white_list.txt * fix the issue caused by upstream * add a pre-commit hook to automatically insert space to cn and en char * fix style issues from upstream * bump pre-commit hooks version * more COPY-FROM (the file only include one code block) * remove redundant labels * more COPY-FROM (try multiple code example) * restore HDFSClient changes * fix style issues from upstream * use COPY-FROM to avoid ci issue
1 parent 5ab0761 commit a9a9e5f

File tree

1,254 files changed

+16422
-20357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,254 files changed

+16422
-20357
lines changed

.pre-commit-config.yaml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
11
repos:
22
- repo: https://github.com/pre-commit/mirrors-yapf.git
3-
rev: v0.16.0
3+
rev: v0.32.0
44
hooks:
55
- id: yapf
66
files: \.py$
77
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: a11d9314b22d8f8c7556443875b731ef05965464
8+
rev: v4.1.0
99
hooks:
1010
- id: check-merge-conflict
1111
- id: check-symlinks
1212
- id: detect-private-key
1313
files: (?!.*paddle)^.*$
1414
- id: end-of-file-fixer
15-
files: \.md$
15+
files: \.md$|\.rst$
1616
- id: trailing-whitespace
17-
files: \.md$
17+
files: \.md$|\.rst$
1818
- repo: https://github.com/Lucas-C/pre-commit-hooks
19-
rev: v1.0.1
19+
rev: v1.1.14
2020
hooks:
2121
- id: forbid-crlf
22-
files: \.md$
22+
files: \.md$|\.rst$
2323
- id: remove-crlf
24-
files: \.md$
24+
files: \.md$|\.rst$
2525
- id: forbid-tabs
26-
files: \.md$
26+
files: \.md$|\.rst$
2727
- id: remove-tabs
28-
files: \.md$
28+
files: \.md$|\.rst$
29+
- repo: https://github.com/ShigureLab/dochooks
30+
rev: v0.3.0
31+
hooks:
32+
- id: check-whitespace-between-cn-and-en-char
33+
files: \.md$|\.rst$
34+
- id: insert-whitespace-between-cn-and-en-char
35+
files: \.md$|\.rst$
2936
- repo: https://github.com/reyoung/pre-commit-hooks-jinja-compile.git
3037
rev: 4a369cc72a4a2b8d3813ab8cc17abb5f5b21ef6c
3138
hooks:

CONTRIBUTING_cn.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,34 @@
88

99
- 使用教程
1010
- 应用实践
11-
- API文档
11+
- API 文档
1212

1313
### 使用教程
1414

1515
这部分内容主要是对飞桨框架的使用指南的说明,你可以对现有的内容进行纠错或者是改进,也可以新增你认为重要的文档在这个栏目中。我们非常欢迎你提出任何关于使用教程文档的建议以及修改。
1616

1717
### 应用实践
1818

19-
应用实践主要是使用飞桨框架进行具体的案例实现。目前已经有许多开发者贡献了非常优秀的案例,如OCR识别、人脸关键点检测等,我们非常欢迎你提交你的项目到我们的repo中来,并最终呈现在飞桨的官网上。
19+
应用实践主要是使用飞桨框架进行具体的案例实现。目前已经有许多开发者贡献了非常优秀的案例,如 OCR 识别、人脸关键点检测等,我们非常欢迎你提交你的项目到我们的 repo 中来,并最终呈现在飞桨的官网上。
2020

21-
### API文档
21+
### API 文档
2222

23-
API文档是飞桨框架的API文档,包含了飞桨框架API的说明介绍。我们非常欢迎你对我们的API文档提出修改,不管是typo或者是修改说明与示例,我们都非常感谢你对于API文档所作出的任何贡献
23+
API 文档是飞桨框架的 API 文档,包含了飞桨框架 API 的说明介绍。我们非常欢迎你对我们的 API 文档提出修改,不管是 typo 或者是修改说明与示例,我们都非常感谢你对于 API 文档所作出的任何贡献
2424

2525
## 参与方式
2626

2727
### 使用教程
2828

29-
这部分内容存放在 [docs/docs/guides](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides) 目录下,你可以通过提交PR的方式,来作出你的修改。具体修改方式请参考:[文档贡献指南](https://github.com/PaddlePaddle/docs/wiki/%E6%96%87%E6%A1%A3%E8%B4%A1%E7%8C%AE%E6%8C%87%E5%8D%97)
29+
这部分内容存放在 [docs/docs/guides](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides) 目录下,你可以通过提交 PR 的方式,来作出你的修改。具体修改方式请参考:[文档贡献指南](https://github.com/PaddlePaddle/docs/wiki/%E6%96%87%E6%A1%A3%E8%B4%A1%E7%8C%AE%E6%8C%87%E5%8D%97)
3030

3131
### 应用实践
3232

33-
这部分内容分为源代码与官网文档两部分,源代码的部分以notebook的形式,存放在 [book/paddle2.0_docs](https://github.com/PaddlePaddle/book/tree/develop/paddle2.0_docs) 目录下,你可以提交你的notebook格式的源码于该目录中;在你的notebook文件被合入后,我们会将其转为md文件,存储在[docs/docs/tutorial](https://github.com/PaddlePaddle/docs/tree/develop/docs/tutorial)中,然后呈现到官网。具体信息请参考:[[Call for Contribution] Tutorials for PaddlePaddle 2.0](https://github.com/PaddlePaddle/book/issues/905).
33+
这部分内容分为源代码与官网文档两部分,源代码的部分以 notebook 的形式,存放在 [book/paddle2.0_docs](https://github.com/PaddlePaddle/book/tree/develop/paddle2.0_docs) 目录下,你可以提交你的 notebook 格式的源码于该目录中;在你的 notebook 文件被合入后,我们会将其转为 md 文件,存储在[docs/docs/tutorial](https://github.com/PaddlePaddle/docs/tree/develop/docs/tutorial)中,然后呈现到官网。具体信息请参考:[[Call for Contribution] Tutorials for PaddlePaddle 2.0](https://github.com/PaddlePaddle/book/issues/905).
3434

35-
### API文档
35+
### API 文档
3636

37-
飞桨框架同时提供中英文API文档。其中,英文API文档存于[Paddle](https://github.com/PaddlePaddle/Paddle/tree/develop/python/paddle)源代码中,绝大部分通过官网文档的源代码即可链接到,你可以在此位置对英文文档进行修改;而中文API文档存放在[docs/docs/api](https://github.com/PaddlePaddle/docs/tree/develop/docs/api)目录下。你可以针对文档中的任何错误与内容进行修复与完善,或者是新增你认为该文档中所需要的内容,我们非常感谢你对于API文档所付出的一切。具体修改方式请参考:[英文API文档贡献指南](https://github.com/PaddlePaddle/docs/wiki/%E8%8B%B1%E6%96%87API%E6%96%87%E6%A1%A3%E8%B4%A1%E7%8C%AE%E6%8C%87%E5%8D%97)[中文API文档贡献指南](https://github.com/PaddlePaddle/docs/wiki/%E4%B8%AD%E6%96%87API%E6%96%87%E6%A1%A3%E8%B4%A1%E7%8C%AE%E6%8C%87%E5%8D%97)
37+
飞桨框架同时提供中英文 API 文档。其中,英文 API 文档存于[Paddle](https://github.com/PaddlePaddle/Paddle/tree/develop/python/paddle)源代码中,绝大部分通过官网文档的源代码即可链接到,你可以在此位置对英文文档进行修改;而中文 API 文档存放在[docs/docs/api](https://github.com/PaddlePaddle/docs/tree/develop/docs/api)目录下。你可以针对文档中的任何错误与内容进行修复与完善,或者是新增你认为该文档中所需要的内容,我们非常感谢你对于 API 文档所付出的一切。具体修改方式请参考:[英文 API 文档贡献指南](https://github.com/PaddlePaddle/docs/wiki/%E8%8B%B1%E6%96%87API%E6%96%87%E6%A1%A3%E8%B4%A1%E7%8C%AE%E6%8C%87%E5%8D%97)[中文 API 文档贡献指南](https://github.com/PaddlePaddle/docs/wiki/%E4%B8%AD%E6%96%87API%E6%96%87%E6%A1%A3%E8%B4%A1%E7%8C%AE%E6%8C%87%E5%8D%97)
3838

39-
## 提交PR
39+
## 提交 PR
4040

41-
你对于飞桨文档的任何修改,都应该通过提交PR的方式来完成,具体的方法可以参考[提交PR](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/08_contribution/local_dev_guide.html)
41+
你对于飞桨文档的任何修改,都应该通过提交 PR 的方式来完成,具体的方法可以参考[提交 PR](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/08_contribution/local_dev_guide.html)

README_cn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
docs 是 [PaddlePaddle 官网文档](https://www.paddlepaddle.org.cn/documentation/docs/zh/guides/index_cn.html) 的源文件。
66

7-
注意:英文版API文档直接从[PaddlePaddle/Paddle](https://github.com/PaddlePaddle/Paddle) 的 docstring 中生成,[飞桨其他项目](https://www.paddlepaddle.org.cn/overview)的文档分别在其对应的位置中管理。
7+
注意:英文版 API 文档直接从[PaddlePaddle/Paddle](https://github.com/PaddlePaddle/Paddle) 的 docstring 中生成,[飞桨其他项目](https://www.paddlepaddle.org.cn/overview)的文档分别在其对应的位置中管理。
88

99
## 仓库结构
1010

1111
- [docs](docs): 飞桨框架 2.0 以及之后版本文档的源文件。
12-
- [docs/api](docs/api): 飞桨中文 API文档的源文件
12+
- [docs/api](docs/api): 飞桨中文 API 文档的源文件
1313
- [docs/guides](docs/guides): 飞桨官方教程的源文件。
1414
- [docs/tutorial](docs/tutorial): 飞桨相关案例的源文件。
1515
- [ci_scripts](ci_scripts): docs CI 相关的文件。

ci_scripts/api_white_list.txt

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
paddle/fluid/DistributeTranspiler_cn.rst
2-
paddle/fluid/DistributeTranspilerConfig_cn.rst
1+
paddle/fluid/transpiler/DistributeTranspiler_cn.rst
2+
paddle/fluid/transpiler/DistributeTranspilerConfig_cn.rst
33
paddle/fluid/transpiler/HashName_cn.rst
4-
paddle/fluid/memory_optimize_cn.rst
5-
paddle/fluid/release_memory_cn.rst
6-
paddle/optimizer/Dpsgd_cn.rst
7-
paddle/reader/ComposeNotAligned_cn.rst
4+
paddle/fluid/transpiler/memory_optimize_cn.rst
5+
paddle/fluid/transpiler/release_memory_cn.rst
86
paddle/fluid/layers/scatter_cn.rst
9-
paddle/tensor/manipulation/scatter_cn.rst
107
paddle/distributed/init_parallel_env_cn.rst
118
paddle/distributed/spawn_cn.rst
129
paddle/distributed/ReduceOp_cn.rst
@@ -18,25 +15,16 @@ paddle/distributed/barrier_cn.rst
1815
paddle/distributed/broadcast_cn.rst
1916
paddle/distributed/split_cn.rst
2017
paddle/distributed/fleet/Fleet_cn.rst
21-
paddle/distributed/fleet/utils/fs/ExecuteError_cn.rst
22-
paddle/distributed/fleet/utils/fs/FSFileExistsError_cn.rst
23-
paddle/distributed/fleet/utils/fs/FSFileNotExistsError_cn.rst
24-
paddle/distributed/fleet/utils/fs/FSShellCmdAborted_cn.rst
25-
paddle/distributed/fleet/utils/fs/FSTimeOut_cn.rst
26-
paddle/distributed/fleet/utils/fs/FS_cn.rst
27-
paddle/distributed/fleet/utils/fs/HDFSClient_cn.rst
28-
paddle/distributed/fleet/utils/fs/LocalFS_cn.rst
29-
paddle/fluid/dygraph/parallel/DataParallel_cn.rst
30-
paddle/fluid/dygraph/parallel/ParallelEnv_cn.rst
31-
paddle/fluid/framework/is_compiled_with_xpu_cn.rst
32-
paddle/fluid/framework/xpu_places_cn.rst
33-
paddle/fluid/core/XPUPlace_cn.rst
18+
paddle/distributed/fleet/utils/HDFSClient_cn.rst
19+
paddle/distributed/fleet/utils/LocalFS_cn.rst
20+
paddle/DataParallel_cn.rst
21+
paddle/distributed/ParallelEnv_cn.rst
22+
paddle/device/is_compiled_with_xpu_cn.rst
23+
paddle/static/xpu_places_cn.rst
24+
paddle/device/XPUPlace_cn.rst
3425
paddle/utils/cpp_extension/load_cn.rst
3526
paddle/utils/cpp_extension/setup_cn.rst
3627
paddle/utils/cpp_extension/CppExtension_cn.rst
3728
paddle/utils/cpp_extension/CUDAExtension_cn.rst
38-
upgrade_guide_cn.md
39-
paddle/hapi/hub/Overview_cn.rst
40-
paddle/hapi/hub/help_cn.rst
41-
paddle/hapi/hub/list_cn.rst
42-
paddle/hapi/hub/load_cn.rst
29+
paddle/hub/Overview_cn.rst
30+
paddle/incubate/autograd/Overview_cn.rst

ci_scripts/check_api_cn.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function filter_cn_api_files() {
1111
local __resultvar=$2
1212
local need_check_files=""
1313
for file in `echo $git_files`;do
14-
grep "code-block" ../docs/$file > /dev/null
14+
grep 'code-block:: python' ../docs/$file > /dev/null
1515
if [ $? -eq 0 ] ;then
1616
api_file=`echo $file | sed 's#api/##g'`
1717
grep -w "${api_file}" ${DIR_PATH}/api_white_list.txt > /dev/null

docs/advanced_guide/index_en.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ So far you have already been familiar with PaddlePaddle. And the next expectatio
1717

1818
inference_deployment/index_en.rst
1919
flags/flags_en.rst
20-

0 commit comments

Comments
 (0)