A CLI tool for extracting, managing and checking code snippets from Codat documentation. Currently consists of two commands
- extract: This will find every markdown file
in the docs directory containing a code snippet. It will then extract those snippets into files under a
temp/directory. - check: This will copy those files into a container with all nessecary Codat SDK dependancies and perform checks that the imports and code are correct and would build.
This project uses uv for dependency management.
# Install dependencies
uv sync
# Install development dependencies
uv sync --extra dev# Run the code extractor
uv run code-util extract
# Run compiler checks on extracted code, (can only be done on lang at a time)
uv run code-util check -l programming-language
# Get help in the cli
uv run code-util --helpmain.py- Entrypoint for the CLI.code_finder/- module for code relating to the CodeFinder class a.k.a the functionality to scan through markdown documents.code_checker/- module for code relating to the CodeChecker class a.k.a the functionality to build containers and run commands in them.code_checker/docker/- docker files, scripts and config that the containers use.temp/- Generated code snippets (gitignored).files_with_code.txt- List of files containing code (gitignored).
- Click - Framework for building CLIs.
- Docker SDK For Python - Library for interacting with the Docker API.
- Pytest - Python Unit testing Framework.
- Pyfakefs - Python utility for faking a filesystem during testing.
- Hard coded to only deal with python, javascript(typescript) and C#
- Javascript container uses a private npm package. Please set PAT_TOKEN and CODAT_EMAIL env vars in order to build.