Genius
docugenius.genius.genius
Genius(docstring_format='google', skip_raises=False, skip_returns=False, skip_examples=False, **kwargs)
Bases: ABC
An abstract class for generating docstrings for Python code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
docstring_format
|
Literal['google', 'numpy', 'sprinx']
|
The format of the docstring. Defaults to "google". |
'google'
|
skip_raises
|
bool
|
Whether to include exceptions in the docstring. Defaults to False. |
False
|
skip_returns
|
bool
|
Whether to include return values in the docstring. Defaults to False. |
False
|
skip_examples
|
bool
|
Whether to include examples in the docstring. Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the provided docstring_format is not valid. |
Source code in docugenius/genius/genius.py
clean_llm_output(output)
Clean the output from the LLM model by removing any leading or trailing whitespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
The output from the LLM model. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The cleaned output. |
Source code in docugenius/genius/genius.py
generate(code)
Generate a docstring for the given code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
The code to generate a docstring for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The code with the generated docstring added. |
Source code in docugenius/genius/genius.py
docugenius.genius.openai_genius
OpenAIGenius(model, docstring_format='google', skip_raises=False, skip_returns=False, skip_examples=False)
Bases: Genius
A class to generate docstrings using OpenAI's API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str
|
The model to use for generating docstrings. |
required |
docstring_format
|
Literal['google', 'numpy', 'sprinx']
|
The format of the docstring. Defaults to "google". |
'google'
|
skip_raises
|
bool
|
Whether to include exceptions in the docstring. Defaults to False. |
False
|
skip_returns
|
bool
|
Whether to include return values in the docstring. Defaults to False. |
False
|
skip_examples
|
bool
|
Whether to include examples in the docstring. Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the provided model is not valid. |
Examples:
Initialize the OpenAIGenius instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str
|
The model to use for generating docstrings. |
required |
docstring_format
|
Literal['google', 'numpy', 'sprinx']
|
The format of the docstring. Defaults to "google". |
'google'
|
skip_raises
|
bool
|
Whether to include exceptions in the docstring. Defaults to False. |
False
|
skip_returns
|
bool
|
Whether to include return values in the docstring. Defaults to False. |
False
|
skip_examples
|
bool
|
Whether to include examples in the docstring. Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the provided model is not valid. |
Examples:
Source code in docugenius/genius/openai_genius.py
clean_llm_output(output)
Clean the output from the LLM model by removing any leading or trailing whitespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
The output from the LLM model. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The cleaned output. |
Source code in docugenius/genius/genius.py
generate(code)
Generate a docstring for the given code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
The code to generate a docstring for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The code with the generated docstring added. |