Skip to content

Commit 681f250

Browse files
committed
Merge branch 'release/0.5.0'
2 parents 458d15f + 65c7e58 commit 681f250

29 files changed

+690
-117
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ updates:
66
# Enable version updates for Python
77
- package-ecosystem: "pip"
88
target-branch: "develop"
9-
# Look for a `Pipfile` in the `root` directory
109
directory: "/"
1110
# Check for updates once a week
1211
schedule:

.github/workflows/ci.yml

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
uses: actions/checkout@v4
2727
-
2828
name: Set up Python 3.10
29-
uses: actions/setup-python@v4
29+
uses: actions/setup-python@v5
3030
with:
3131
python-version: '3.10'
3232
cache: 'pip'
@@ -72,7 +72,7 @@ jobs:
7272
sudo apt-get install --yes --no-install-recommends poppler-utils
7373
-
7474
name: Set up Python ${{ matrix.python-version }}
75-
uses: actions/setup-python@v4
75+
uses: actions/setup-python@v5
7676
with:
7777
python-version: ${{ matrix.python-version }}
7878
cache: 'pip'
@@ -122,7 +122,7 @@ jobs:
122122
sudo apt-get install --yes --no-install-recommends poppler-utils
123123
-
124124
name: Set up Python 3.11
125-
uses: actions/setup-python@v4
125+
uses: actions/setup-python@v5
126126
with:
127127
python-version: "3.11"
128128
cache: 'pip'
@@ -153,7 +153,7 @@ jobs:
153153
uses: actions/checkout@v4
154154
-
155155
name: Set up Python 3.10
156-
uses: actions/setup-python@v4
156+
uses: actions/setup-python@v5
157157
with:
158158
python-version: '3.10'
159159
cache: 'pip'
@@ -166,13 +166,54 @@ jobs:
166166
run: |
167167
hatch build --clean
168168
-
169-
uses: actions/upload-artifact@v3
169+
uses: actions/upload-artifact@v4
170170
with:
171171
name: artifacts
172172
path: dist/*
173173
if-no-files-found: error
174174
retention-days: 7
175-
175+
documentation:
176+
name: Documentation
177+
runs-on: ubuntu-latest
178+
permissions:
179+
contents: write
180+
needs:
181+
- lint
182+
steps:
183+
-
184+
uses: actions/checkout@v4
185+
-
186+
name: Set up Python 3.10
187+
uses: actions/setup-python@v5
188+
with:
189+
python-version: '3.10'
190+
cache: 'pip'
191+
-
192+
name: Install Hatch
193+
run: |
194+
pip3 --quiet install --upgrade hatch
195+
-
196+
name: Build Documentation
197+
run: |
198+
hatch run docs:build
199+
-
200+
uses: actions/upload-artifact@v4
201+
with:
202+
name: documentation
203+
path: site/*
204+
if-no-files-found: error
205+
retention-days: 7
206+
-
207+
name: Configure Git user
208+
if: startsWith(github.ref, 'refs/tags/')
209+
run: |
210+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
211+
git config --local user.name "github-actions[bot]"
212+
-
213+
name: Deploy documentation
214+
if: startsWith(github.ref, 'refs/tags/')
215+
run: |
216+
hatch run docs:deploy ${{ github.ref_name }}
176217
create-release:
177218
name: Release
178219
runs-on: ubuntu-latest
@@ -182,11 +223,12 @@ jobs:
182223
needs:
183224
- build
184225
- test
226+
- documentation
185227
steps:
186228
-
187229
uses: actions/checkout@v4
188230
-
189-
uses: actions/download-artifact@v3
231+
uses: actions/download-artifact@v4
190232
with:
191233
name: artifacts
192234
path: dist
@@ -218,9 +260,10 @@ jobs:
218260
needs:
219261
- build
220262
- test
263+
- documentation
221264
steps:
222265
-
223-
uses: actions/download-artifact@v3
266+
uses: actions/download-artifact@v4
224267
with:
225268
name: artifacts
226269
path: dist

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656

5757
# Initializes the CodeQL tools for scanning.
5858
- name: Initialize CodeQL
59-
uses: github/codeql-action/init@v2
59+
uses: github/codeql-action/init@v3
6060
with:
6161
languages: ${{ matrix.language }}
6262
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -70,7 +70,7 @@ jobs:
7070
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
7171
# If this step fails, then you should remove it and run the build manually (see below)
7272
- name: Autobuild
73-
uses: github/codeql-action/autobuild@v2
73+
uses: github/codeql-action/autobuild@v3
7474

7575
# ℹ️ Command-line programs to run using the OS shell.
7676
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -83,6 +83,6 @@ jobs:
8383
# ./location_of_script_within_repo/buildscript.sh
8484

8585
- name: Perform CodeQL Analysis
86-
uses: github/codeql-action/analyze@v2
86+
uses: github/codeql-action/analyze@v3
8787
with:
8888
category: "/language:${{matrix.language}}"

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ venv/
2828

2929
# Possible PDF generated from testing
3030
tests/outputs/**
31+
32+
# Documentation site
33+
site/
34+
.cache/

.pre-commit-config.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ repos:
1111
- id: check-json
1212
exclude: "tsconfig.*json"
1313
- id: check-yaml
14+
args:
15+
- "--unsafe"
1416
- id: check-toml
1517
- id: check-executables-have-shebangs
1618
- id: end-of-file-fixer
@@ -37,10 +39,10 @@ repos:
3739
exclude: "(^Pipfile\\.lock$)"
3840
# Python hooks
3941
- repo: https://github.com/astral-sh/ruff-pre-commit
40-
rev: 'v0.1.6'
42+
rev: 'v0.1.11'
4143
hooks:
4244
- id: ruff
43-
- repo: https://github.com/psf/black
44-
rev: 23.11.0
45+
- repo: https://github.com/psf/black-pre-commit-mirror
46+
rev: 23.12.1
4547
hooks:
4648
- id: black

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.5.0] - 2024-01-11
9+
10+
### Added
11+
12+
- Documentation site built with Github Pages and Material for MkDocs
13+
- New method `.run_with_retry` for routes, which allows the route to be rerun as configured, with progressive backoff if the server returns a server error
14+
- Support for Gotenberg [Webhooks](https://gotenberg.dev/docs/webhook)
15+
16+
### Deprecated
17+
18+
- Support for Gotenberg 7.x. This will likely be the last release to support 7.x, as the options for PDF/A have been changed
19+
820
## [0.4.1] - 2023-12-11
921

1022
### Fixed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ from gotenberg_client import GotenbergClient
9595
from gotenberg_client.options import PageOrientation
9696

9797
with GotenbergClient("http://localhost:3000") as client:
98-
with client.chromium.html_to_pdf() as route:
98+
with client.chromium.url_to_pdf() as route:
9999
response = route.url("https://hello.world").orient(PageOrientation.Landscape).run()
100100
Path("my-world.pdf").write_bytes(response.content)
101101
```

docs/.override/main.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% extends "base.html" %}
2+
3+
{% block outdated %}
4+
You're not viewing the latest version.
5+
<a href="{{ '../' ~ base_url }}">
6+
<strong>Click here to go to latest.</strong>
7+
</a>
8+
{% endblock %}

docs/changelog.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
12+
- Documentation site built with Github Pages and Material for MkDocs
13+
14+
## [0.4.1] - 2023-12-11
15+
16+
### Fixed
17+
18+
- Implemented an internal workaround for older Gotenberg versions and their handling of non-latin filenames.
19+
- When detected, the files will be copied into a temporary directory and the filename cleaned
20+
- Gotenberg 8.0.0 will start implementing something similar once released
21+
- The pulled Gotenberg image is now inspected, allowing local re-creation of failures against specific digests
22+
- The `:edge` tag testing is now allowed to fail
23+
24+
## [0.4.0] - 2023-12-04
25+
26+
### Changed
27+
28+
- Removed some certain special cases from coverage
29+
- Updated `pre-commit` hook versions
30+
- Updated how pytest is configured, so it will apply to any invocation
31+
- Updated test running image to log at warning or lower using text format
32+
- Updated test running image from 7.9.2 to 7.10.1
33+
- For the moment, send both `pdfa` and `pdfFormat` for compatibility with 7.9 and 7.10
34+
- See [here](https://github.com/stumpylog/gotenberg-client/issues/5#issuecomment-1839081129) for some subtle differences in what these options mean
35+
36+
### Added
37+
38+
- Added new test job against Gotenberg's `:edge` tag
39+
40+
## [0.3.0] - 2023-10-17
41+
42+
### Added
43+
44+
- Support for the output filename and request tracing for all routes
45+
46+
### Removed
47+
48+
- References to compression and Brotli. Gotenberg doesn't seem to ever compress response data
49+
50+
### Fixed
51+
52+
- An issue with the sorting of merging PDFs. Expanded testing to cover the merged ordering
53+
54+
### Changed
55+
56+
- Multiple merge calls on the same route will maintain the ordering of all files, rather than just per merge call
57+
58+
## [0.2.0] - 2023-10-16
59+
60+
### Added
61+
62+
- CodeQL scanning via GitHub
63+
- Codecov.io coverage shield
64+
65+
### Changed
66+
67+
- Updated pypa/gh-action-pypi-publish from 1.8.8 to 1.8.10
68+
- Updated actions/checkout from 3 to 4
69+
- Mis-spelled `gotenerg_url` for a `Client` is now `host` and no longer keyword only
70+
71+
## [0.1.0] - 2023-10-15
72+
73+
### Added
74+
75+
- Chromium conversion routes
76+
- LibreOffice conversion routes
77+
- PDF/A conversion route
78+
- PDF merge route
79+
- Health status route
80+
- Testing and typing all setup and passing

docs/index.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Gotenberg Python Client
2+
3+
This is a Python client for interfacing with [Gotenberg](https://gotenberg.dev/), which in turn is a wrapper around
4+
powerful tools for PDF generation and creation in various ways, using a stateless API. It's a very powerful tool
5+
to generate and manipulate PDFs.
6+
7+
## Features
8+
9+
- HTTP/2 enabled by default
10+
- Abstract away the handling of multi-part/form-data and deal with `Path`s instead
11+
- Based on the modern [httpx](https://github.com/encode/httpx) library
12+
- Full support for type hinting and concrete return types as much as possible
13+
- Nearly full test coverage run against an actual Gotenberg server for multiple Python and PyPy versions
14+
15+
## Examples
16+
17+
Converting a single HTML file into a PDF:
18+
19+
```python
20+
from gotenberg_client import GotenbergClient
21+
22+
with GotenbergClient("http://localhost:3000") as client:
23+
with client.chromium.html_to_pdf() as route:
24+
response = route.index("my-index.html").run()
25+
Path("my-index.pdf").write_bytes(response.content)
26+
```
27+
28+
Converting an HTML file with additional resources into a PDF:
29+
30+
```python
31+
from gotenberg_client import GotenbergClient
32+
33+
with GotenbergClient("http://localhost:3000") as client:
34+
with client.chromium.html_to_pdf() as route:
35+
response = route.index("my-index.html").resource("image.png").resource("style.css").run()
36+
Path("my-index.pdf").write_bytes(response.content)
37+
```
38+
39+
Converting an HTML file with additional resources into a PDF/A1a format:
40+
41+
```python
42+
from gotenberg_client import GotenbergClient
43+
from gotenberg_client.options import PdfAFormat
44+
45+
with GotenbergClient("http://localhost:3000") as client:
46+
with client.chromium.html_to_pdf() as route:
47+
response = route.index("my-index.html").resources(["image.png", "style.css"]).pdf_format(PdfAFormat.A1a).run()
48+
Path("my-index.pdf").write_bytes(response.content)
49+
```
50+
51+
Converting a URL into PDF, in landscape format
52+
53+
```python
54+
from gotenberg_client import GotenbergClient
55+
from gotenberg_client.options import PageOrientation
56+
57+
with GotenbergClient("http://localhost:3000") as client:
58+
with client.chromium.html_to_pdf() as route:
59+
response = route.url("https://hello.world").orient(PageOrientation.Landscape).run()
60+
Path("my-world.pdf").write_bytes(response.content)
61+
```
62+
63+
To ensure the proper clean up of all used resources, both the client and the route(s) should be
64+
used as context manager. If for some reason you cannot, you should `.close` the client and any
65+
routes:
66+
67+
```python
68+
from gotenberg_client import GotenbergClient
69+
70+
try:
71+
client = GotenbergClient("http://localhost:3000")
72+
try:
73+
route = client.merge(["myfile.pdf", "otherfile.pdf"]).run()
74+
finally:
75+
route.close()
76+
finally:
77+
client.close()
78+
```

0 commit comments

Comments
 (0)