如何为在 PyCharm 快速文档功能中可见的 Python 变量创建文档? [英] How to create documentation for Python variables that will be visible in PyCharm quick documentation functionality?

查看:88
本文介绍了如何为在 PyCharm 快速文档功能中可见的 Python 变量创建文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 PushButtonType.py 的文件,我在其中定义了两个变量:

OK = 0 # 就像一个 OK 按钮.""" 就像一个取消按钮."""取消 = 0

在另一个文件中,我导入并使用这些变量:

from PushButtonType import CANCEL, OKfoo = 取消酒吧 = 好

我希望第一个文件中的注释在 PyCharm 的快速文档 (Ctrl+Q) 功能中可见.目前,当我将光标放在一个变量上并按 Ctrl+Q 时,我会收到一条消息,指出未找到文档"(请参见下面的屏幕截图).

我希望评论在快速文档弹出窗口中可见.我怎样才能做到这一点?有什么特殊的评论格式吗?

解决方案

With

I have a file named PushButtonType.py where I define two variables:

OK = 0  # acts like a OK button.

""" acts like a cancel button. """
CANCEL = 0

In another file, I import and use those variables:

from PushButtonType import CANCEL, OK

foo = CANCEL
bar = OK

I want the comments from the first file to be visible in the Quick Documentation (Ctrl+Q) functionality of PyCharm. Currently, when I put a cursor on one of the variables and press Ctrl+Q, I get a message saying "No documentation found" (see screenshot below).

I would like the comments be visible in the Quick documentation popup. How can I do this? Is there some special format of comments?

解决方案

With 2018.2 EAP:

bar = 1
"""bar variable"""

这篇关于如何为在 PyCharm 快速文档功能中可见的 Python 变量创建文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆