-
Notifications
You must be signed in to change notification settings - Fork 752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ci parameter checking script #6864
Conversation
感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-6864.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html |
docs/api/paddle/einsum_cn.rst
Outdated
@@ -68,9 +68,9 @@ Einsum 求和过程理论上等价于如下四步,但实现中实际执行的 | |||
::::: | |||
|
|||
|
|||
**equation** (str):求和标记 | |||
- **equation** (str):求和标记 | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个空行删一下吧
docs/api/paddle/unstack_cn.rst
Outdated
@@ -13,11 +13,9 @@ unstack | |||
参数 | |||
:::::::::::: | |||
|
|||
- **x** (Tensor) – 输入 x 为 ``dim > 0`` 的 Tensor, | |||
支持的数据类型:float32,float64,int32,int64, complex64,complex128。 | |||
- **x** (Tensor) – 输入 x 为 ``dim > 0`` 的 Tensor,支持的数据类型:float32,float64,int32,int64, complex64,complex128。 | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs/api/paddle/unstack_cn.rst
Outdated
|
||
- **axis** (int | 可选) – 输入 Tensor 进行 unpack 运算所在的轴,axis 的范围为:``[-D, D)`` , | ||
如果 ``axis < 0``,则 :math:`axis = axis + dim(x)`,axis 的默认值为 0。 | ||
- **axis** (int | 可选) – 输入 Tensor 进行 unpack 运算所在的轴,axis 的范围为:``[-D, D)`` ,如果 ``axis < 0``,则 :math:`axis = axis + dim(x)`,axis 的默认值为 0。 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ci_scripts/check_api_parameters.py
Outdated
default_value = ast.dump( | ||
fake_func.body[0].args.defaults[ | ||
i - (num_args - num_defaults) | ||
] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dump 是用来可视化的,一般只用于 debug,这里有必要 dump 么?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
收到,当时貌似是把调试的代码直接粘贴过去了
ci_scripts/check_api_parameters.py
Outdated
@@ -56,76 +56,130 @@ def parse_args(): | |||
|
|||
def _check_params_in_description(rstfilename, paramstr): | |||
flag = True | |||
info = "" | |||
params_intitle = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intitle
拆成 in_title
吧,这样看着很奇怪,其他地方也都改一下吧
ci_scripts/check_api_parameters.py
Outdated
params_intitle.append(arg.arg) | ||
# vararh(*args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# vararh(*args) | |
# vararg(*args) |
@@ -220,9 +277,11 @@ def check_api_parameters(rstfiles, apiinfo): | |||
result = True | |||
if check_failed: | |||
result = False | |||
print(f"check_api_parameters failed: {check_failed}") | |||
for path, info in check_failed.items(): | |||
print(f"Checking failed file:{path}\nError:{info}\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的 path
是生成的 html 文件路径还是原始的 rst 文件路径?从提示角度来看,使用源文件 rst 是更推荐的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path是rst文件的路径文件名,例如"api/paddle/unstack_cn.rst",是要改一下变量名吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path是rst文件的路径文件名,例如"api/paddle/unstack_cn.rst",是要改一下变量名吗?
这个倒不用,只是确认下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
尝试修复ci参数检查
为方便描述,以下称图中红框部分为文档的标题 API 字符串,蓝框部分为文档的参数板块:
本pr的大致贡献如下:
完善提取intitle参数的代码
之前的只能提取文档标题 API 字符串
.. py:function:: func()
的args
参数,完善后可以提取 API 中所有类型的参数;添加更详细的文档参数检查日志
添加了更详细的日志来帮助排查文档的格式问题:
Something wrong with the format of params list in description, check it please.
表示文档的参数板块存在格式问题
Params section in description is empty, check it please.
表示文档的参数板块内容为空
The number of params in title does not match the params in description: {len(params_intitle)} != {len(items)}.
表示文档标题 API 字符串的参数数量
len(params_intitle)
与参数板块中的参数数量len(items)
不符the following param in title does not match the param in description: {pname_intitle} != {pname_indesc}
表示文档标题 API 字符串中的参数
pname_intitle
与参数板块中对应位置参数pname_indesc
的名称不符param name '{pname_intitle}' not matched in description line{i+1}, check it please.
表示文档标题 API 字符串中的参数
pname_intitle
在参数板块中对应位置(第i+1
行处)没有找到相应的描述params section not found in description, check it please.
表示文档中没有参数板块
修复现有问题文档
修正了之前发现的存在格式问题的文档,具体列表见 #6839
统一用 Inplace 文档链接 Outplace 文档
将以下文档改为将 Inplace 版本的 API 文档的参数介绍链接向 Outplace 版本的 API 文档,与其他文档统一:
总览和 Inplace 文档跳过参数检查
在参数检查时,将总览文档(
api/paddle/Overview_cn.rst
)和所有 Inplace 版本的 API 文档自动跳过开启参数检查功能