ndg)A small program to generate docstrings using Ollama-compatible LLMs
I don’t like writing docstrings.
Large language models (LLMs) don’t complain about writing docstrings.
Therefore, if I can get LLMs to write docstrings for me, then I’ll be happy and free!
This tool (neural docstring generator, or ndg) is meant to provide a proof of
concept on how to:
ndg was tested to work on x86-64 Linux computers running Python3.10.
It is assumed that you have a working ollama instance on your computer. To
learn more, see the
Ollama GitHub repository.
The following dependencies are required:
python3.10poetrylangchainprogressclickpyfsTo install:
git clone this repositorycd into this repositorypip install -r requirments && poetry installndg tool with makeUsage: ndg [OPTIONS]
Options:
-i, --input PATH Source file to generate docstrings for [required]
-m, --model TEXT LLM used to generate docstrings. NOTE: Must be
recognizable by Ollama
-s, --system TEXT The system prompt to use
-o, --output PATH File to output docstrings to [required]
--help Show this message and exit.
If your input and output are equivalent, then a new file will be created in
the same directory as input, but with the .ndg file extension appended to
avoid overwriting content between the two files.
By default,
Ollama’s default CodeGemma model (codegemma)
is used for this tool.
Here is the default system prompt.
This file contains code for counting lines of code of software projects.
Generate suitable docstring for these Python functions in Google's style.
Do not explain the result.
Only return the docstring and function declaration.
Return as raw text.
This can be adjusted with ndg --system