mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 12:59:02 +02:00
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>
This commit is contained in:
parent
33ea53f00d
commit
bca3caeaea
2
documentation/.gitignore
vendored
2
documentation/.gitignore
vendored
|
@ -1,3 +1,5 @@
|
|||
_build/
|
||||
Pipfile.lock
|
||||
.vscode/
|
||||
*/svg/*.png
|
||||
*/svg/*.pdf
|
||||
|
|
|
@ -6,8 +6,11 @@
|
|||
SPHINXOPTS ?= -W --keep-going -j auto
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
SOURCEDIR = .
|
||||
IMAGEDIRS = */svg
|
||||
BUILDDIR = _build
|
||||
DESTDIR = final
|
||||
SVG2PNG = inkscape
|
||||
SVG2PDF = inkscape
|
||||
|
||||
ifeq ($(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi),0)
|
||||
$(error "The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed")
|
||||
|
@ -17,7 +20,7 @@ endif
|
|||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile clean publish
|
||||
.PHONY: help Makefile clean publish epub latexpdf
|
||||
|
||||
publish: Makefile html singlehtml
|
||||
rm -rf $(BUILDDIR)/$(DESTDIR)/
|
||||
|
@ -26,10 +29,30 @@ publish: Makefile html singlehtml
|
|||
cp $(BUILDDIR)/singlehtml/index.html $(BUILDDIR)/$(DESTDIR)/singleindex.html
|
||||
sed -i -e 's@index.html#@singleindex.html#@g' $(BUILDDIR)/$(DESTDIR)/singleindex.html
|
||||
|
||||
# Build a list of SVG files to convert to PDFs
|
||||
PDFs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.pdf,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))
|
||||
|
||||
# Build a list of SVG files to convert to PNGs
|
||||
PNGs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.png,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))
|
||||
|
||||
# Pattern rule for converting SVG to PDF
|
||||
%.pdf : %.svg
|
||||
$(SVG2PDF) --export-filename=$@ $<
|
||||
|
||||
# Pattern rule for converting SVG to PNG
|
||||
%.png : %.svg
|
||||
$(SVG2PNG) --export-filename=$@ $<
|
||||
|
||||
clean:
|
||||
@rm -rf $(BUILDDIR)
|
||||
@rm -rf $(BUILDDIR) $(PNGs) $(PDFs)
|
||||
|
||||
epub: $(PNGs)
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
latexpdf: $(PDFs)
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
%:
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
|
|
@ -113,6 +113,10 @@ To install all required packages run:
|
|||
|
||||
$ pip3 install sphinx sphinx_rtd_theme pyyaml
|
||||
|
||||
Also install the "inkscape" package from your distribution.
|
||||
Inkscape is need to convert SVG graphics to PNG (for EPUB
|
||||
export) and to PDF (for PDF export).
|
||||
|
||||
To build the documentation locally, run:
|
||||
|
||||
$ cd documentation
|
||||
|
|
Loading…
Reference in New Issue
Block a user