Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying function documentation in PyDev

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?

like image 454
Scott Avatar asked Dec 15 '10 15:12

Scott


People also ask

How do you write a comment or a docstring in a function?

It is written by using # symbol. Whereas Python Docstrings as mentioned above provides a convenient way of associating documentation with Python modules, functions, classes, and methods.

How do I run code in PyDev?

Go to the menu: Alt + R + S + The number of the Run you wish (It can be Python, Jython, unit-test, etc). Note: if you were using unit-tests, you could use: Ctrl+F9 to run the unit-tests from the module (and even selecting which tests should be run -- and if Shift is pressed it's launched in debug mode).

Which is the correct location to place a docstring for a function?

A function's docstring is a multi-line string that is below the function's head. As a convention, we use triple quotes to enclose the string. You can use either double or single quotation marks to form the triple quotes as long as they're matched.

How do you access a docstring in Python?

As mentioned above, Python docstrings are strings used right after the definition of a function, method, class, or module (like in Example 1). They are used to document our code. We can access these docstrings using the __doc__ attribute.


1 Answers

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.

like image 170
spade78 Avatar answered Sep 23 '22 09:09

spade78