自定义PyCharm docstring存根(即用于google docstring或numpydoc格式)

2024-06-01 02:01:49 发布

您现在位置:Python中文网/ 问答频道 /正文

PyCharm 2.7(或者PyCharm 3)是否支持自定义docstring和doctest存根?如果是,那么如何编写这种特定类型的自定义扩展呢?

我当前的项目已经标准化地使用Google Python样式指南(http://google-styleguide.googlecode.com/svn/trunk/pyguide.html)。我喜欢PyCharm对docstring的支持,但目前只有两种支持的格式是epytext和reStructureText。我想要并且愿意自己编写一个PyCharm插件,它创建一个文档注释存根,格式为Google或Numpydoc样式(https://pypi.python.org/pypi/sphinxcontrib-napoleon/)。这里特别重要的是将PyCharm的类型推断能力与其他两种文档类型结合起来。


Tags: 项目文档pypihttp类型格式google指南
3条回答

使用PyCharm 5.0,我们终于可以选择Google and NumPy Style Python Docstrings模板。

PyCharm 5.0的whatsnew部分也提到了这一点。

如何更改Docstring格式:

File --> Settings --> Tools --> Python Integrated Tools

您可以从可用的Docstrings格式中进行选择:

Plain, Epytext, reStructuredText, NumPy, Google

正如jstol所指出的:对于Mac用户来说

PyCharm -> Preferences -> Tools -> Python Integrated Tools.

正如CrazyCoder所说,它是一个ticket。现在,您只能使用EpyTypereStructuredText

只是为了让@Nras answer显式,从PyCharm 5.0

File > Settings > Tools > Python Integrated Tools > Docstrings > Google

相关问题 更多 >