-
Notifications
You must be signed in to change notification settings - Fork 839
【Type Hints】将 typehints 显示在描述中而不是函数签名中 #6676
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
Conversation
感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-6676.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html |
docs/api/paddle/audio/save_cn.rst
Outdated
@@ -3,19 +3,19 @@ | |||
save | |||
------------------------------- | |||
|
|||
.. py:function:: paddle.audio.save(filepath: str, src: paddle.Tensor, sample_rate: int, channels_first: bool = True, encoding: Optional[str] = None, bits_per_sample: Optional[int] = 16) | |||
.. py:function:: paddle.audio.save(filepath, src, sample_rate, channels_first=True, encoding=None, bits_per_sample=16) | |||
|
|||
保存音频数据。 | |||
|
|||
参数 | |||
:::::::::::: | |||
|
|||
- **filepath** (str 或者 Path) - 保存音频路径。 |
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.
- **filepath** (str 或者 Path) - 保存音频路径。 | |
- **filepath** (str) - 保存音频路径。 |
我试了下,pathlib.Path
并不是合法输入
|
||
保存音频数据。 | ||
|
||
参数 | ||
:::::::::::: | ||
|
||
- **filepath** (str 或者 Path) - 保存音频路径。 | ||
- **src** (paddle.Tensor) - 音频数据。 | ||
- **src** (Tensor) - 音频数据。 |
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.
话说这里改成 Tensor
后,为什么变更后的中文文档页面显示的还是 paddle.Tensor
呢?
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.
是 Tensor ~ 上面的图是我把 paddle.Tensor 改为 Tensor 之前的 ~ 现已更新 ~
docs/api/paddle/audio/save_cn.rst
Outdated
- **bits_per_sample** (Optional[int],可选) - 默认是 16,编码位长。 | ||
- **channels_first** (bool,可选) - 如果是 True,那么 src 的 Tensor 形状是[channel,time],如果是 False,则是[time,channel]。默认是 True。 | ||
- **encoding** (str|None,可选) - 默认是 None,编码信息。 | ||
- **bits_per_sample** (int,可选) - 默认是 16,编码位长。 |
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.
这里看起来也能接收 None
,虽然接收 None
后会挂就是了
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.
LGTMeow @sunzhongkai588 看看呢?另外英文的可以按照描述修改下~
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.
LGTM 顺师傅修的太快了
PR Category
User Experience
PR Types
Improvements
Description
将 typehints 显示在描述中,而不是函数签名中 ~
建议:
以本 PR 中的 api
paddle.audio.save
为例,原 api 代码中:from __future__ import annotations
|
需要改为:
此 api 的中文文档中,需要修改:
需要改为
修改后,原中文文档的页面:
变更为:
原英文文档的页面:
变更为 :
注意:此时还未修改此 api 的 docstring,英文文档中,描述中的参数类型,是 sphinx 自动加进去的 ~
但是,如果修改了 api 的 docstring,添加了数据类型,sphinx 理论上会 merge 函数签名中的类型与描述中的参数类型 ~ 因此,此处具体效果还需要后续观察 ~
@sunzhongkai588 @SigureMo