我正在与使用vscode的人合作一个项目。我们编写Python代码。我让他们为他们的函数生成文档字符串,他们使用了vscode中的Autodocstring。这是他们想出的文档字符串:
"""
Subclass ObjectCAD renderToFile method to render the scad file
in renders_dir
Arguments:
file_path {str} -- the destination path for the scad file
Returns:
None
"""它应该是一个Google风格的文档字符串。
当我使用Sphinx生成一个html文档时,下面是我是否得到:

而我应该得到这样的东西:

我是否遗漏了sphinx配置中的一个选项?或者是Autodocstring损坏了?
发布于 2019-01-18 17:59:00
您显示的语法不是Google风格的语法(有关详细示例,请参阅here )。它应该是:
"""
Subclass ObjectCAD renderToFile method to render the scad file
in renders_dir
Args:
file_path (str): the destination path for the scad file
Returns:
None
"""VSCode的autoDocstring扩展必须正确配置才能生成谷歌风格的文档字符串(查找autoDocstring.docstringFormat)。
发布于 2021-03-24 07:26:16
我是否在sphinx配置中缺少一个选项?
如果你想使用sphinx,你需要在settings.json中添加下面的代码。
{
"autoDocstring.docstringFormat": "sphinx"
}转到VS Code菜单:
Windows/Linux上的
macOS -代码>首选项<代码>E218

或者,文件位于以下位置(默认情况下VS Code):
Windows %APPDATA%\Code\User\settings.json
$HOME/Library/Application Support/Code/User/settings.json
$HOME/.config/Code/User/settings.json的
使用doctring的示例
def func1(arg1, arg2):
"""
This function take two arguments, sets the first to equal the second, then returns the new first argument. Pointless.
:param arg1: Some value
:param arg2: Another value
:return: arg1
"""
arg1 = arg2
return arg1https://stackoverflow.com/questions/51591245
复制相似问题