[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <92cc6573-4eed-047e-0e9d-4b0e96aa6649@gmail.com>
Date: Mon, 13 Dec 2021 23:36:58 +0900
From: Akira Yokosawa <akiyks@...il.com>
To: Jonathan Corbet <corbet@....net>,
Mauro Carvalho Chehab <mchehab@...nel.org>
Cc: linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
Akira Yokosawa <akiyks@...il.com>
Subject: [PATCH 4/3] docs: sphinx/kfigure.py: Add check of 'dot -Tpdf'
To prevent any regression on existing build systems, limit the
fallback of converting DOT -> raster PDF only when all of the
following conditions are met.
o dot(1) doesn't support -Tpdf
o rsvg-convert(1) is not found
o inkscape(1) is not found
Suggested-by: Mauro Carvalho Chehab <mchehab@...nel.org>
Signed-off-by: Akira Yokosawa <akiyks@...il.com>
Cc: Jonathan Corbet <corbet@....net>
---
Documentation/sphinx/kfigure.py | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/Documentation/sphinx/kfigure.py b/Documentation/sphinx/kfigure.py
index d5802e3975e5..dbe75ee8ae61 100644
--- a/Documentation/sphinx/kfigure.py
+++ b/Documentation/sphinx/kfigure.py
@@ -113,6 +113,8 @@ def pass_handle(self, node): # pylint: disable=W0613
# Graphviz's dot(1) support
dot_cmd = None
+# dot(1) -Tpdf should be used
+dot_Tpdf = False
# ImageMagick' convert(1) support
convert_cmd = None
@@ -175,7 +177,7 @@ def setupTools(app):
This function is called once, when the builder is initiated.
"""
- global dot_cmd, convert_cmd, rsvg_convert_cmd # pylint: disable=W0603
+ global dot_cmd, dot_Tpdf, convert_cmd, rsvg_convert_cmd # pylint: disable=W0603
global inkscape_cmd, inkscape_ver_one, inkscape_show_warn # pylint: disable=W0603
kernellog.verbose(app, "kfigure: check installed tools ...")
@@ -186,6 +188,16 @@ def setupTools(app):
if dot_cmd:
kernellog.verbose(app, "use dot(1) from: " + dot_cmd)
+
+ try:
+ dot_Thelp_list = subprocess.check_output([dot_cmd, '-Thelp'],
+ stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as err:
+ dot_Thelp_list = err.output
+ pass
+
+ dot_Tpdf_ptn = b'pdf'
+ dot_Tpdf = re.search(dot_Tpdf_ptn, dot_Thelp_list)
else:
kernellog.warn(app, "dot(1) not found, for better output quality install "
"graphviz from https://www.graphviz.org")
@@ -197,6 +209,7 @@ def setupTools(app):
inkscape_ver_one = re.search(ver_one_ptn, inkscape_ver)
convert_cmd = None
rsvg_convert_cmd = None
+ dot_Tpdf = False
try:
if os.environ['SPHINX_SHOW_INKSCAPE_WARN']:
@@ -216,6 +229,7 @@ def setupTools(app):
if rsvg_convert_cmd:
kernellog.verbose(app, "use rsvg-convert(1) from: " + rsvg_convert_cmd)
+ dot_Tpdf = False
else:
kernellog.verbose(app, "rsvg-convert(1) not found, "
"falling back to raster image conversion")
@@ -308,11 +322,12 @@ def convert_image(img_node, translator, src_fname=None):
if in_ext == '.dot':
kernellog.verbose(app, 'convert DOT to: {out}/' + _name)
- if translator.builder.format == 'latex':
+ if translator.builder.format == 'latex' and not dot_Tpdf:
svg_fname = path.join(translator.builder.outdir, fname + '.svg')
ok1 = dot2format(app, src_fname, svg_fname)
ok2 = svg2pdf_by_rsvg(app, svg_fname, dst_fname)
ok = ok1 and ok2
+
else:
ok = dot2format(app, src_fname, dst_fname)
--
2.17.1
Powered by blists - more mailing lists