gak
gak

Reputation: 32763

PyCharm docstrings linking to classes

IntelliJ IDEA allows for linking to other methods in Java document comments. This allows me to move the cursor over a symbol and jump to the definition using a keyboard shortcut, as well as holding down ctrl while hovering with the mouse displaying an underline under the symbol which is clickable. For example:

/**
  * This is a link to a method {@link #setBalance}
  */

I am trying to achieve this in Python with PyCharm. I've tried various things from other answers without any luck. Here are some attempts:

def my_func(my_arg):
    '''
    Convert a S{decimal.Decimal} to an :ref:`int`.

    This method imports a module called :mod:``django``.

    Sometimes we might call :func:`~utils.error` to raise an {@link Exception}.
    '''

None of these autocomplete or create a hyperlink.

Could it be that PyCharm simply hasn't implemented this functionality (yet)?

This question is similar to Link to class method in python docstring but the answers don't seem to apply to PyCharm.

Upvotes: 31

Views: 11942

Answers (2)

gak
gak

Reputation: 32763

I contacted support and it turns out it hasn't been implemented.

I have created a feature request on their issue tracker:

https://youtrack.jetbrains.com/issue/PY-14743

Update:

original feature request is marked as a duplicate of

https://youtrack.jetbrains.com/issue/PY-27635

State: In progress

Upvotes: 24

MrMister
MrMister

Reputation: 2536

def die_hard(self):
    """
    Throws a :class:`NakatomiPlazaError`.
    """
    raise NakatomiPlazaError('Yippee ki-yay')

Worked for me.

Upvotes: 24

Related Questions