问题
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?
回答1:
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.
回答2:
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)
来源:https://stackoverflow.com/questions/4451645/displaying-function-documentation-in-pydev