A simple context builder and converter toolkit
Project description
ContextMaker
ContextMaker is a powerful Python toolkit that converts library documentation into formats optimized for AI agent ingestion. It automatically detects and processes various documentation formats including Sphinx, Jupyter notebooks, Python docstrings, and raw source code.
Feature to enrich the CMBAgents: Multi-Agent System for Science, Made by Cosmologists, Powered by AG2.
Features
- 🔍 Automatic Format Detection: Intelligently detects Sphinx, notebooks, docstrings, or source code
- 📚 Multi-Format Support: Handles Sphinx documentation, Jupyter notebooks, Python docstrings, and raw source
- 🚀 Smart Fallbacks: Multiple conversion methods with automatic fallbacks for maximum compatibility
- 📝 Flexible Output: Generate clean text (.txt) or markdown (.md) files
- 🎯 AI-Optimized: Output formatted specifically for Large Language Model ingestion
- 🔧 Robust Processing: Handles edge cases and provides detailed logging
Supported Documentation Formats
-
Sphinx Documentation (Highest Priority)
- Automatic detection of
conf.pyandindex.rst - Support for Makefile-based builds
- Fallback to direct Sphinx building
- Automatic detection of
-
Jupyter Notebooks
- Recursive search for
.ipynbfiles - Conversion to markdown using
jupytext - Integration with other documentation sources
- Recursive search for
-
Python Docstrings
- AST-based extraction of module, class, and function docstrings
- Structured markdown output with proper headers
-
Raw Source Code
- Fallback for projects without structured documentation
- Preserves code formatting and structure
Installation
Install ContextMaker from PyPI:
python3 -m venv context_env
source context_env/bin/activate
pip install contextmaker
Usage
From the Command Line
ContextMaker automatically finds libraries on your system and generates complete documentation with function signatures and docstrings.
# Convert a library's documentation (automatic search)
contextmaker library_name
# Example: convert pixell documentation
contextmaker pixell
# Example: convert numpy documentation
contextmaker numpy
Advanced Usage
# Specify custom output path
contextmaker pixell --output ~/Documents/my_docs
# Specify manual input path (overrides automatic search)
contextmaker pixell --input_path /path/to/library/source
# Choose output format (txt or md)
contextmaker pixell --extension md
# Save directly to specified file without creating folders (rough mode)
contextmaker pixell --output ./pixell_context.txt --rough
Output
- Default location:
~/your_context_library/library_name.txt - Content: Complete documentation with function signatures, docstrings, examples, and API references
- Format: Clean text optimized for AI agent ingestion
From a Python Script
You can also use ContextMaker programmatically in your Python scripts:
import contextmaker
# Minimal usage (automatic search, default output path)
contextmaker.make("pixell")
# With custom output path
contextmaker.make("pixell", output_path="/tmp")
# With manual input path
contextmaker.make("pixell", input_path="/path/to/pixell/source")
# Choose output format (txt or md)
contextmaker.make("pixell", extension="md")
# Save directly to specified file without creating folders (rough mode)
contextmaker.make("pixell", output_path="./pixell_context.txt", rough=True)
Examples
Processing a Sphinx Project
contextmaker my_library --input_path /path/to/sphinx/docs
Processing Notebooks Only
contextmaker tutorial_project --input_path /path/to/notebooks
Custom Output Format
contextmaker numpy --extension md --output ~/my_docs
Running the Jupyter Notebook
To launch and use the notebooks provided in this project, follow these steps:
- Install Jupyter
If Jupyter is not already installed, you can install it with:
pip install jupyter
- Launch Jupyter Notebook
Navigate to the project directory and run:
jupyter notebook
This will open the Jupyter interface in your web browser.
Dependencies
- Core: Python 3.8+
- Documentation: Sphinx, jupytext, sphinx-rtd-theme
- Processing: markdownify, beautifulsoup4, html2text
- Utilities: rich, numpy, docutils, jinja2
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
This project uses the CAMB code developed by Antony Lewis and collaborators. Please see the CAMB website and documentation for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file contextmaker-1.8.0.tar.gz.
File metadata
- Download URL: contextmaker-1.8.0.tar.gz
- Upload date:
- Size: 394.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
039c26f1a0cf4d0c7196c68f56b8cb85b39ee0d771d1ef31d42f1cf373f1d4ec
|
|
| MD5 |
efca7287aae4b401a967e9af88794eb1
|
|
| BLAKE2b-256 |
358bab4e493aa032499bcf11f09e09f6c51270d3b0b0927ed340ee711c24021f
|
File details
Details for the file contextmaker-1.8.0-py3-none-any.whl.
File metadata
- Download URL: contextmaker-1.8.0-py3-none-any.whl
- Upload date:
- Size: 29.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71461763c9fa82d7bba79494f6f02f1fbae4d8d01ca9bb4c0e935ec6dede717e
|
|
| MD5 |
106955e27bfcb5fd427e89d350151333
|
|
| BLAKE2b-256 |
0394b74f593dd942d6a7be440971d0908ca4b48236234135bcf38a1597d13229
|