Compare commits
2 commits
12ba097128
...
03b8c509c3
| Author | SHA1 | Date | |
|---|---|---|---|
| 03b8c509c3 | |||
| bc186be0f9 |
3 changed files with 74 additions and 3 deletions
54
CLAUDE.md
Normal file
54
CLAUDE.md
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
# CLAUDE.md
|
||||||
|
|
||||||
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||||
|
|
||||||
|
## Project Overview
|
||||||
|
|
||||||
|
CV Generator - A Python tool that generates polished PDF CVs from Markdown files with YAML frontmatter. Reads structured CV data and cover letter content, renders them into professionally styled PDFs using Jinja2 templates and WeasyPrint.
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run the application
|
||||||
|
uv run cv path/to/your_cv.md # Generate CV to default output
|
||||||
|
uv run cv path/to/your_cv.md -o out.pdf # Specify custom output path
|
||||||
|
|
||||||
|
# Development environment (with Nix)
|
||||||
|
nix develop # Enter dev shell with all dependencies
|
||||||
|
|
||||||
|
# Code quality (run in nix develop shell or via pre-commit)
|
||||||
|
basedpyright # Type checking
|
||||||
|
ruff check # Linting
|
||||||
|
ruff format # Code formatting
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
pytest # Run test suite
|
||||||
|
```
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
**Data Flow:**
|
||||||
|
1. **Input:** Markdown file with YAML frontmatter + optional image/signature assets
|
||||||
|
2. **Parsing:** `main.py` uses Typer CLI, calls `generator.py` which parses with `python-frontmatter`
|
||||||
|
3. **Validation:** YAML frontmatter validated via Pydantic models in `models.py`
|
||||||
|
4. **Rendering:** Jinja2 template (`cv.html.j2`) populated with data, styled by `cv.css`
|
||||||
|
5. **Output:** WeasyPrint converts HTML+CSS to PDF
|
||||||
|
|
||||||
|
**Key Files:**
|
||||||
|
- `main.py` - CLI entry point (Typer)
|
||||||
|
- `src/cv_generator/generator.py` - Core PDF generation logic
|
||||||
|
- `src/cv_generator/models.py` - Pydantic data models (CVData, ContactInfo, Experience, etc.)
|
||||||
|
- `src/cv_generator/cv.html.j2` - Jinja2 HTML template (two-column layout)
|
||||||
|
- `src/cv_generator/cv.css` - WeasyPrint-compatible CSS styling
|
||||||
|
- `example/alberteinstein.md` - Reference example showing complete YAML structure
|
||||||
|
|
||||||
|
**Template Structure:**
|
||||||
|
- Two-column layout: sidebar (photo, contact, skills) + main content (cover letter, experience)
|
||||||
|
- Separate `@page` rules for letter vs CV pages
|
||||||
|
- Uses Fira Sans Condensed fonts and Bootstrap Icons
|
||||||
|
|
||||||
|
## Tech Stack
|
||||||
|
|
||||||
|
- Python 3.13, Typer (CLI), Pydantic (validation), Jinja2 (templates), WeasyPrint (PDF)
|
||||||
|
- Build: Nix Flakes with uv2nix, uv package manager
|
||||||
|
- Quality: BasedPyright, Ruff, Commitizen (commit messages)
|
||||||
9
main.py
9
main.py
|
|
@ -15,7 +15,16 @@ def generate(
|
||||||
),
|
),
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Generate a PDF CV from a Markdown file with YAML frontmatter."""
|
"""Generate a PDF CV from a Markdown file with YAML frontmatter."""
|
||||||
|
if not input_file.exists():
|
||||||
|
typer.echo(f"Error: Markdown file not found: {input_file}", err=True)
|
||||||
|
raise typer.Exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
result = generate_pdf(input_file, output_file)
|
result = generate_pdf(input_file, output_file)
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
typer.echo(f"Error: {e}", err=True)
|
||||||
|
raise typer.Exit(1)
|
||||||
|
|
||||||
typer.echo(f"Generated {result}")
|
typer.echo(f"Generated {result}")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,16 @@ def generate_pdf(input_file: Path, output_file: Path | None = None) -> Path:
|
||||||
letter_body: str = markdown.markdown(post.content)
|
letter_body: str = markdown.markdown(post.content)
|
||||||
|
|
||||||
input_dir = Path(input_file).resolve().parent
|
input_dir = Path(input_file).resolve().parent
|
||||||
cv.photo = str(input_dir / cv.photo)
|
photo_path = input_dir / cv.photo
|
||||||
cv.signature = str(input_dir / cv.signature)
|
signature_path = input_dir / cv.signature
|
||||||
|
|
||||||
|
if not photo_path.exists():
|
||||||
|
raise FileNotFoundError(f"Photo not found: {photo_path}")
|
||||||
|
if not signature_path.exists():
|
||||||
|
raise FileNotFoundError(f"Signature not found: {signature_path}")
|
||||||
|
|
||||||
|
cv.photo = str(photo_path)
|
||||||
|
cv.signature = str(signature_path)
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader(str(SRC_DIR)))
|
env = Environment(loader=FileSystemLoader(str(SRC_DIR)))
|
||||||
template = env.get_template("cv.html.j2")
|
template = env.get_template("cv.html.j2")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue