Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
FluidDoc
提交
03f24d1b
F
FluidDoc
项目概览
PaddlePaddle
/
FluidDoc
通知
10
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
23
列表
看板
标记
里程碑
合并请求
111
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
FluidDoc
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
23
Issue
23
列表
看板
标记
里程碑
合并请求
111
合并请求
111
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
03f24d1b
编写于
6月 15, 2020
作者:
L
lelelelelez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
full api;test=develop
上级
77472587
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
31 deletion
+32
-31
doc/fluid/api_cn/chinese_samplecode_processor.py
doc/fluid/api_cn/chinese_samplecode_processor.py
+22
-14
doc/fluid/api_cn/framework_cn/ExecutionStrategy_cn.rst
doc/fluid/api_cn/framework_cn/ExecutionStrategy_cn.rst
+0
-0
scripts/check_api_cn.sh
scripts/check_api_cn.sh
+10
-17
未找到文件。
doc/fluid/api_cn/chinese_samplecode_processor.py
浏览文件 @
03f24d1b
...
...
@@ -32,7 +32,7 @@ def remove_desc_code(srcls, filename):
if
filename
==
'layers_cn/sums_cn.rst'
:
srcls
.
pop
(
11
)
if
filename
==
'layers_cn/sum_cn.rst'
:
for
i
in
range
(
len
(
srcls
)
-
1
,
61
,
-
1
):
for
i
in
range
(
len
(
srcls
)
-
1
,
61
,
-
1
):
srcls
.
pop
(
i
)
if
filename
==
'layers_cn/softmax_cn.rst'
:
srcls
.
pop
(
30
)
...
...
@@ -88,10 +88,12 @@ def extract_sample_code(srcfile, status_all):
srcc
=
srcfile
.
read
()
srcfile
.
seek
(
0
,
0
)
srcls
=
srcfile
.
readlines
()
srcls
=
remove_desc_code
(
srcls
,
filename
)
# remove description info for samplecode
srcls
=
remove_desc_code
(
srcls
,
filename
)
# remove description info for samplecode
status
=
[]
sample_code_begins
=
find_all
(
srcc
,
" code-block:: python"
)
if
len
(
sample_code_begins
)
==
0
:
print
(
"No Sample Code: %s"
%
filename
)
status
.
append
(
-
1
)
else
:
...
...
@@ -107,15 +109,18 @@ def extract_sample_code(srcfile, status_all):
startindent
=
""
# remove indent error
if
srcls
[
start
+
blank_line
].
find
(
"from"
)
!=
-
1
:
startindent
+=
srcls
[
start
+
blank_line
][:
srcls
[
start
+
blank_line
].
find
(
"from"
)]
startindent
+=
srcls
[
start
+
blank_line
][:
srcls
[
start
+
blank_line
].
find
(
"from"
)]
elif
srcls
[
start
+
blank_line
].
find
(
"import"
)
!=
-
1
:
startindent
+=
srcls
[
start
+
blank_line
][:
srcls
[
start
+
blank_line
].
find
(
"import"
)]
startindent
+=
srcls
[
start
+
blank_line
][:
srcls
[
start
+
blank_line
].
find
(
"import"
)]
else
:
startindent
+=
check_indent
(
srcls
[
start
+
blank_line
])
content
+=
srcls
[
start
+
blank_line
][
len
(
startindent
):]
for
j
in
range
(
start
+
blank_line
+
1
,
len
(
srcls
)):
# planish a blank line
if
not
srcls
[
j
].
startswith
(
startindent
)
and
srcls
[
j
]
!=
'
\n
'
:
if
not
srcls
[
j
].
startswith
(
startindent
)
and
srcls
[
j
]
!=
'
\n
'
:
break
if
srcls
[
j
].
find
(
" code-block:: python"
)
!=
-
1
:
break
...
...
@@ -128,19 +133,22 @@ def extract_sample_code(srcfile, status_all):
def
run_sample_code
(
content
,
filename
):
# three status ,-1:no sample code; 1: running error; 0:normal
fname
=
filename
.
split
(
"/"
)[
-
1
].
replace
(
"_cn"
,
""
).
replace
(
".rst"
,
""
)
+
".py"
fname
=
filename
.
split
(
"/"
)[
-
1
].
replace
(
"_cn"
,
""
).
replace
(
".rst"
,
""
)
+
".py"
tempf
=
open
(
"temp/"
+
fname
,
'w'
)
content
=
"# -*- coding: utf-8 -*-
\n
"
+
content
tempf
.
write
(
content
)
tempf
.
close
()
cmd
=
[
"python"
,
"temp/"
+
fname
]
subprc
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
subprc
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
_
,
error
=
subprc
.
communicate
()
err
=
""
.
join
(
error
.
decode
(
encoding
=
'utf-8'
))
if
subprc
.
returncode
!=
0
:
print
(
"
\n
Sample code error found in "
,
filename
,
":
\n
"
)
#print("\nSample code error found in ", filename, ":\n")
print
(
"Sample code error found in %s"
%
filename
)
print
(
err
)
status
=
1
else
:
...
...
@@ -148,6 +156,7 @@ def run_sample_code(content, filename):
os
.
remove
(
"temp/"
+
fname
)
return
status
def
test
(
file
):
temp
=
[]
src
=
open
(
file
,
'r'
)
...
...
@@ -169,7 +178,6 @@ if os.path.isdir("my_paddle_model"):
if
os
.
path
.
isdir
(
"my_paddle_vars"
):
shutil
.
rmtree
(
"my_paddle_vars"
)
if
not
os
.
path
.
isdir
(
"temp"
):
os
.
mkdir
(
"temp"
)
...
...
@@ -183,10 +191,9 @@ else:
if
not
os
.
path
.
exists
(
sys
.
argv
[
1
]):
print
(
"File not found"
)
sys
.
exit
(
1
)
res
=
test
(
sys
.
argv
[
1
])
res
=
test
(
sys
.
argv
[
1
])
output
.
append
(
res
)
status_groups
=
{
-
1
:
[],
0
:
[],
1
:
[]}
# polishes show format
ci_pass
=
True
...
...
@@ -207,7 +214,6 @@ for one_file in output:
error_api
=
status_groups
[
-
1
]
+
status_groups
[
1
]
total_error_number
=
len
(
error_api
)
print
(
"****************************************************"
)
print
(
"----------------End of the Check--------------------"
)
print
(
"****************************************************"
)
...
...
@@ -217,10 +223,12 @@ if total_error_number > 0:
type_two_number
=
len
(
status_groups
[
1
])
if
type_one_number
>
0
:
print
(
"Error type one sample number is:{}"
.
format
(
type_one_number
))
print
(
"Error raised from type one:no sample code."
,
str
(
status_groups
[
-
1
]))
print
(
"Error raised from type one:no sample code."
,
str
(
status_groups
[
-
1
]))
if
type_two_number
>
0
:
print
(
"Error type two sample number is:{}"
.
format
(
type_two_number
))
print
(
"Error raised from type two:running error sample code."
,
str
(
status_groups
[
1
]))
print
(
"Error raised from type two:running error sample code."
,
str
(
status_groups
[
1
]))
if
not
ci_pass
:
print
(
"Mistakes found in sample codes."
)
exit
(
1
)
...
...
doc/fluid/api_cn/framework_cn/ExecutionStrateg
y_cn.rst
→
doc/fluid/api_cn/framework_cn/ExecutionStrategy_cn.rst
浏览文件 @
03f24d1b
文件已移动
scripts/check_api_cn.sh
浏览文件 @
03f24d1b
...
...
@@ -14,21 +14,14 @@ else
pip
install
-U
python/dist/paddlepaddle_gpu-0.0.0-cp27-cp27mu-linux_x86_64.whl
fi
for
files
in
`
echo
$git_files
`
;
do
grep
"code-block"
$files
if
[
$?
-eq
0
]
;
then
echo
$files
|grep
'doc/fluid/api_cn/.*/.*.rst'
if
[
$?
-eq
0
]
;
then
api_file
=
`
echo
$files
|sed
's#doc/fluid/api_cn/##g'
`
cd
/FluidDoc/doc/fluid/api_cn/
grep
-w
"
$api_file
"
/FluidDoc/scripts/api_white_list.txt
if
[
$?
-ne
0
]
;
then
python chinese_samplecode_processor.py
$api_file
if
[
$?
-ne
0
]
;
then
exit
5
fi
fi
fi
fi
done
files
=
`
find
$PWD
/doc/fluid/api_cn | xargs
ls
-d
|
grep
'doc/fluid/api_cn/.*/.*.rst'
`
if
[
$?
-eq
0
]
;
then
se
=
$PWD
/doc/fluid/api_cn/
api_files
=
`
echo
$files
|sed
's#'
$PWD
'/doc/fluid/api_cn/##g'
`
cd
$PWD
/doc/fluid/api_cn/
for
api_file
in
$api_files
;
do
python chinese_samplecode_processor.py
$api_file
done
fi
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录