Skip to content
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

Merged
merged 7 commits into from
Sep 19, 2024
Merged

Conversation

fufu0615
Copy link
Contributor

@fufu0615 fufu0615 commented Sep 13, 2024

尝试修复ci参数检查

为方便描述,以下称图中红框部分为文档的标题 API 字符串蓝框部分为文档的参数板块

image-20240913172149139

本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 文档,与其他文档统一:

"api/paddle/index_fill_cn.rst",
"api/paddle/index_fill__cn.rst",
"api/paddle/index_put_cn.rst",
"api/paddle/index_fill__cn.rst",

总览和 Inplace 文档跳过参数检查

在参数检查时,将总览文档(api/paddle/Overview_cn.rst)和所有 Inplace 版本的 API 文档自动跳过

开启参数检查功能

Copy link

paddle-bot bot commented Sep 13, 2024

感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-6864.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html
预览工具的更多说明,请参考:飞桨文档预览工具

@@ -68,9 +68,9 @@ Einsum 求和过程理论上等价于如下四步,但实现中实际执行的
:::::


**equation** (str):求和标记
- **equation** (str):求和标记

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

这个空行删一下吧

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change


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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines 69 to 73
default_value = ast.dump(
fake_func.body[0].args.defaults[
i - (num_args - num_defaults)
]
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dump 是用来可视化的,一般只用于 debug,这里有必要 dump 么?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

收到,当时貌似是把调试的代码直接粘贴过去了

@@ -56,76 +56,130 @@ def parse_args():

def _check_params_in_description(rstfilename, paramstr):
flag = True
info = ""
params_intitle = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intitle 拆成 in_title 吧,这样看着很奇怪,其他地方也都改一下吧

params_intitle.append(arg.arg)
# vararh(*args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的 path 是生成的 html 文件路径还是原始的 rst 文件路径?从提示角度来看,使用源文件 rst 是更推荐的

Copy link
Contributor Author

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",是要改一下变量名吗?

Copy link
Member

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",是要改一下变量名吗?

这个倒不用,只是确认下

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMeow 🐾

@luotao1 luotao1 merged commit b41831d into PaddlePaddle:develop Sep 19, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants