Displaying function documentation in PyDev
Asked Answered
H

2

19

I've gotten Pydev up and running, and almost all is working well. However I'm having some trouble with docstrings.

Let's say for instance I have a function such as the following:

def _get_logging_statement(self):
    """Returns an easy to read string which separates items in the log file cleanly"""
    result = "\n\n#============================================="
    result += "\n#   %-80s#"(self)
    result =+ "\n\n#============================================"
    return result

Assume I've overridden repr to format that string properly as well.

When I hover over this in Eclipse it shows me the full docstring as intended. However, the full implementation is also displayed below the doctsting.

Is there a way to only display the docstring?

Haugen answered 15/12, 2010 at 15:30 Comment(10)
Note: I do not wish to put the docstring below the implementation, as that seems to go against the PEP standard.Haugen
Double-underscore methods are unpleasant (they cause the name of the function to be mangled, which causes bugs and provides no extra security) -- use at your own peril!Sabrinasabsay
Following on from katrielalex, starting with a single underscore avoids the trouble, and is still considered 'internals' by convention.Bloxberg
@katrielalex Modified the function definition per comment. Newer to python, so thanks for the heads up.Haugen
Looks like pydev always shows the entire body under the method. Not sure if there's a setting to change this.Harris
@Harris I've looked through the options, but there is a possibility that I have missed it, but I see that on built in functions as well.Haugen
Added a request: sourceforge.net/tracker/…Haugen
I entered this feature request as ticket #191 but it got no upvotes and was moved to icebox recently. I'd really love an option to show only docstring but it don't think we'll get this in the near future.Poinciana
The feature request link is no longer valid. "The requested URL /tracker/PyDev/191 was not found on this server."Withstand
@StevenVascellaro See pydev.org/faq.html#HowdoIReportaFeatureRequestUproarious
L
15

Doesn't look like it currently. Googled around for this issue and the top result pointed me to this Pydev-users post:

On Mon, May 3, 2010 at 5:45 AM, Janosch Peters wrote:

Hi,

when I hover over a function or class, I get a tooltip showing the whole definition of the function/class not only the docstring (as I would expect).

Is this expected behaviour? I think it would be more useful, if only the content of the docstring is shown.

It's currently expected. Please enter a feature request to make showing just the docstring an option.

Cheers,

Fabio

Looked around the Pydev bug/feature tracker and didn't find this specific issue entered. You might want to enter it in the Pydev feature request tracker and see if you can get help there.

Lianeliang answered 16/12, 2010 at 18:12 Comment(0)
H
0

I have submitted a feature request in the PyDev bug tracker, with ID 863.

In PyCharm when I hover onto a method name, I can see a popup showing only the docstring of every method, without implementation details. And, the tags like @param xx:, @rtype, etc., are parsed correctly and shown in a readable format in the popup, and different style like spinx/epytext/google/plain can be tweaked in settings so that it can recognize all formats.

I would like to suggest the same in PyDev: a popup which shows docstring with tags parsed, without implementation details, and if like javadoc, one can use <code>some code</code> to render it like in HTML, better.

Consider vote up to this ticket if you also want this. (And maybe vote up here, too)

Hexachlorophene answered 10/11, 2017 at 13:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.