Skip to content

AutoDog: An automatic documentation generator to document a specific segment of code

License

Notifications You must be signed in to change notification settings

tishikawaz/autodog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AutoDog: An automatic documentation generator to document a specific segment of code

License

AutoDog uses LLM to generate documentation for specific segments of code automatically. It can be made documentation of the following language.

  • Python
  • Fortran

You can find code documentation generated by AutoDog in 'test/python/out.py', 'test/fortran/out.f90', and AutoDog codes. AutoDog generated the code documentation by itself.

Requests

  • Python 3.9 or above
  • OpenAI Python Library

Installation

python -m pip install git+https://github.com/tishikawaz/autodog.git

Usage

Command line interface

autodog code.py --key YOUR_OPENAI_KEY

You can find the options by autodog -h.

Python interface

import autodog

code = autodog.code('your_code.f90')
engine = autodog.engine(api_key='YOUR-API-KEY', model='gpt-3.5-turbo-0613')
doc_model = autodog.doc_model(model_name='google style docstring')

# insert code documents to a function, class, module, ...
code.insert_docs(engine, doc_model)

# overwrite your_code.py
code.write()

Engine options

autodog.engine() is a generator to make a autodog.Engine instance. The usage is the following:

engine = autodog.engine(name='chatgpt', kwargs)

where name is the Engin name you want to generate and kwargs is an argument you give to the constructor of the engine of your choice. The default name is chatgpt. And it should be selected from the list ['chatgpt', 'dummy'].

You can set the following arguments for autodog.ChatGPTEngine, which can be generated by name='chatgpt' option:

Arguments Type Default value Description
model str 'gpt-3.5-turbo' ChatGPT model name. You can choose from '/v1/chat/completions' in OpenAI website.
line_length int 72 Maximum line length.
notes list[str] [] Notes that use in the documentation generation. We can send the information such as abbreviation and limitation. For example, notes = ['The word impl, sometimes used in function names, indicates the implementation'].
api_key str {@env OPENAI_API_KEY} OpenAI API key. We can generate the key here.
api_key_path str {@env OPENAI_API_KEY_PATH} File path where the key is stored.
api_base str {@env OPENAI_API_BASE} or 'https://api.openai.com/v1' Your endpoint. If {@env OPENAI_API_BASE} is void, api_base will be set 'https://api.openai.com/v1'.
api_version str {@env OPENAI_API_VERSION} or a default of OpenAI Python API API version. If {@env OPENAI_API_VERSION} is void, api_version will be set the default of OpenAI Python API.
api_type str {@env OPENAI_API_TYPE} or 'open_ai' API type. If {@env OPENAI_API_TYPE} is void, api_type will be set 'open_ai'.
deployment_id str None Deployment ID of Azure OpenAI instance.
http_proxy str None The HTTP proxy address.
https_proxy str None The HTTPS proxy address.
rate_limit float 20.0 Rate limit of OpenAI API [sec.]. Please see OpenAI rate limits guide.

Documentation Model Option

autodog.doc_model() is a generator to make a autodog.DocModel instance. The usage is the following:

doc_model = autodog.doc_model(model_name='google style docstring')

where model_name is the documentation model name that can be selected in the list, ['docstring', 'google style docstring', 'numpy style docstring', 'reStructuredText', 'javadoc']. The default is 'google style docstring'.

Insert options

You can set the following options:

code.insert_docs(
    engine,
    doc_model,
    overwrite=True,
    progress_bar=tqdm,
    args...
)

where overwrite is the option for overwriting code documentation and progress_bar is a progress bar object (such as tqdm and progress_bar we provide).

Write code options

The code can be saved in different a location with the following option:

code.write(
    filepath = 'out.py' # The default is the file path you specified when you created the code instance.
)

where filepath is the file path you want to write.

License

License

AutoDog is an open source software, it is distributed under the MIT license. More details of the MIT license available at the following file: LICENSE.

About

AutoDog: An automatic documentation generator to document a specific segment of code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published