Skip to content
📝 📖 A lightweight in-code doc generator for Python.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
src
.gitignore
LICENSE
README.md

README.md

logo

code-size

Teddy is a lightweight in-code doc generator for Python, based on Jinja Templates.

Install

To install it, clone the repo and use setup.py file.

git clone https://github.com/monolix/teddy
cd teddy/src
python3 setup.py install

Usage

Let's make a calculator.

def add(a, b):
    return float(a + b)

def sub(a, b):
    return float(a - b)

def mult(a, b):
    return float(a * b)

def div(a, b):
    return float(a / b)

That's enough. Client will pay for other features.

Now it needs documentation. Before crying, try using Teddy.

from teddy import Teddy, Section

doc = Teddy("Calculator", "Simple maths calculator.", "Gilfoyle")

ops = Section("Operations", "Operations the calculator can do.")

@ops("Adds two numbers", returns=float)
def add(a, b):
    """>>> add(5, 4) 
9.0"""
    return float(a + b)

@ops("Subtracts two numbers", returns=float)
def sub(a, b):
    """>>> sub(5, 2)
3.0"""
    return float(a - b)

@ops("Multiplies two numbers", returns=float)
def mult(a, b):
    """>>> mult(7, 8)
56.0"""
    return float(a * b)

@ops("Divides two numbers", returns=float)
def div(a, b):
    """>>> mult(8, 4)
2.0"""
    return float(a / b)

doc.add_section(ops)
doc.dump("test.html")

After that, run da kode and look at the new generated file:

example

It's nicely responsive, thanks to Water CSS.

You'll always need to run the code at least once to generate the documentation.

You can use Teddy with Flask, too! Use your imagination.

Contributing

Sharing is caring! If you find some bugs or if you want to change something, everything is under the MIT License, you're free to do that. Just fork the repo and pull request us.

You can’t perform that action at this time.