在 Eclipse 中自动生成 Python 源代码中的虚拟文档

发布于 2024-12-05 20:58:02 字数 408 浏览 5 评论 0原文

当时我正在记录我的很多代码(Python),我想知道 Eclipse 是否有一个插件可以自动为我的函数生成文档字符串,就像 Visual Studio 在编写 // 时为 C# 所做的那样/ 方法。

我一直在寻找解决方案,但我没有运气 - 你们有人知道解决方案吗?

示例:

从方法的参数列表中,将在我的方法定义下创建“虚拟”文档,如下所示:

def myFunction(self, a, b):
    """

    :param a:
    :type a:
    :param b:
    :type b:
    :return:
    :rtype:
    """
    return 'Hello, world'

At the time I am documenting a lot of my code (Python) and I was wondering if there is a plugin to Eclipse that can automatically generate a doc string for my functions, like visual studio does it for C# when writing /// over a method.

I have been searching around for a solution, but I had no luck - do any of you know a solution?

Example:

From my parameter list on a method the "dummy" documentation will be created under my method definition as shown below:

def myFunction(self, a, b):
    """

    :param a:
    :type a:
    :param b:
    :type b:
    :return:
    :rtype:
    """
    return 'Hello, world'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缱绻入梦 2024-12-12 20:58:02

好吧,根据 此文档,如果您按 Ctrl + 1 在方法名称上,您将得到您需要的内容。

对于您的示例(编辑:如果您将选项 PyDev>Editor>Code Style>Docstrings>Doctag Generation 设置为始终获取参数的类型),您将得到:

def myFunction(self, a, b):
    '''

    @param a:
    @type a:
    @param b:
    @type b:
    '''
    return 'Hello, world'

Well, according to this doc, if you press Ctrl + 1 on a method name, you will get what you need.

For your example (EDIT : if you set the option PyDev>Editor>Code Style>Docstrings>Doctag generation to always to get the type of the param), you will get :

def myFunction(self, a, b):
    '''

    @param a:
    @type a:
    @param b:
    @type b:
    '''
    return 'Hello, world'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文