code2doc is a lightweight Python tool to automatically generate .docx assignment files from your source code.
It scans your project folder, picks up specified files, and formats them neatly into a Word document — perfect for uploading or submitting coursework without copy-pasting code a million times.
- 🚀 Automatically traverses your project folder (using os.walk)
- 📂 Collects .java files (configurable to other languages like .py, .cpp, etc.)
- 📝 Exports your code into a clean, readable DOCX file
- 🔠 Custom fonts & formatting for code blocks
- 🏷️ Adds headings for each file and subdirectory
- 📌 Optional cover page / header / footer
- 🔗 Supports clickable GitHub links inside the document
This project uses uv as the Python package manager.
git clone https://www.github.com/anshulbadhani/code2doc
cd code2doc- Make a
config.jsonfile. - Paste the contents from
sample_config_file.json. - Edit the fields accordingly.
- Run the python script using:
uv run main.py
You can also use uv run main.py --help for seeing all the possible options
code2doc/
├── main.py # Entry point script
├── config.json # Active project configuration (your paths & extensions)
├── sample_config_file.json # Example config template
├── pyproject.toml # Project metadata & dependencies (uv format)
├── uv.lock # Lockfile for uv dependency versions
└── README.md # Project documentation