Makefile: allow epub and latexpdf outputs to use diagrams from SVG sources
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/4 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.
--- documentation/.gitignore | 2 ++ documentation/Makefile | 29 ++++++++++++++++++++++++++--- documentation/README | 2 ++ 3 files changed, 30 insertions(+), 3 deletions(-)
documentation/.gitignore +2 -0
@@ -1,3 +1,5 @@ _build/ Pipfile.lock .vscode/ +*/svg/*.png +*/svg/*.pdf
documentation/Makefile +26 -3
@@ -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 '[email protected]#@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)
documentation/README +2 -0
@@ -113,6 +113,8 @@ To install all required packages run: $ pip3 install sphinx sphinx_rtd_theme pyyaml +Also install the "inkscape" package from your distribution. + To build the documentation locally, run: $ cd documentation
Signature · 1 line
2.25.1
PATCH 2/4 conf.py: use PNG first in EPUB output
SVG directly included in EPUB output has multiple issues, in particular font size and alignment ones (tested on two EPUB readers). Instead, using PNG, generated from SVG when available as the primary format for images. GIF and JPEG are fine too.
--- documentation/conf.py | 4 ++++ 1 file changed, 4 insertions(+)
documentation/conf.py +4 -0
@@ -139,3 +139,7 @@ latex_elements = { 'passoptionstopackages': '\PassOptionsToPackage{bookmarksdepth=5}{hyperref}', 'preamble': '\setcounter{tocdepth}{2}', } + +# Make the EPUB builder prefer PNG to SVG because of issues rendering Inkscape SVG +from sphinx.builders.epub3 import Epub3Builder +Epub3Builder.supported_image_types = ['image/png', 'image/gif', 'image/jpeg']
Signature · 1 line
2.25.1
PATCH 3/4 overview-manual: SVG diagram for the git workflow
In reply to Michael OpdenackerSet in full-width mode to make it ready in PDF
and EPUB outputs.
--- .../development-environment.rst | 4 +- .../overview-manual/figures/git-workflow.png | Bin 26586 -> 0 bytes .../overview-manual/svg/git-workflow.svg | 1205 +++++++++++++++++ 3 files changed, 1207 insertions(+), 2 deletions(-) delete mode 100644 documentation/overview-manual/figures/git-workflow.png create mode 100644 documentation/overview-manual/svg/git-workflow.svg
documentation/overview-manual/development-environment.rst +2 -2
@@ -286,8 +286,8 @@ develop, test, and submit changes to "contrib" areas for the maintainer to examine. The maintainer then chooses which changes are going to become a permanent part of the project. -.. image:: figures/git-workflow.png - :align: center +.. image:: svg/git-workflow.* + :width: 100% While each development environment is unique, there are some best practices or methods that help development run smoothly. The following
documentation/overview-manual/figures/git-workflow.png deleted binary +0 -0
documentation/overview-manual/svg/git-workflow.svg new file +1205 -0
1,205 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [docs] [PATCH 3/4] overview-manual: SVG diagram for the git workflow
Hi Michael,
Found your patch in my Spam folder :)
Quoted 17 lines · Michael Opdenacker
Set in full-width mode to make it ready in PDF
and EPUB outputs.Signed-off-by Michael Opdenacker <[email protected]>--- .../development-environment.rst | 4 +- .../overview-manual/figures/git-workflow.png | Bin 26586 -> 0 bytes .../overview-manual/svg/git-workflow.svg | 1205 +++++++++++++++++ 3 files changed, 1207 insertions(+), 2 deletions(-) delete mode 100644 documentation/overview-manual/figures/git-workflow.png create mode 100644 documentation/overview-manual/svg/git-workflow.svgdocumentation/overview-manual/development-environment.rst +0
-0
documentation/overview-manual/development-environment.rst develop, test, and submit changes to "contrib" areas for the maintainer · line 289
Quoted 6 lines
documentation/overview-manual/development-environment.rst +1
-2@@ -286,8 +286,8 @@ develop, test, and submit changes to "contrib" areas for the maintainer to examine. The maintainer then chooses which changes are going to become a permanent part of the project. -.. image:: figures/git-workflow.png - :align: center +.. image:: svg/git-workflow.*
I guess this is due to HTML rendering including SVG but epub using a png created by inkscape?
We could add a comment for this maybe?
Does this work well if you do the following:
$ make latexpdf $ make html
for the html to use the svg and not the png created by inkscape?
Otherwise not much to add :)
Thanks,
Quentin
Quentin Schulz
Reviewed-byRe: [docs] [PATCH 3/4] overview-manual: SVG diagram for the git workflow
Hi all,
Quoted 25 lines · Quentin Schulz
Hi Michael,
Found your patch in my Spam folder :)
Quoted 20 lines · Michael Opdenacker
Set in full-width mode to make it ready in PDF
and EPUB outputs.Signed-off-by Michael Opdenacker <[email protected]>--- .../development-environment.rst | 4 +- .../overview-manual/figures/git-workflow.png | Bin 26586 -> 0 bytes .../overview-manual/svg/git-workflow.svg | 1205 +++++++++++++++++ 3 files changed, 1207 insertions(+), 2 deletions(-) delete mode 100644 documentation/overview-manual/figures/git-workflow.png create mode 100644 documentation/overview-manual/svg/git-workflow.svgdocumentation/overview-manual/development-environment.rst +0
-0@@ -286,8 +286,8 @@ develop, test, and submit changes to "contrib" areas for the maintainer to examine. The maintainer then chooses which changes are going to become a permanent part of the project.
Quoted 9 lines
documentation/overview-manual/development-environment.rst develop, test, and submit changes to "contrib" areas for the maintainer · line 289
Quoted 3 lines
documentation/overview-manual/development-environment.rst +1
-2-.. image:: figures/git-workflow.png - :align: center +.. image:: svg/git-workflow.*I guess this is due to HTML rendering including SVG but epub using a png created by inkscape?
We could add a comment for this maybe?
Answering myself:
https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html?highlight=image#images
Depends on the Builder and its supported_image_types setting (first match, from left to right).
For HTML, it is
https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.html.StandaloneHTMLBuilder,
svg first then png, etc..
For pdflatex it is:
https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.latex.LaTeXBuilder,
pdf then png, etc..
And it is overridden for Epub builder in a patch of this series.
Therefore,
Thanks!
Quentin
Re: [docs] [PATCH 3/4] overview-manual: SVG diagram for the git workflow
Quoted 10 lines · Quentin Schulz
Answering myself:
https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html?highlight=image#images
Depends on the Builder and its
supported_image_typessetting (first match, from left to right).For HTML, it is
https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.html.StandaloneHTMLBuilder,
svg first then png, etc..
Good that you found the defaults there. I didn't read that page carefully enough, and I thought it was just an example.
I'm merging this series in master next, after adding the comment about Inkscape that you suggested in the README file.
Thanks for the review!
Michael.
Signature · 3 lines
Michael Opdenacker, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [docs] [PATCH 3/4] overview-manual: SVG diagram for the git workflow
In reply to Quentin SchulzHi Quentin,
Quoted 7 lines · Quentin Schulz
Quoted 5 lines
-.. image:: figures/git-workflow.png
- :align: center
+.. image:: svg/git-workflow.*I guess this is due to HTML rendering including SVG but epub using a png created by inkscape?
Right.
Quoted 2 lines
We could add a comment for this maybe?
Yes, but maybe in a central place that will explain how to add images. This may be too verbose to repeat a comment every time we include an image.
Quoted 9 lines
Does this work well if you do the following:
$ make latexpdf $ make htmlfor the html to use the svg and not the png created by inkscape?
Otherwise not much to add :)
Yes, it works. Actually, the HTML export seems to prefer SVG over PNG by default (from my experiments, and as claimed by
https://newbedev.com/using-sphinx-docs-how-can-i-specify-png-image-formats-for-html-builds-and-pdf-image-formats-for-latex-pdf-builds).
We may change this by tuning |StandaloneHTMLBuilder.supported_image_types in conf.py, but since the default is fine, I'd say that no extra setting is required.|
|Cheers, Michael.|
Signature · 3 lines
Michael Opdenacker, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 4/4 docs: add "make all" to build old types of docs (html, epub, pdf) at once
In reply to Michael Opdenacker--- documentation/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
documentation/Makefile +3 -1
@@ -20,7 +20,7 @@ endif help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -.PHONY: help Makefile clean publish epub latexpdf +.PHONY: all help Makefile clean publish epub latexpdf publish: Makefile html singlehtml rm -rf $(BUILDDIR)/$(DESTDIR)/
@@ -52,6 +52,8 @@ epub: $(PNGs) latexpdf: $(PDFs) @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) +all: html epub latexpdf + # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %:
Signature · 1 line
2.25.1
Quoted 10 lines · Michael Opdenacker
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 insteadThis 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.
Quoted 6 lines
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.Signed-off-by Michael Opdenacker <[email protected]>
For the entire series:
Thanks for turning the initial RFC into this series. We need to get back at producing and releasing PDF files. It might be a bit too late for this release.. perhaps not.. but definitely something to do for 3.5.
Quickly browsing through the PDF I can spot some graphics issues.. Would be interesting to do an in-depth review of the PDF!
Quoted 112 lines
--- documentation/.gitignore | 2 ++ documentation/Makefile | 29 ++++++++++++++++++++++++++--- documentation/README | 2 ++ 3 files changed, 30 insertions(+), 3 deletions(-)documentation/.gitignore +2
-0@@ -1,3 +1,5 @@ _build/ Pipfile.lock .vscode/ +*/svg/*.png +*/svg/*.pdfdocumentation/Makefile +3
-0@@ -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")documentation/Makefile +1
-1@@ -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 singlehtmlrm -rf $(BUILDDIR)/$(DESTDIR)/documentation/Makefile +0
-0@@ -26,10 +29,30 @@ publish: Makefile html singlehtml cp $(BUILDDIR)/singlehtml/index.html$(BUILDDIR)/$(DESTDIR)/singleindex.html
sed -i -e '[email protected]#@singleindex.html#@g'
$(BUILDDIR)/$(DESTDIR)/singleindex.htmldocumentation/Makefile +2
-0+# Build a list of SVG files to convert to PDFs +PDFs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.pdf,$(wildcard$(SOURCEDIR)/$(dir)/*.svg)))
documentation/Makefile +3
-0+ +# Build a list of SVG files to convert to PNGs +PNGs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.png,$(wildcard$(SOURCEDIR)/$(dir)/*.svg)))
documentation/Makefile +13
-1+ +# 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)
documentation/Makefile +3
-0+ +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)
documentation/README +2
-1@@ -113,6 +113,8 @@ To install all required packages run: $ pip3 install sphinx sphinx_rtd_theme pyyaml +Also install the "inkscape" package from your distribution. + To build the documentation locally, run: $ cd documentation --2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#1926):
https://lists.yoctoproject.org/g/docs/message/1926
Mute This Topic: https://lists.yoctoproject.org/mt/86117757/1279857
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/docs/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Hi Nico,
Quoted 4 lines · Nicolas Dechesne
For the entire series:
Reviewed-by Nicolas Dechesne <[email protected]<mailto:[email protected]>>
Thanks for the review!
Quoted 4 lines
Thanks for turning the initial RFC into this series. We need to get back at producing and releasing PDF files. It might be a bit too late for this release.. perhaps not.. but definitely something to do for 3.5.
Maybe not, if the PDF is considered mature enough.
Quoted 3 lines
Quickly browsing through the PDF I can spot some graphics issues.. Would be interesting to do an in-depth review of the PDF!
I'll check and try to find solutions.
Thanks again,
Cheers,
Michael.
Signature · 3 lines
Michael Opdenacker, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Hi Michael,
Your patch series is missing patch 3/4, can you fix that (send the missing one or renumber them :) )?
Quoted 93 lines · Michael Opdenacker
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 insteadThis 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.Signed-off-by Michael Opdenacker <[email protected]>--- documentation/.gitignore | 2 ++ documentation/Makefile | 29 ++++++++++++++++++++++++++--- documentation/README | 2 ++ 3 files changed, 30 insertions(+), 3 deletions(-)documentation/.gitignore +2
-0@@ -1,3 +1,5 @@ _build/ Pipfile.lock .vscode/ +*/svg/*.png +*/svg/*.pdfdocumentation/Makefile +26
-3@@ -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 '[email protected]#@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)documentation/README +0
-0
documentation/README To install all required packages run: · line 117
Quoted 5 lines
documentation/README +2
-0@@ -113,6 +113,8 @@ To install all required packages run: $ pip3 install sphinx sphinx_rtd_theme pyyaml +Also install the "inkscape" package from your distribution. +
This is needed only to build epub or pdf, might want to specify that?
Cheers,
Quentin
Hi Quentin,
Thanks for the review!
Quoted 4 lines · Quentin Schulz
Hi Michael,
Your patch series is missing patch 3/4, can you fix that (send the missing one or renumber them :) )?
Weird, maybe a (very short... between 2/4 and 4/4) issue between the mailing list and your end.
https://lists.yoctoproject.org/g/docs/message/1928
Quoted 6 lines
documentation/README To install all required packages run: · line 117
Quoted 5 lines
$ pip3 install sphinx sphinx_rtd_theme pyyamldocumentation/README +2
-0+Also install the "inkscape" package from your distribution. +This is needed only to build epub or pdf, might want to specify that?
Good idea. I'll add it.
Thanks again
Michael.
Signature · 3 lines
Michael Opdenacker, Bootlin Embedded Linux and Kernel engineering https://bootlin.com