Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,16 @@ jobs:
echo "VIRTUAL_ENV=$PWD/.venv" >> $GITHUB_ENV
echo "$PWD/.venv/bin" >> $GITHUB_PATH
uv sync --dev
- name: Run tests with pytest
run: pytest
- name: Run tests with pytest and collect coverage
run:
pytest --cov=pdfbaker --cov-report=xml --junitxml=junit.xml -o
junit_family=legacy
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
5 changes: 2 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ repos:
rev: v3.3.4
hooks:
- id: pylint
args:
- --rcfile=.pylintrc
additional_dependencies:
- "cairosvg"
- "click"
- "jinja2"
- "pydantic"
- "pypdf"
- "pytest"
- "pyyaml"
- "ruamel.yaml"
12 changes: 0 additions & 12 deletions .pylintrc

This file was deleted.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# pdfbaker

[![PyPI version](https://img.shields.io/pypi/v/pdfbaker?color=blue)](https://pypi.org/project/pdfbaker/)
[![Python](https://img.shields.io/python/required-version-toml?color=blue&tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fpythonnz%2Fpdfbaker%2Fmain%2Fpyproject.toml)](https://github.com/pythonnz/pdfbaker/blob/main/pyproject.toml)
[![Downloads](https://img.shields.io/pypi/dw/pdfbaker?color=blue)](https://pypistats.org/packages/pdfbaker)
[![tests](https://github.com/pythonnz/pdfbaker/actions/workflows/tests.yaml/badge.svg)](https://github.com/pythonnz/pdfbaker/actions/workflows/tests.yaml)
[![codecov](https://img.shields.io/codecov/c/github/pythonnz/pdfbaker)](https://codecov.io/gh/pythonnz/pdfbaker)
[![Last commit](https://img.shields.io/github/last-commit/pythonnz/pdfbaker?color=lightgrey)](https://github.com/pythonnz/pdfbaker/commits/main)
[![License](https://img.shields.io/github/license/pythonnz/pdfbaker?color=lightgrey)](https://github.com/pythonnz/pdfbaker/blob/main/LICENSE)

Create PDF documents from YAML-configured SVG templates.

## Quickstart
Expand Down
2 changes: 0 additions & 2 deletions examples/custom_locations/other_pages/custom_page.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
title: "Custom Location Example"
description: "This page uses custom directory structure"
template:
# If you just wrote this directly it would be relative to the templates directory
# We want it to be relative to the config file, so use path:
path: "../other_templates/custom_page.svg.j2"
detailed_description:
"This example demonstrates custom file locations in pdfbaker. The template file is in
Expand Down
6 changes: 3 additions & 3 deletions examples/custom_processing/bake.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import urllib.request
from datetime import datetime

from pdfbaker.document import PDFBakerDocument
from pdfbaker.document import Document
from pdfbaker.errors import PDFBakerError
from pdfbaker.processing import wordwrap


def process_document(document: PDFBakerDocument) -> None:
def process_document(document: Document) -> None:
"""Process document with live XKCD comic."""
try:
# Fetch latest XKCD
Expand All @@ -29,7 +29,7 @@ def process_document(document: PDFBakerDocument) -> None:
wrapped_alt_text = wordwrap(data["alt"], max_chars=60)

# Update config/template context with XKCD info
document.config["xkcd"] = {
document.config.xkcd = {
"title": data["title"],
"alt_text": data["alt"],
"alt_text_lines": wrapped_alt_text,
Expand Down
8 changes: 7 additions & 1 deletion examples/examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@ documents:
- minimal
- regular
- variants
- ./custom_locations/your_directory
- path: ./custom_locations/your_directory
name: custom_locations
- custom_processing

custom_stuff:
- year: 2025
- nested:
- anything: really
24 changes: 12 additions & 12 deletions examples/variants/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ variants:
- name: Basic
style:
color: "#3498db"
features:
- "Single page layout"
- "Basic styling"
features:
- "Single page layout"
- "Basic styling"
- name: Premium
style:
color: "#2ecc71"
features:
- "Single page layout"
- "Premium styling"
- "Custom colors"
features:
- "Single page layout"
- "Premium styling"
- "Custom colors"
- name: Enterprise
style:
color: "#e74c3c"
features:
- "Single page layout"
- "Enterprise styling"
- "Custom colors"
- "Priority support"
features:
- "Single page layout"
- "Enterprise styling"
- "Custom colors"
- "Priority support"
2 changes: 1 addition & 1 deletion examples/variants/templates/main.svg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<!-- Features -->
<text x="20" y="90" font-family="Arial" font-size="10" font-weight="bold" fill="#333">Features:</text>
{% for feature in variant.style.features %}
{% for feature in variant.features %}
<text x="30" y="{{ 110 + loop.index0 * 16 }}" font-family="Arial" font-size="9" fill="#333">• {{ feature }}</text>
{% endfor %}
</svg>
17 changes: 16 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ dependencies = [
"cairosvg",
"click",
"jinja2",
"pydantic",
"pypdf",
"pyyaml",
"ruamel.yaml",
]
readme = "README.md"
requires-python = ">= 3.11"
Expand Down Expand Up @@ -42,3 +43,17 @@ addopts = "-v --cov=pdfbaker --cov-report=term-missing"

[tool.coverage.run]
source = ["pdfbaker"]

[tool.pylint.main]
py-version = "3.11"
ignore-paths = ["tests/"]
init-hook = "import sys; sys.path.insert(0, 'src')"

[tool.pylint.messages_control]
disable = ["W0511"] # Disable TODO/FIXME warnings

[tool.pylint.reports]
msg-template = "{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}"
output-format = "colorized"
reports = "no"
score = "no"
10 changes: 5 additions & 5 deletions src/pdfbaker/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import click

from pdfbaker import __version__
from pdfbaker.baker import PDFBaker, PDFBakerOptions
from pdfbaker.baker import Baker, BakerOptions
from pdfbaker.errors import DocumentNotFoundError, PDFBakerError

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -54,20 +54,20 @@
keep_build = True

try:
options = PDFBakerOptions(
options = BakerOptions(
quiet=quiet,
verbose=verbose,
trace=trace,
keep_build=keep_build,
)
baker = PDFBaker(config_file, options=options)
baker = Baker(config_file, options=options)
success = baker.bake(document_names=documents if documents else None)
sys.exit(0 if success else 1)
except DocumentNotFoundError as exc:
logger.error(str(exc))
logger.error("❌ %s", str(exc))

Check warning on line 67 in src/pdfbaker/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/pdfbaker/__main__.py#L67

Added line #L67 was not covered by tests
sys.exit(2)
except PDFBakerError as exc:
logger.error(str(exc))
logger.error("❌ %s", str(exc))

Check warning on line 70 in src/pdfbaker/__main__.py

View check run for this annotation

Codecov / codecov/patch

src/pdfbaker/__main__.py#L70

Added line #L70 was not covered by tests
sys.exit(1)


Expand Down
Loading