Skip to content

Commit 7e5b599

Browse files
authored
Enable PDF and EPUB build (#272)
1 parent 2572853 commit 7e5b599

File tree

2 files changed

+48
-20
lines changed

2 files changed

+48
-20
lines changed

.github/workflows/check.yml

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,16 @@ env:
4141

4242
jobs:
4343

44-
# Build documentation handling warnings as errors.
45-
# If success, upload built docs. If failure, notify telegram and upload logs.
44+
# Build documentation handling warnings as errors in both HTML and PDF.
45+
# If success, upload built docs as artifact.
46+
# If failure in HTML, notify telegram and upload logs.
4647
build:
47-
name: Build translated docs
48+
name: Build docs
4849
runs-on: ubuntu-latest
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
format: [ html, latex, epub ]
4954
steps:
5055
- uses: actions/checkout@v5
5156
with:
@@ -70,20 +75,13 @@ jobs:
7075

7176
- name: Build docs
7277
id: build
73-
run: ./scripts/build.sh
74-
75-
- name: Upload artifact - docs
76-
if: steps.build.outcome == 'success'
77-
uses: actions/upload-artifact@v4.3.5
78-
with:
79-
name: docs
80-
path: cpython/Doc/build/html
78+
run: ./scripts/build.sh ${{ matrix.format }}
8179

8280
- name: Prepare notification (only on error)
83-
if: always() && steps.build.outcome == 'failure'
81+
if: always() && steps.build.outcome == 'failure' && matrix.format == 'html'
8482
id: prepare
8583
run: |
86-
scripts/prepmsg.sh logs/sphinxwarnings.txt logs/notify.txt
84+
scripts/prepmsg.sh logs/sphinxwarnings-${format}.txt logs/notify.txt
8785
cat logs/notify.txt
8886
env:
8987
GITHUB_JOB: ${{ github.job }}
@@ -101,11 +99,34 @@ jobs:
10199

102100
- name: Upload artifact - log files
103101
if: always() && steps.build.outcome == 'failure'
104-
uses: actions/upload-artifact@v4
102+
uses: actions/upload-artifact@v4.3.5
105103
with:
106-
name: ${{ inputs.version }}-build-logs
104+
name: logs-${{ inputs.version }}-${{ matrix.format }}
107105
path: logs/*
106+
107+
- name: Upload artifact - docs
108+
if: always() && steps.build.outcome == 'success'
109+
uses: actions/upload-artifact@v4.3.5
110+
with:
111+
name: python-docs-pt-br-${{ inputs.version }}-${{ matrix.format }}
112+
path: cpython/Doc/build/${{ matrix.format }}
108113

114+
# Build Python docs in PDF format and make available for download.
115+
output-pdf:
116+
name: Build docs (pdf)
117+
runs-on: ubuntu-latest
118+
needs: [ 'build' ]
119+
steps:
120+
- uses: actions/download-artifact@v5
121+
with:
122+
name: python-docs-pt-br-${{ inputs.version }}-latex
123+
- run: sudo apt-get update
124+
- run: sudo apt-get install -y latexmk texlive-xetex fonts-freefont-otf xindy texlive-lang-portuguese
125+
- run: make
126+
- uses: actions/upload-artifact@v4
127+
with:
128+
name: python-docs-pt-br-${{ inputs.version }}-pdf
129+
path: ./*.pdf
109130

110131
# Run sphinx-lint to find wrong reST syntax in PO files. Always store logs.
111132
# If issues are found, notify telegram and upload logs.

scripts/build.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
#!/bin/sh
2-
# Build translated docs to pop up errors
2+
# Build translated docs
3+
# Expects input like 'html' and 'latex', defaults to 'html'.
34
#
45
# SPDX-License-Identifier: CC0-1.0
56

67
set -xeu
78

9+
if [ -z "$1" ]; then
10+
format=html
11+
else
12+
format="$1"
13+
fi
14+
815
# Fail earlier if required variables are not set
916
test -n ${PYDOC_LANGUAGE+x}
1017

@@ -14,15 +21,15 @@ mkdir -p logs
1421
# If version is 3.12 or older, set gettext_compact.
1522
# This confval is not needed since 3.12.
1623
# In 3.13, its presence messes 3.13's syntax checking (?)
17-
opts="-D language=${PYDOC_LANGUAGE} --keep-going -w ../../logs/sphinxwarnings.txt"
24+
opts="-D language=${PYDOC_LANGUAGE} --keep-going -w ../../logs/sphinxwarnings-${format}.txt"
1825
minor_version=$(git -C cpython/Doc branch --show-current | sed 's|^3\.||')
1926
if [ $minor_version -lt 12 ]; then
2027
opts="$opts -D gettext_compact=False"
2128
fi
2229

23-
make -C cpython/Doc html SPHINXOPTS="${opts}"
30+
make -C cpython/Doc "${format}" SPHINXOPTS="${opts}"
2431

2532
# Remove empty file
26-
if [ ! -s logs/sphinxwarnings.txt ]; then
27-
rm logs/sphinxwarnings.txt
33+
if [ ! -s "logs/sphinxwarnings-${format}.txt" ]; then
34+
rm "logs/sphinxwarnings-${format}.txt"
2835
fi

0 commit comments

Comments
 (0)