使'Google'成为所有项目PyCharm的默认文档字符串样式

问题描述 投票:3回答:2

我知道我可以去设置|工具| Python集成工具| Docstrings |文档字符串格式|谷歌,但这只设置当前项目的文档字符串格式(由窗口中的“当前项目”标题指示)。我正在寻找一种更改默认设置的方法,以便我的所有项目默认使用google docstring格式。

据我所知,JetBrains qazxsw poi没有提到如何实现这个目标。

intellij-idea pycharm docstring
2个回答
3
投票

目前无法做到这一点。请向own documentation提交有关它的功能请求


2
投票

在撰写本文时,这是不可能的。在过去的几年里,已经提交了几张请求此功能的门票,可能正在进行中。

https://youtrack.jetbrains.com/issues/PY

https://youtrack.jetbrains.com/issue/PY-33833

在短期内,如果您需要从默认值转换以前的项目,您可以发现该设置存储在“.idea / MYPROJECT.iml”文件中:

https://youtrack.jetbrains.com/issue/PY-20243

默认情况下,没有PyDocumentationSettings组件,因此您需要添加它。在Linux中,您可以在终端中运行以下(非常hackish)代码来更改任何子目录中的所有项目:

  <component name="PyDocumentationSettings">
    <option name="myDocStringFormat" value="Google" />
  </component>

如果你只是想从Numpy to Google,你可能会使用:

new_docstring='  <component name="PyDocumentationSettings">\n    <option name="myDocStringFormat" value="Google" />\n  </component>\n</module>'
find . -type f -name '*.iml' -print0 | xargs -0 sed -i "s|</module>|$new_docstring|g"
© www.soinside.com 2019 - 2024. All rights reserved.