mirror of
https://codeberg.org/openpgp/notes.git
synced 2024-11-23 08:02:05 +01:00
Merge pull request 'Add EPUB customizations and improve CI' (#142) from dvzrv/epub_customizations into draft
Reviewed-on: https://codeberg.org/openpgp/notes/pulls/142
This commit is contained in:
commit
a2c2beb73a
7 changed files with 96 additions and 14 deletions
|
@ -10,3 +10,7 @@ License: CC-BY-SA-4.0
|
||||||
Files: book/source/mermaid/*.png
|
Files: book/source/mermaid/*.png
|
||||||
Copyright: 2023 The "Notes on OpenPGP" project
|
Copyright: 2023 The "Notes on OpenPGP" project
|
||||||
License: CC-BY-SA-4.0
|
License: CC-BY-SA-4.0
|
||||||
|
|
||||||
|
Files: book/patches/*.patch
|
||||||
|
Copyright: 2023 The "Notes on OpenPGP" project
|
||||||
|
License: CC0-1.0
|
||||||
|
|
24
.woodpecker/epub.yml
Normal file
24
.woodpecker/epub.yml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# SPDX-FileCopyrightText: 2023 The "Notes on OpenPGP" project
|
||||||
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
clone:
|
||||||
|
git:
|
||||||
|
image: woodpeckerci/plugin-git
|
||||||
|
settings:
|
||||||
|
lfs: false
|
||||||
|
|
||||||
|
when:
|
||||||
|
branch: draft
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
steps:
|
||||||
|
epub-check:
|
||||||
|
image: archlinux:latest
|
||||||
|
commands:
|
||||||
|
- pacman -Sy --needed --noconfirm archlinux-keyring
|
||||||
|
- pacman -Syu --needed --noconfirm epubcheck make patch python-myst-parser python-sphinx
|
||||||
|
# fix sphinx: https://github.com/sphinx-doc/sphinx/issues/11598
|
||||||
|
- patch -Np1 -d /usr/lib/python3.11/site-packages/ -i "$(pwd)/book/patches/sphinx-11766.patch"
|
||||||
|
- make -C book epub-check
|
13
Dockerfile
13
Dockerfile
|
@ -1,13 +1,16 @@
|
||||||
# SPDX-FileCopyrightText: 2023 The "Notes on OpenPGP" project
|
# SPDX-FileCopyrightText: 2023 The "Notes on OpenPGP" project
|
||||||
# SPDX-License-Identifier: CC0-1.0
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
FROM sphinxdoc/sphinx AS build
|
FROM archlinux:latest AS build
|
||||||
RUN pip install myst-parser
|
|
||||||
COPY book/ /book
|
COPY book/ /book
|
||||||
WORKDIR /book
|
WORKDIR /book
|
||||||
RUN make html
|
# fix EPUB rendering: https://github.com/sphinx-doc/sphinx/issues/11598
|
||||||
RUN make epub
|
RUN \
|
||||||
|
pacman -Sy --needed --noconfirm archlinux-keyring \
|
||||||
|
&& pacman -Syu --needed --noconfirm epubcheck make patch python-myst-parser python-sphinx \
|
||||||
|
&& patch -Np1 -d /usr/lib/python3.11/site-packages/ -i /book/patches/sphinx-11766.patch \
|
||||||
|
&& make epub html
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
COPY --from=build /book/build/html /
|
COPY --from=build /book/build/html /
|
||||||
COPY --from=build /book/build/epub/OpenPGPforapplicationdevelopers.epub /
|
COPY --from=build /book/build/epub/OpenPGPforapplicationdevelopers.epub /
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
# You can set these variables from the command line, and also
|
# You can set these variables from the command line, and also
|
||||||
# from the environment for the first two.
|
# from the environment for the first two.
|
||||||
CODESPELL ?= codespell
|
CODESPELL ?= codespell
|
||||||
|
EPUBCHECK ?= epubcheck
|
||||||
SPHINXOPTS ?= -W
|
SPHINXOPTS ?= -W
|
||||||
SPHINXBUILD ?= sphinx-build
|
SPHINXBUILD ?= sphinx-build
|
||||||
LYCHEE ?= lychee
|
LYCHEE ?= lychee
|
||||||
|
@ -14,6 +15,9 @@ PRINTF ?= printf
|
||||||
SOURCEDIR = source
|
SOURCEDIR = source
|
||||||
BUILDDIR = build
|
BUILDDIR = build
|
||||||
|
|
||||||
|
epub-check: clean epub
|
||||||
|
@$(EPUBCHECK) "$(BUILDDIR)/epub/"*.epub
|
||||||
|
|
||||||
# Put it first so that "make" without argument is like "make help".
|
# Put it first so that "make" without argument is like "make help".
|
||||||
help:
|
help:
|
||||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||||
|
|
26
book/patches/sphinx-11766.patch
Normal file
26
book/patches/sphinx-11766.patch
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py
|
||||||
|
index 85067be0178..91d3647597c 100644
|
||||||
|
--- a/sphinx/builders/html/__init__.py
|
||||||
|
+++ b/sphinx/builders/html/__init__.py
|
||||||
|
@@ -1061,7 +1061,9 @@ def css_tag(css: _CascadingStyleSheet) -> str:
|
||||||
|
attrs.append(f'{key}="{html.escape(value, quote=True)}"')
|
||||||
|
uri = pathto(os.fspath(css.filename), resource=True)
|
||||||
|
if checksum := _file_checksum(outdir, css.filename):
|
||||||
|
- uri += f'?v={checksum}'
|
||||||
|
+ # the EPUB format does not allow the use of query components
|
||||||
|
+ if self.name != 'epub':
|
||||||
|
+ uri += f'?v={checksum}'
|
||||||
|
return f'<link {" ".join(sorted(attrs))} href="{uri}" />'
|
||||||
|
|
||||||
|
ctx['css_tag'] = css_tag
|
||||||
|
@@ -1092,7 +1094,9 @@ def js_tag(js: _JavaScript | str) -> str:
|
||||||
|
# https://github.com/sphinx-doc/sphinx/issues/11658
|
||||||
|
pass
|
||||||
|
elif checksum := _file_checksum(outdir, js.filename):
|
||||||
|
- uri += f'?v={checksum}'
|
||||||
|
+ # the EPUB format does not allow the use of query components
|
||||||
|
+ if self.name != 'epub':
|
||||||
|
+ uri += f'?v={checksum}'
|
||||||
|
if attrs:
|
||||||
|
return f'<script {" ".join(sorted(attrs))} src="{uri}"></script>'
|
||||||
|
return f'<script src="{uri}"></script>'
|
13
book/source/_static/epub/css/custom.css
Normal file
13
book/source/_static/epub/css/custom.css
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
/*
|
||||||
|
SPDX-FileCopyrightText: 2023 The "Notes on OpenPGP" project
|
||||||
|
SPDX-License-Identifier: CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
div.admonition {
|
||||||
|
background-color: lightgray;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.warning,
|
||||||
|
div.admonition-warning {
|
||||||
|
background-color: palevioletred;
|
||||||
|
}
|
|
@ -24,7 +24,24 @@ source_suffix = ['.md', '.rst']
|
||||||
templates_path = ['_templates']
|
templates_path = ['_templates']
|
||||||
exclude_patterns = []
|
exclude_patterns = []
|
||||||
|
|
||||||
|
# number code-blocks, figures and tables, if they have a caption
|
||||||
|
numfig = True
|
||||||
|
# number figures in flat hierarchy
|
||||||
|
numfig_secnum_depth = 0
|
||||||
|
|
||||||
|
# -- Options for MyST-parser -------------------------------------------------
|
||||||
|
# https://myst-parser.readthedocs.io/en/latest/configuration.html
|
||||||
|
|
||||||
|
# we want to circumvent obscure warnings about footnotes following a heading:
|
||||||
|
# https://github.com/executablebooks/MyST-Parser/issues/352
|
||||||
|
myst_footnote_transition = False
|
||||||
|
|
||||||
|
# -- Options for EPUB output -------------------------------------------------
|
||||||
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-epub-output
|
||||||
|
|
||||||
|
epub_css_files = [
|
||||||
|
'epub/css/custom.css'
|
||||||
|
]
|
||||||
|
|
||||||
# -- Options for HTML output -------------------------------------------------
|
# -- Options for HTML output -------------------------------------------------
|
||||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
||||||
|
@ -42,12 +59,3 @@ html_theme_options = {
|
||||||
'show_relbars': 'yes',
|
'show_relbars': 'yes',
|
||||||
'show_powered_by': False,
|
'show_powered_by': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
# we want to circumvent obscure warnings about footnotes following a heading:
|
|
||||||
# https://github.com/executablebooks/MyST-Parser/issues/352
|
|
||||||
myst_footnote_transition = False
|
|
||||||
|
|
||||||
# number code-blocks, figures and tables, if they have a caption
|
|
||||||
numfig = True
|
|
||||||
# number figures in flat hierarchy
|
|
||||||
numfig_secnum_depth = 0
|
|
||||||
|
|
Loading…
Reference in a new issue