Create documentation comments
Creating documentation comments for Python functions
To create documentation comment for a Python function
Place the caret after the declaration of a function you want to document.
Type opening triple quotes, and press Enter, or Space.
Add meaningful description of parameters and return values.
To create documentation comment for a Python function using intention action
Place the caret somewhere within the function you want to document.
Press Alt+Enter to show the available intention actions.
Choose Insert documentation string stub:
PyCharm generates documentation comment stub according to docstring format, selected in the Python Integrated Tools page.
Example of Python comment
Consider the following function:
Open settings Ctrl+Alt+S and navigate to
.In the Docstring format dropdown, select Epytext:
Then type the opening triple quotes and press Enter or Space. PyCharm generates a documentation comment stub in Epytext format:
Go back to the Python Integrated Tools page in settings (Ctrl+Alt+S) and switch Docstring format to reStructuredText. Then type the opening triple quotes and press Enter or Space. PyCharm generates a documentation comment stub in reStructuredText format: