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.
PyCharm recognizes inline documentation created in accordance with the JavaScript Documentation Tool format. Press Ctrl+Q or choose View | Quick Documentation Lookup on the main menu. In the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | General | Code Completion. The Code completion page opens.
Docstrings are accessible from the doc attribute (__doc__) for any of the Python objects and also with the built-in help() function. An object's docstring is defined by including a string constant as the first statement in the object's definition.
In the Docstrings section, set the Docstring format to 'reStructuredText' and make sure 'Analyze Python code in doctrings' is selected. If you type the triple quotes to start your docstring and then press Enter, PyCharm will automatically provide a number of relevant sphinx Info Fields for you.
I contacted PyCharm support, and this is what they said:
For tuple please use
(<type_1>, <type_2>, <type_3>, e t.c.)
syntax.E.g.:
""" :rtype: (string, int, int) """
This is confirmed in PyCharm's documentation:
Type Syntax
Type syntax in Python docstrings is not defined by any standard. Thus, PyCharm suggests the following notation:
...
- (Foo, Bar) # Tuple of Foo and Bar
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