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.
Python documentation string or commonly known as docstring, is a string literal, and it is used in the class, module, function, or method definition. Docstrings are accessible from the doc attribute (__doc__) for any of the Python objects and also with the built-in help() function.
Press Ctrl+Alt+S and go to Editor | General |Smart Keys. Select the Insert type placeholders checkbox in the Smart Keys page of the editor settings. Place the caret at the function name, and press Alt+Enter . In the list of intention actions that opens, choose Insert documentation string stub.
Yes, you can do that! You can actually 'document' lambdas and variables in a module by attaching docstrings to them.
Class method docstrings should contain the following: A brief description of what the method is and what it's used for. Any arguments (both required and optional) that are passed including keyword arguments. Label any arguments that are considered optional or have a default value.
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
def die_hard(self): """ Throws a :class:`NakatomiPlazaError`. """ raise NakatomiPlazaError('Yippee ki-yay')
Worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With