This IntelliJ plugin allows you to generate Python function documentation using OpenAI's ChatGPT.
You can download the plugin from the JetBrains MarketPlace - Docgen
- Generate code documentation using OpenAI's models
- Option to use a custom prompt
- Open IntelliJ IDEA
- Make sure that the Python plugin is installed
- Go to
Preferences
- Select
Plugins
- Click on
Marketplace
and search forDocgen
- Install the plugin and restart IntelliJ IDEA
- To set your OpenAI API key, go to
Preferences > Tools > Docgen
- Enter your API key in the provided input field and click 'Apply'
- Set your keyboard shortcut: go to
Preferences > Keymap
and look forPlugins > Docgen > Generate Docstring
- Right-click on the function you want to generate documentation for
- Choose
Generate Docstring
from the context menu - Wait for the OpenAI model to generate the documentation
- The generated documentation will be displayed in a popup window
- Click
Insert
to add the documentation to your Python function
The default model is gpt-3.5-turbo
. To use another model go to Preferences > Tools > Docgen
and
enter the model name in the provided input field.
The default prompt is:
Generate high-quality docstring for the following Python function including function signature:
To use a custom prompt, go to Preferences > Tools > Docgen
and enter your prompt in the provided input field.
We recommend using IntelliJ IDEA for development. After installing IDEA you can simply open the project folder.
You also need JDK 17. If IDEA can't find this JDK version on your machine it should
suggest downloading it for you after opening any .java
file. You can also go to File > New > Project > JDK > Add SDK
and download the correct JDK version manually.
To test the plugin you go to Run > Run...
and select the Run Plugin
configuration. This will start a new isolated IDEA
instance with Docgen already installed.
To create a ZIP file for distributing the plugin first open the Gradle tool window by clicking View > Tool Windows > Gradle
.
Then select Tasks > intelij > buildPlugin
. If the Gradle tool window is empty click the "reload" button. It will force
IDEA to download all missing tools.
Contributions are welcome! Please open an issue or submit a pull request if you have any suggestions or improvements.