gpt4docstrings

class gpt4docstrings.generate_docstrings.GPT4Docstrings(paths: str | List[str], excluded=None, model: str = 'gpt-3.5-turbo', docstring_style: str = 'google', translate: bool = True, api_key: str | None = None, verbose: int = 0, config: GPT4DocstringsConfig | None = None)[source]
async generate_file_docstrings(filename: str, file_content: str, nodes: List[GPT4DocstringsNode]) str[source]

Generates docstrings for a single file.

Parameters:
  • filename (str) – The path of the file to generate docstrings for.

  • file_content (str) – The content of the file to be processed.

  • nodes (List[GPT4DocstringsNode]) – The list of GPT4DocstringsNode containing nodes from classes and functions

Returns:

The new file content

get_filenames_from_paths() List[str][source]

Retrieves the filenames from the input paths.

Returns:

The list of filenames.

Return type:

List[str]

run()[source]

Generates docstrings for the input files or directories.

async translate_file_docstrings(filename: str, file_content: str, nodes: List[GPT4DocstringsNode]) str[source]

Generates docstrings for a single file.

Parameters:
  • filename (str) – The path of the file to generate docstrings for.

  • file_content (str) – The content of the file to be processed.

  • nodes (List[GPT4DocstringsNode]) – The list of GPT4DocstringsNode containing nodes from classes and functions

Returns:

The new file content