Lines Matching +full:os +full:- +full:initiated

1 # -*- coding: utf-8; mode: python -*-
14 handling from the author's POV. Directives like ``kernel-figure`` implement
15 methods *to* always get the best output-format even if some tools are not
19 * ``.. kernel-image``: for image handling / a ``.. image::`` replacement
21 * ``.. kernel-figure``: for figure handling / a ``.. figure::`` replacement
23 * ``.. kernel-render``: for render markup / a concept to embed *render*
26 - ``DOT``: render embedded Graphviz's **DOC**
27 - ``SVG``: render embedded Scalable Vector Graphics (**SVG**)
28 - ... *developable*
33 available, the DOT language is inserted as literal-block.
34 For conversion to PDF, ``rsvg-convert(1)`` of librsvg
39 - ``convert(1)``: ImageMagick (https://www.imagemagick.org)
40 - ``inkscape(1)``: Inkscape (https://inkscape.org/)
46 * generate SVG (html-builder) and PDF (latex-builder) from DOT files.
47 DOT: see https://www.graphviz.org/content/dot-language
51 import os
52 from os import path
69 # -------------
77 envpath = os.environ.get('PATH', None) or os.defpath
78 for folder in envpath.split(os.pathsep):
79 fname = folder + os.sep + cmd
85 os.makedirs(folder, mode)
100 and os.stat(path1).st_ctime > os.stat(path2).st_ctime)
106 # -------------------------------------------
110 # dot(1) -Tpdf should be used
116 # librsvg's rsvg-convert(1) support
127 app.connect('builder-inited', setupTools)
130 app.add_directive("kernel-image", KernelImage)
139 app.add_directive("kernel-figure", KernelFigure)
148 app.add_directive('kernel-render', KernelRender)
156 app.connect('doctree-read', add_kernel_figure_to_std_domain)
169 This function is called once, when the builder is initiated.
177 rsvg_convert_cmd = which('rsvg-convert')
184 dot_Thelp_list = subprocess.check_output([dot_cmd, '-Thelp'],
197 inkscape_ver = subprocess.check_output([inkscape_cmd, '--version'],
216 kernellog.verbose(app, "use rsvg-convert(1) from: " + rsvg_convert_cmd)
217 kernellog.verbose(app, "use 'dot -Tsvg' and rsvg-convert(1) for DOT -> PDF conversion")
221 "rsvg-convert(1) not found.\n"
222 " SVG rendering of convert(1) is done by ImageMagick-native renderer.")
224 kernellog.verbose(app, "use 'dot -Tpdf' for DOT -> PDF conversion")
226 kernellog.verbose(app, "use 'dot -Tsvg' and convert(1) for DOT -> PDF conversion")
230 # --------------------------
258 # in kernel builds, use 'make SPHINXOPTS=-v' to see verbose messages
342 option ``-Txxx``). Normally you will use one of the following extensions:
344 - ``.ps`` for PostScript,
345 - ``.svg`` or ``svgz`` for Structured Vector Graphics,
346 - ``.fig`` for XFIG graphics and
347 - ``.png`` or ``gif`` for common bitmap graphics.
351 cmd = [dot_cmd, '-T%s' % out_format, dot_fname]
378 cmd = [inkscape_cmd, '-o', pdf_fname, svg_fname]
380 cmd = [inkscape_cmd, '-z', '--export-pdf=%s' % pdf_fname, svg_fname]
394 % (cmd_name, str(warning_msg, 'utf-8')))
397 % (cmd_name, str(warning_msg, 'utf-8')))
402 """Convert SVG to PDF with ``rsvg-convert(1)`` command.
408 SVG -> PDF conversion is done by ``rsvg-convert(1)``.
410 If ``rsvg-convert(1)`` is unavailable, fall back to ``svg2pdf()``.
417 cmd = [rsvg_convert_cmd, '--format=pdf', '-o', pdf_fname, svg_fname]
428 # ---------------------
433 Handles the ``image`` child-node with the ``convert_image(...)``.
439 """Node for ``kernel-image`` directive."""
452 if uri.endswith('.*') or uri.find('://') != -1:
465 # ---------------------
470 Handles the ``image`` child-node with the ``convert_image(...)``.
476 """Node for ``kernel-figure`` directive."""
488 if uri.endswith('.*') or uri.find('://') != -1:
503 # ---------------------
511 image child-node with the ``convert_image(...)``.
516 kernellog.verbose(app, 'visit kernel-render node lang: "%s"' % (srclang))
520 kernellog.warn(app, 'kernel-render: "%s" unknown / include raw.' % (srclang))
530 hashobj = code.encode('utf-8') # str(node.attributes)
531 fname = path.join('%s-%s' % (srclang, sha1(hashobj).hexdigest()))
551 """Node for ``kernel-render`` directive."""
621 """Add kernel-figure anchors to 'std' domain.
624 the caption (label) of ``kernel-figure`` directive (it only knows about
626 this will result in a 'undefined label' for kernel-figures.
628 This handle adds labels of kernel-figure to the 'std' domain labels.