Giter Club home page Giter Club logo

auto-docs's Introduction

Auto-Docs

Auto-Docs is a CLI tool that automatically generates documentation for your python code using machine learning.

This is a wrapper built around this HuggingFace model.

Usage

I plan on releasing this as a pip package but for now the code can be run directly.

Clone the repo and install requirements (I used python 3.8.8 but I assume it runs with other versions):

git clone https://github.com/jweissenberger/auto-docs.git
cd auto-docs
pip install -r requirements.txt

Then run auto-docs.py and pass in the name of the file you want to generate documentation for:

python auto-docs.py <name_of_your_python_file>

This will automatically download the HuggingFace model if you don't have it already.

Results

auto-docs summarizes what functions do in plain english. For example, given this function:

def chunks(l, n):
    d, r = divmod(len(l), n)
    for i in range(n):
        si = (d + 1) * (i if i < r else r) + d * (0 if i < r else i - r)
        yield l[si:si + (d + 1 if i < r else d)]

It updates it with:

def chunks(l, n):
    """
    Split a list into n - sized chunks .
    """
    d, r = divmod(len(l), n)
    for i in range(n):
        si = (d + 1) * (i if i < r else r) + d * (0 if i < r else i - r)
        yield l[si:si + (d + 1 if i < r else d)]

You can see more results in before.py and after.py

Tips

You can also specify the size of the model you would like to use in the command with -m. The options are small, medium, or the default large.

python auto-docs.py file_to_get_documentation_for.py -m small

The trade off is generally inference time vs quality of the summary. You could hypothetically pass in any HuggingFace model but others probably won't work well.

auto-docs works better when you have good names for your functions and variables as they help it infer what your code is accomplishing.

auto-docs's People

Contributors

jweissenberger avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.