diff options
author | Michael Opdenacker <michael.opdenacker@bootlin.com> | 2021-10-06 14:17:46 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-08 22:01:24 +0100 |
commit | bca3caeaeafc3c9c412ef33b1a9a3ef99b04baf1 (patch) | |
tree | feda1c56929d305c3ecc58c52a3c15c5caf6b5a5 /documentation | |
parent | 33ea53f00db5760650596af24d6c5bea262ed0f6 (diff) | |
download | poky-bca3caeaeafc3c9c412ef33b1a9a3ef99b04baf1.tar.gz |
Makefile: allow epub and latexpdf outputs to use diagrams from SVG sources
html output is great when directly using SVG
epub output has to use exported PNG because of issues using SVG directly
latexpdf output cannot use SVG, it needs exported PDF instead
This adds rules to generate PNG and PDF formats from new SVG sources.
Newly added diagrams have be stored in svg/ subdirectories
so that PNG and PDF files generated from SVG can be "gitignored"
without ignoring the original PNG diagrams that have no SVG source.
Note: had to remove the dependency to "Makefile" in the final "catch-all" target,
otherwise it was also catching the SVG to PNG and SVG to PDF targets.
(From yocto-docs rev: cd9bbd41d323bc124057396f142010509c65bbaf)
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
Reviewed-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
Signed-off-by: Quentin Schulz <foss@0leil.net>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'documentation')
-rw-r--r-- | documentation/.gitignore | 2 | ||||
-rw-r--r-- | documentation/Makefile | 29 | ||||
-rw-r--r-- | documentation/README | 4 |
3 files changed, 32 insertions, 3 deletions
diff --git a/documentation/.gitignore b/documentation/.gitignore index c44580b088..35ead8af66 100644 --- a/documentation/.gitignore +++ b/documentation/.gitignore | |||
@@ -1,3 +1,5 @@ | |||
1 | _build/ | 1 | _build/ |
2 | Pipfile.lock | 2 | Pipfile.lock |
3 | .vscode/ | 3 | .vscode/ |
4 | */svg/*.png | ||
5 | */svg/*.pdf | ||
diff --git a/documentation/Makefile b/documentation/Makefile index 996f01b7d5..f015026562 100644 --- a/documentation/Makefile +++ b/documentation/Makefile | |||
@@ -6,8 +6,11 @@ | |||
6 | SPHINXOPTS ?= -W --keep-going -j auto | 6 | SPHINXOPTS ?= -W --keep-going -j auto |
7 | SPHINXBUILD ?= sphinx-build | 7 | SPHINXBUILD ?= sphinx-build |
8 | SOURCEDIR = . | 8 | SOURCEDIR = . |
9 | IMAGEDIRS = */svg | ||
9 | BUILDDIR = _build | 10 | BUILDDIR = _build |
10 | DESTDIR = final | 11 | DESTDIR = final |
12 | SVG2PNG = inkscape | ||
13 | SVG2PDF = inkscape | ||
11 | 14 | ||
12 | ifeq ($(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi),0) | 15 | ifeq ($(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi),0) |
13 | $(error "The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed") | 16 | $(error "The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed") |
@@ -17,7 +20,7 @@ endif | |||
17 | help: | 20 | help: |
18 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | 21 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
19 | 22 | ||
20 | .PHONY: help Makefile clean publish | 23 | .PHONY: help Makefile clean publish epub latexpdf |
21 | 24 | ||
22 | publish: Makefile html singlehtml | 25 | publish: Makefile html singlehtml |
23 | rm -rf $(BUILDDIR)/$(DESTDIR)/ | 26 | rm -rf $(BUILDDIR)/$(DESTDIR)/ |
@@ -26,10 +29,30 @@ publish: Makefile html singlehtml | |||
26 | cp $(BUILDDIR)/singlehtml/index.html $(BUILDDIR)/$(DESTDIR)/singleindex.html | 29 | cp $(BUILDDIR)/singlehtml/index.html $(BUILDDIR)/$(DESTDIR)/singleindex.html |
27 | sed -i -e 's@index.html#@singleindex.html#@g' $(BUILDDIR)/$(DESTDIR)/singleindex.html | 30 | sed -i -e 's@index.html#@singleindex.html#@g' $(BUILDDIR)/$(DESTDIR)/singleindex.html |
28 | 31 | ||
32 | # Build a list of SVG files to convert to PDFs | ||
33 | PDFs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.pdf,$(wildcard $(SOURCEDIR)/$(dir)/*.svg))) | ||
34 | |||
35 | # Build a list of SVG files to convert to PNGs | ||
36 | PNGs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.png,$(wildcard $(SOURCEDIR)/$(dir)/*.svg))) | ||
37 | |||
38 | # Pattern rule for converting SVG to PDF | ||
39 | %.pdf : %.svg | ||
40 | $(SVG2PDF) --export-filename=$@ $< | ||
41 | |||
42 | # Pattern rule for converting SVG to PNG | ||
43 | %.png : %.svg | ||
44 | $(SVG2PNG) --export-filename=$@ $< | ||
45 | |||
29 | clean: | 46 | clean: |
30 | @rm -rf $(BUILDDIR) | 47 | @rm -rf $(BUILDDIR) $(PNGs) $(PDFs) |
48 | |||
49 | epub: $(PNGs) | ||
50 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
51 | |||
52 | latexpdf: $(PDFs) | ||
53 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
31 | 54 | ||
32 | # Catch-all target: route all unknown targets to Sphinx using the new | 55 | # Catch-all target: route all unknown targets to Sphinx using the new |
33 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | 56 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). |
34 | %: Makefile | 57 | %: |
35 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | 58 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
diff --git a/documentation/README b/documentation/README index 1e7b4f0e65..2d9eb887b2 100644 --- a/documentation/README +++ b/documentation/README | |||
@@ -113,6 +113,10 @@ To install all required packages run: | |||
113 | 113 | ||
114 | $ pip3 install sphinx sphinx_rtd_theme pyyaml | 114 | $ pip3 install sphinx sphinx_rtd_theme pyyaml |
115 | 115 | ||
116 | Also install the "inkscape" package from your distribution. | ||
117 | Inkscape is need to convert SVG graphics to PNG (for EPUB | ||
118 | export) and to PDF (for PDF export). | ||
119 | |||
116 | To build the documentation locally, run: | 120 | To build the documentation locally, run: |
117 | 121 | ||
118 | $ cd documentation | 122 | $ cd documentation |