Generates a professional PDF source code annex with Smart Index, Images and Emoji support.
Project description
📂 codeannex
Generates a professional PDF annex from a project's source code — with syntax highlighting, a clickable table of contents, image rendering, non-selectable line numbers, and configurable fonts.
Features
- Syntax highlighting via Pygments (Catppuccin Mocha theme)
- Clickable table of contents with page numbers (two-pass layout)
- Smart word wrap — breaks at word boundaries, respects emoji codepoints
- Non-selectable line numbers rendered as images
- Image support — embeds PNG, JPG, GIF, WebP, BMP, ICO, and SVG files
- Git-aware — uses
git ls-fileswhen available; falls back to manual.gitignoreparsing - Cross-platform font discovery — finds monospace and emoji fonts on Windows, macOS, and Linux
- Emoji support — configurable fonts for emojis, with fallback for better rendering.
- Tip for Linux: Install
fonts-symbolafor high-coverage monochromatic emoji support that works reliably with ReportLab.
- Tip for Linux: Install
- Emoji descriptions — option to print
[EMOJI NAME]instead of glyphs for systems without emoji fonts. - Configurable fonts — customize normal, bold, monospace, and emoji fonts.
- Page numbering — customizable font size and position.
- Repository Link — show a clickable repository link on the cover page.
- Fast binary file detection — quickly ignores common binary extensions.
Requirements
- Python >= 3.11
reportlab,Pillow,Pygments
Optional SVG rendering (install at least one):
cairosvg(preferred)svglib
For development and testing:
pytest(install withpip install -e ".[dev]")
Installation
pip install codeannex
With SVG support:
pip install "codeannex[svg]"
Requirements
- Python >= 3.11
reportlab,Pillow,Pygments,pdfminer.six
Optional SVG rendering (install at least one): ...
Usage
# Annotate current directory
codeannex
# Annotate a specific project
codeannex /path/to/project
# Custom output filename
codeannex /path/to/project -o my_annex.pdf
# Customized configuration (margins in cm)
codeannex /path/to/project \
--name "My Project" \
--repo-url "https://github.com/user/repo" \
--margin 1.5 \
--margin-top 2.5 \
--page-number-size 10 \
--show-project
Configuration Options
--name NAME— Custom project name (default: directory name).--repo-url URL— Repository URL to show as a clickable link on the cover.--start-page N— Starting page number (default: 1).--margin CM— General margin in cm for all sides.--margin-left CM— Left margin in cm (default: 1.5).--margin-right CM— Right margin in cm (default: 1.5).--margin-top CM— Top margin in cm (default: 2.0).--margin-bottom CM— Bottom margin in cm (default: 2.0).--show-project— Show project name in page footer (default: off).--page-number-size N— Font size for page numbers (default: 8).--normal-font FONT— Font for normal text (default: Helvetica).--bold-font FONT— Font for bold text (default: Helvetica-Bold).--mono-font FONT— Monospace font for code (default: auto-detect).--emoji-font FONT— Font for emojis (default: auto-detect).--emoji-description— Print[DESCRIPTION]instead of emoji glyphs.--check-emoji-font— Check current emoji font style and exit.
Testing
Run the test suite with pytest:
pytest
Output
The generated PDF contains:
- Cover page — project name with page number
- Table of contents — tree-structured, with clickable links to each file
- File pages — syntax-highlighted source, with file path headers and line numbers
Files are ordered: root files first (alphabetical), then directories recursively (alphabetical).
Binary files (e.g., .pdf, .exe) are automatically ignored with warnings if not in .gitignore.
License
MIT
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 codeannex-0.1.1.tar.gz.
File metadata
- Download URL: codeannex-0.1.1.tar.gz
- Upload date:
- Size: 22.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed1f2bab2eea39c4a9f430a8792bdd0cb3b70a8fa765fae79fe7f6bf9c9d6741
|
|
| MD5 |
c547e18ffac748a517140229238e9154
|
|
| BLAKE2b-256 |
01d8b5ed924445df691ed5504cd790fa598020fe00fe07005d9fd33d9c38782a
|
File details
Details for the file codeannex-0.1.1-py3-none-any.whl.
File metadata
- Download URL: codeannex-0.1.1-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3ecf82e03064aae95e3d6b94b3a669720a1e0844a8c90e9a93b6d65aa1f1803
|
|
| MD5 |
4657baea7ba926c5c8e282f77cb34da4
|
|
| BLAKE2b-256 |
099ee3d7b8602c7532203e9e5f0a505b0709cff538f50edfa34d49fe962366ce
|