Skip to main content

Lightweight autodoc for github readme

Project description

Tinydocs

Lightweight autodoc for github.

Are you in need of a simple and efficient solution for documenting your Python code, without the hassle of setting up and maintaining a full-fledged documentation website like readthedocs? Do you want something that can quickly and easily be integrated into GitHub, allowing your team to quickly access the documentation for a few classes and helper functions? Look no further!

Tinydocs is right for you!

readthedocs automatically generates the documentation of your .py files in a small elegant way that fits in a simple README.md. Check out the example function below or the example directory.

Contents

Installation

Best way to install tinydocs is through pip:

pip install tinydocs

Example

The following is an example of the documentation egenrated for a simple function. YOu can finde how tinydocs handles and entire directory by checking the example directory.

Function

module.function(var1, var2, long_var_name=None, *args)

Warning Deprecation: function will be removed in version 2.0.0, it is replaced by better_function because the new one is blazingly fast.

This is an example documentation. Several sentences providing an extended description. Refer to variables using back-ticks, e.g. var. Look at this really big equation that I took from [^1]

$$( \sum_{k=1}^n a_k b_k )^2 \leq ( \sum_{k=1}^n a_k^2 ) ( \sum_{k=1}^n b_k^2 )$$

Parameters

  • var1: array_like
     Array_like means all those objects -- lists, nested lists, etc. -- that can be converted to an array. We can also refer to variables like `var1`.
  • var2: int
     The type above can either refer to an actual Python type (e.g. ``int``), or describe the type of the variable in more detail, e.g. ``(N,) ndarray`` or ``array_like``.
  • long_var_name: {'hi', 'ho'}, optional
     Choices in brackets, default first when optional.
  • *args: iterable
     Other arguments.
Returns

  • var3: int
     Returns `var3` which is of type ``int``.
Examples

These are written in doctest format, and should illustrate how to use the function.

>>> a = [1, 2, 3]
>>> b = deprecated_function(a)
>>> print(b)
[4,5,6]

[^1]: Trager, Scott. "The Earth's atmosphere: seeing, background, absorption & scattering" (PDF). S.C. Trager. Retrieved 31 May 2022

Syntax

Currently tinydocs only supports NumpyDoc syntax. This might change in the future. For a detailed guide check out numpy's style guidelines you can also check-out the example directory of this project.

Here is the docstring that generates the documentation on the example above, taken mostly from numpydoc's example.

def function(var1, var2, long_var_name=None, *args):
    """This is an example documentation.

    Several sentences providing an extended description. Refer to
    variables using back-ticks, e.g. `var`.

    Parameters
    ----------
    var1 : array_like
        Array_like means all those objects -- lists, nested lists, etc. --
        that can be converted to an array.  We can also refer to
        variables like `var1`.
    var2 : int
        The type above can either refer to an actual Python type
        (e.g. ``int``), or describe the type of the variable in more
        detail, e.g. ``(N,) ndarray`` or ``array_like``.
    long_var_name : {'hi', 'ho'}, optional
        Choices in brackets, default first when optional.
    *args : iterable
        Other arguments.

    Returns
    -------
    var3 : int
        Returns `var3` which is of type ``int``.

    Notes
    -----
    Look at this really big equation that I took from [1]_

    $$( \sum_{k=1}^n a_k b_k )^2 \leq ( \sum_{k=1}^n a_k^2 ) ( \sum_{k=1}^n b_k^2 )$$

    Warnings
    --------
    Deprecation Warning: `deprecated_function` will be removed in version 2.0.0, it is replaced by `better_function` because the new one is blazingly fast.

    References
    ----------
    .. [1] Trager, Scott. "The Earth's atmosphere: seeing, background, absorption & scattering" (PDF). S.C. Trager. Retrieved 31 May 2022

    Examples
    --------
    These are written in doctest format, and should illustrate how to
    use the function.

    >>> a = [1, 2, 3]
    >>> b = deprecated_function(a)
    >>> print(b)
    [4,5,6]
    """
    pass

Basic Usage

tinydocs can be run directly from the command line using:

tinydocs <options>

Note By design --tinydocs only looks at .py files and skips over hidden directories or files/functions/methods that start with "_"(underscore).

  • --dir: Directory to document. Defaults to working directory.
  • --output: Output path and name of documentation file. Defaults to --dir/TINYDOCS.md when not supplied.
  • --exclude-dirs: List of directories to exclude entirely from the documentation.
  • --exclude-files: List of files to exclude individually from the documentation.
  • --help: Help will always be given to those who ask for it.

Github Workflow

tinydocs incorporates very well with automatic deployment allowing you to update your documentation on every push. Here's an example workflow on .github/workflows/tinydocs.yaml:

name: Update TINYDOCS.md

on:
  push:
    branches:
      - "*"

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Setup Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.10

      - name: Install tinydocs
        run: pip install tinydocs

      - name: Run tinydocs
        run: tinydocs

      - name: Commit and push TINYDOCS.md
        run: |
          git config --local user.email "github-actions@example.com"
          git config --local user.name "GitHub Actions"
          git add TINYDOCS.md
          git commit -m "Update TINYDOCS.md"
          git push

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tinydocs-0.0.2.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

tinydocs-0.0.2-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file tinydocs-0.0.2.tar.gz.

File metadata

  • Download URL: tinydocs-0.0.2.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for tinydocs-0.0.2.tar.gz
Algorithm Hash digest
SHA256 21ac0ff293c71e03b5e2656dd03d451f1e76294a044b2fb5ff5310a7dc30f198
MD5 1b17a89d13e7c3f2b5ee96a308d5ef30
BLAKE2b-256 6a42b2aa1bcb2e7356519f99a386ab467fe08f32f49b5a19a4ccc75badcebbbf

See more details on using hashes here.

File details

Details for the file tinydocs-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: tinydocs-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for tinydocs-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7ff0baf4c19c454735e836a5315aee19a8820c0c9b6e9c14939969c51f0f1e00
MD5 e715492dd60a8f90a9a4e78938b3347f
BLAKE2b-256 91e15ed7f5e1c072c7132ad6c478675262b58b3cb44087bbb51d85756bd4f6b0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page