https://github.com/dscmatter/codefilestoformat
Make any code files into pdfs/txt using a simple python script
https://github.com/dscmatter/codefilestoformat
python script
Last synced: 4 months ago
JSON representation
Make any code files into pdfs/txt using a simple python script
- Host: GitHub
- URL: https://github.com/dscmatter/codefilestoformat
- Owner: DSCmatter
- License: mit
- Created: 2025-08-10T16:43:11.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-08-15T19:19:49.000Z (6 months ago)
- Last Synced: 2025-08-15T21:44:01.670Z (6 months ago)
- Topics: python, script
- Language: Python
- Homepage:
- Size: 53.7 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# codeFilesToFormat
A simple Python GUI tool to export code files from a selected folder into a single PDF or TXT file, so you don't have to. Supports optional auto-formatting with **Black**, **clang-format**, and **Prettier** before exporting.
## Features
* Select any folder containing code files
* Supported extensions: `.py`, `.c`, `.h`, `.yaml`, `.yml`, `.cpp`, `.java`, `.txt`
* Choose between **Single File** (all code in one PDF/TXT) or **Separate Files** (each file exported individually)
* Output generated in a dedicated folder (`pdf_output` or `txt_output`)
* Optional code formatting before export
## Installation
Clone the repository:
```bash
git clone https://github.com/DSCmatter/codeFilesToFormatr.git
cd codeFilesToFormat
```
Install the required Python packages:
```bash
pip install -r requirements.txt
```
If you want code formatting:
* Install [Black](https://black.readthedocs.io/en/stable/) for Python formatting
* Install [clang-format](https://clang.llvm.org/docs/ClangFormat.html) for C/C++ formatting
* Install [Prettier](https://prettier.io/) for YAML/JSON formatting
## Usage
Run the script:
```bash
python main.py
```
1. Browse and select the folder containing your code
2. Choose **Mode**:
* `Single` → all code in one file
* `Separate` → each file exported separately
3. Choose **Format** (`PDF` or `TXT`)
4. Click **Convert**
5. Your files will be saved in `pdf_output` or `txt_output` next to the script
## Notes
* The script tries to use the `Calibri` font for PDF output. If missing, it falls back to default fonts.
* Large folders may take time to process depending on formatting and file sizes.