Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom PyCharm docstring stubs (i.e. for google docstring or numpydoc formats)

Does PyCharm 2.7 (or will PyCharm 3) have support for custom docstring and doctest stubs? If so, how does one go about writing this specific type of custom extension?

My current project has standardized on using the Google Python Style Guide (http://google-styleguide.googlecode.com/svn/trunk/pyguide.html). I love PyCharm's docstring support, but it's only two supported formats right now are epytext and reStructureText. I want, and am willing to write myself, a PyCharm plugin that creates a documentation comment stub formatted in either Google or Numpydoc style (https://pypi.python.org/pypi/sphinxcontrib-napoleon/). Of special importance here is incorporating the type inference abilities that PyCharm has with the other two documentation types.

like image 889
kalefranz Avatar asked Sep 06 '13 21:09

kalefranz


People also ask

How do I create a docstring in Pycharm?

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.

How do you specify the docstring of a function?

Declaring Docstrings: The docstrings are declared using ”'triple single quotes”' or “””triple double quotes””” just below the class, method or function declaration. All functions should have a docstring.

How do I get function documentation in Pycharm?

Quick documentation look-upPress 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. Select the Show the documentation popup checkbox and specify the elapsed time.


1 Answers

With PyCharm 5.0 we finally got to select Google and NumPy Style Python Docstrings templates.

It is also mentioned in the whatsnew section for PyCharm 5.0.

How to change the Docstring Format:

File --> Settings --> Tools --> Python Integrated Tools

There you can choose from the available Docstrings formats:

Plain, Epytext, reStructuredText, NumPy, Google

As pointed out by jstol: for Mac users, this is under

PyCharm -> Preferences -> Tools -> Python Integrated Tools.

like image 121
Nras Avatar answered Oct 07 '22 21:10

Nras