sphinxcontrib-svg2pdfconverter-1.0.1/0002755007267400724610000000000013536716264016127 5ustar 00000000000000sphinxcontrib-svg2pdfconverter-1.0.1/LICENSE.txt0000644007267400724610000000261213536652420017742 0ustar 00000000000000If not otherwise noted, the extensions in this package are licensed under the following license. Copyright (c) 2018-2019 by Missing Link Electronics, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. sphinxcontrib-svg2pdfconverter-1.0.1/MANIFEST.in0000644007267400724610000000004713536701027017653 0ustar 00000000000000include README.rst include LICENSE.txt sphinxcontrib-svg2pdfconverter-1.0.1/PKG-INFO0000644007267400724610000000535213536716264017227 0ustar 00000000000000Metadata-Version: 2.1 Name: sphinxcontrib-svg2pdfconverter Version: 1.0.1 Summary: Sphinx SVG to PDF converter extension Home-page: https://github.com/missinglinkelectronics/sphinxcontrib-svg2pdfconverter Author: Stefan Wiehler Author-email: stefan.wiehler@missinglinkelectronics.com License: BSD Download-URL: https://pypi.org/project/sphinxcontrib-svg2pdfconverter Description: ************************************* Sphinx SVG to PDF Converter Extension ************************************* This extension converts SVG images to PDF in case the builder does not support SVG images natively (e.g. LaTeX). Internally, either `Inkscape `_ or ``rsvg-convert`` from `libRSVG `_ as a more lightweight alternative is used to convert images. Installation ============ Just install via ``pip``: .. code-block:: console $ pip install sphinxcontrib-svg2pdfconverter You can choose between Inkscape and libRSVG by either adding ``sphinxcontrib.inkscapeconverter`` or ``sphinxcontrib.rsvgconverter`` to the ``extensions`` list in your ``conf.py``. Make sure to have either ``inkscape`` or the ``rsvg-convert`` command available in your systems ``PATH`` and, if necessary, adapt the ``inkscape_converter_bin`` or ``rsvg_converter_bin`` config value respectively. Configuration ============= Inkscape -------- ``inkscape_converter_bin`` Path to Inkscape binary. By default, this is ``inkscape``. ``inkscape_converter_args`` Additional command-line arguments for Inkscape, as a list. By default, this is ``['--export-area-drawing']``. RSVG ---- ``rsvg_converter_bin`` Path to RSVG converter binary. By default, this is ``rsvg-convert``. ``rsvg_converter_args`` Additional command-line arguments for the RSVG converter, as a list. By default, this is the emtpy list ``[]``. Platform: any Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 3 Classifier: Framework :: Sphinx :: Extension Classifier: Topic :: Documentation Classifier: Topic :: Utilities Requires-Python: ~=3.4 Description-Content-Type: text/x-rst sphinxcontrib-svg2pdfconverter-1.0.1/README.rst0000644007267400724610000000272013530702722017601 0ustar 00000000000000************************************* Sphinx SVG to PDF Converter Extension ************************************* This extension converts SVG images to PDF in case the builder does not support SVG images natively (e.g. LaTeX). Internally, either `Inkscape `_ or ``rsvg-convert`` from `libRSVG `_ as a more lightweight alternative is used to convert images. Installation ============ Just install via ``pip``: .. code-block:: console $ pip install sphinxcontrib-svg2pdfconverter You can choose between Inkscape and libRSVG by either adding ``sphinxcontrib.inkscapeconverter`` or ``sphinxcontrib.rsvgconverter`` to the ``extensions`` list in your ``conf.py``. Make sure to have either ``inkscape`` or the ``rsvg-convert`` command available in your systems ``PATH`` and, if necessary, adapt the ``inkscape_converter_bin`` or ``rsvg_converter_bin`` config value respectively. Configuration ============= Inkscape -------- ``inkscape_converter_bin`` Path to Inkscape binary. By default, this is ``inkscape``. ``inkscape_converter_args`` Additional command-line arguments for Inkscape, as a list. By default, this is ``['--export-area-drawing']``. RSVG ---- ``rsvg_converter_bin`` Path to RSVG converter binary. By default, this is ``rsvg-convert``. ``rsvg_converter_args`` Additional command-line arguments for the RSVG converter, as a list. By default, this is the emtpy list ``[]``. sphinxcontrib-svg2pdfconverter-1.0.1/setup.cfg0000644007267400724610000000011513536716264017743 0ustar 00000000000000[metadata] license_file = LICENSE.txt [egg_info] tag_build = tag_date = 0 sphinxcontrib-svg2pdfconverter-1.0.1/setup.py0000644007267400724610000000265413536716171017643 0ustar 00000000000000# -*- coding: utf-8 -*- from setuptools import setup, find_packages from os import path here = path.abspath(path.dirname(__file__)) # Get the long description from the README file with open(path.join(here, 'README.rst'), encoding='utf-8') as f: long_description = f.read() requires = ['Sphinx>=1.6.3'] setup( name='sphinxcontrib-svg2pdfconverter', version='1.0.1', url='https://github.com/missinglinkelectronics/sphinxcontrib-svg2pdfconverter', download_url='https://pypi.org/project/sphinxcontrib-svg2pdfconverter', license='BSD', author='Stefan Wiehler', author_email='stefan.wiehler@missinglinkelectronics.com', description='Sphinx SVG to PDF converter extension', long_description=long_description, long_description_content_type='text/x-rst', zip_safe=False, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Console', 'Environment :: Web Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python :: 3', 'Framework :: Sphinx :: Extension', 'Topic :: Documentation', 'Topic :: Utilities', ], platforms='any', packages=find_packages(), include_package_data=True, install_requires=requires, python_requires='~=3.4', namespace_packages=['sphinxcontrib'], ) sphinxcontrib-svg2pdfconverter-1.0.1/sphinxcontrib/0002755007267400724610000000000013536716264021021 5ustar 00000000000000sphinxcontrib-svg2pdfconverter-1.0.1/sphinxcontrib/__init__.py0000644007267400724610000000056213536652420023124 0ustar 00000000000000# -*- coding: utf-8 -*- """ sphinxcontrib ~~~~~~~~~~~~~ This package is a namespace package that contains all extensions distributed in the ``sphinx-contrib`` distribution. :copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE.txt for details. """ __import__('pkg_resources').declare_namespace(__name__) sphinxcontrib-svg2pdfconverter-1.0.1/sphinxcontrib/inkscapeconverter.py0000644007267400724610000000636413536652420025120 0ustar 00000000000000# -*- coding: utf-8 -*- """ sphinxcontrib.inkscapeconverter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Converts SVG images to PDF using Inkscape in case the builder does not support SVG images natively (e.g. LaTeX). :copyright: Copyright 2018-2019 by Stefan Wiehler . :license: BSD, see LICENSE.txt for details. """ import subprocess from sphinx.errors import ExtensionError from sphinx.locale import __ from sphinx.transforms.post_transforms.images import ImageConverter from sphinx.util import logging from sphinx.util.osutil import ENOENT, EPIPE, EINVAL if False: # For type annotation from typing import Any, Dict # NOQA from sphinx.application import Sphinx # NOQA logger = logging.getLogger(__name__) class InkscapeConverter(ImageConverter): conversion_rules = [ ('image/svg+xml', 'application/pdf'), ] def is_available(self): # type: () -> bool """Confirms if Inkscape is available or not.""" try: args = [self.config.inkscape_converter_bin, '--version'] logger.debug('Invoking %r ...', args) ret = subprocess.call(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE) if ret == 0: return True else: return False except (OSError, IOError): logger.warning(__('Inkscape command %r cannot be run. ' 'Check the inkscape_converter_bin setting'), self.config.inkscape_converter_bin) return False def convert(self, _from, _to): # type: (unicode, unicode) -> bool """Converts the image from SVG to PDF via Inkscape.""" try: args = ([self.config.inkscape_converter_bin] + self.config.inkscape_converter_args + ['--export-pdf=' + _to, _from]) logger.debug('Invoking %r ...', args) p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE) except OSError as err: if err.errno != ENOENT: # No such file or directory raise logger.warning(__('Inkscape command %r cannot be run. ' 'Check the inkscape_converter_bin setting'), self.config.inkscape_converter_bin) return False try: stdout, stderr = p.communicate() except (OSError, IOError) as err: if err.errno not in (EPIPE, EINVAL): raise stdout, stderr = p.stdout.read(), p.stderr.read() p.wait() if p.returncode != 0: raise ExtensionError(__('Inkscape exited with error:\n' '[stderr]\n%s\n[stdout]\n%s') % (stderr, stdout)) return True def setup(app): # type: (Sphinx) -> Dict[unicode, Any] app.add_post_transform(InkscapeConverter) app.add_config_value('inkscape_converter_bin', 'inkscape', 'env') app.add_config_value('inkscape_converter_args', ['--export-area-drawing'], 'env') return { 'version': 'builtin', 'parallel_read_safe': True, 'parallel_write_safe': True, } sphinxcontrib-svg2pdfconverter-1.0.1/sphinxcontrib/rsvgconverter.py0000644007267400724610000000630313536652420024275 0ustar 00000000000000# -*- coding: utf-8 -*- """ sphinxcontrib.rsvgconverter ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Converts SVG images to PDF using libRSVG in case the builder does not support SVG images natively (e.g. LaTeX). :copyright: Copyright 2018-2019 by Stefan Wiehler . :license: BSD, see LICENSE.txt for details. """ import subprocess from sphinx.errors import ExtensionError from sphinx.locale import __ from sphinx.transforms.post_transforms.images import ImageConverter from sphinx.util import logging from sphinx.util.osutil import ENOENT, EPIPE, EINVAL if False: # For type annotation from typing import Any, Dict # NOQA from sphinx.application import Sphinx # NOQA logger = logging.getLogger(__name__) class RSVGConverter(ImageConverter): conversion_rules = [ ('image/svg+xml', 'application/pdf'), ] def is_available(self): # type: () -> bool """Confirms if RSVG converter is available or not.""" try: args = [self.config.rsvg_converter_bin, '--version'] logger.debug('Invoking %r ...', args) ret = subprocess.call(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE) if ret == 0: return True else: return False except (OSError, IOError): logger.warning(__('RSVG converter command %r cannot be run. ' 'Check the rsvg_converter_bin setting'), self.config.rsvg_converter_bin) return False def convert(self, _from, _to): # type: (unicode, unicode) -> bool """Converts the image from SVG to PDF via libRSVG.""" try: args = ([self.config.rsvg_converter_bin] + self.config.rsvg_converter_args + ['--format=pdf', '--output=' + _to, _from]) logger.debug('Invoking %r ...', args) p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE) except OSError as err: if err.errno != ENOENT: # No such file or directory raise logger.warning(__('RSVG converter command %r cannot be run. ' 'Check the rsvg_converter_bin setting'), self.config.rsvg_converter_bin) return False try: stdout, stderr = p.communicate() except (OSError, IOError) as err: if err.errno not in (EPIPE, EINVAL): raise stdout, stderr = p.stdout.read(), p.stderr.read() p.wait() if p.returncode != 0: raise ExtensionError(__('RSVG converter exited with error:\n' '[stderr]\n%s\n[stdout]\n%s') % (stderr, stdout)) return True def setup(app): # type: (Sphinx) -> Dict[unicode, Any] app.add_post_transform(RSVGConverter) app.add_config_value('rsvg_converter_bin', 'rsvg-convert', 'env') app.add_config_value('rsvg_converter_args', [], 'env') return { 'version': 'builtin', 'parallel_read_safe': True, 'parallel_write_safe': True, } sphinxcontrib-svg2pdfconverter-1.0.1/sphinxcontrib_svg2pdfconverter.egg-info/0002755007267400724610000000000013536716264026076 5ustar 00000000000000sphinxcontrib-svg2pdfconverter-1.0.1/sphinxcontrib_svg2pdfconverter.egg-info/PKG-INFO0000644007267400724610000000535213536716263027175 0ustar 00000000000000Metadata-Version: 2.1 Name: sphinxcontrib-svg2pdfconverter Version: 1.0.1 Summary: Sphinx SVG to PDF converter extension Home-page: https://github.com/missinglinkelectronics/sphinxcontrib-svg2pdfconverter Author: Stefan Wiehler Author-email: stefan.wiehler@missinglinkelectronics.com License: BSD Download-URL: https://pypi.org/project/sphinxcontrib-svg2pdfconverter Description: ************************************* Sphinx SVG to PDF Converter Extension ************************************* This extension converts SVG images to PDF in case the builder does not support SVG images natively (e.g. LaTeX). Internally, either `Inkscape `_ or ``rsvg-convert`` from `libRSVG `_ as a more lightweight alternative is used to convert images. Installation ============ Just install via ``pip``: .. code-block:: console $ pip install sphinxcontrib-svg2pdfconverter You can choose between Inkscape and libRSVG by either adding ``sphinxcontrib.inkscapeconverter`` or ``sphinxcontrib.rsvgconverter`` to the ``extensions`` list in your ``conf.py``. Make sure to have either ``inkscape`` or the ``rsvg-convert`` command available in your systems ``PATH`` and, if necessary, adapt the ``inkscape_converter_bin`` or ``rsvg_converter_bin`` config value respectively. Configuration ============= Inkscape -------- ``inkscape_converter_bin`` Path to Inkscape binary. By default, this is ``inkscape``. ``inkscape_converter_args`` Additional command-line arguments for Inkscape, as a list. By default, this is ``['--export-area-drawing']``. RSVG ---- ``rsvg_converter_bin`` Path to RSVG converter binary. By default, this is ``rsvg-convert``. ``rsvg_converter_args`` Additional command-line arguments for the RSVG converter, as a list. By default, this is the emtpy list ``[]``. Platform: any Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 3 Classifier: Framework :: Sphinx :: Extension Classifier: Topic :: Documentation Classifier: Topic :: Utilities Requires-Python: ~=3.4 Description-Content-Type: text/x-rst sphinxcontrib-svg2pdfconverter-1.0.1/sphinxcontrib_svg2pdfconverter.egg-info/SOURCES.txt0000644007267400724610000000102213536716264027753 0ustar 00000000000000LICENSE.txt MANIFEST.in README.rst setup.cfg setup.py sphinxcontrib/__init__.py sphinxcontrib/inkscapeconverter.py sphinxcontrib/rsvgconverter.py sphinxcontrib_svg2pdfconverter.egg-info/PKG-INFO sphinxcontrib_svg2pdfconverter.egg-info/SOURCES.txt sphinxcontrib_svg2pdfconverter.egg-info/dependency_links.txt sphinxcontrib_svg2pdfconverter.egg-info/namespace_packages.txt sphinxcontrib_svg2pdfconverter.egg-info/not-zip-safe sphinxcontrib_svg2pdfconverter.egg-info/requires.txt sphinxcontrib_svg2pdfconverter.egg-info/top_level.txtsphinxcontrib-svg2pdfconverter-1.0.1/sphinxcontrib_svg2pdfconverter.egg-info/dependency_links.txt0000644007267400724610000000000113536716263032141 0ustar 00000000000000 sphinxcontrib-svg2pdfconverter-1.0.1/sphinxcontrib_svg2pdfconverter.egg-info/namespace_packages.txt0000644007267400724610000000001613536716263032423 0ustar 00000000000000sphinxcontrib sphinxcontrib-svg2pdfconverter-1.0.1/sphinxcontrib_svg2pdfconverter.egg-info/not-zip-safe0000644007267400724610000000000113530702724030310 0ustar 00000000000000 sphinxcontrib-svg2pdfconverter-1.0.1/sphinxcontrib_svg2pdfconverter.egg-info/requires.txt0000644007267400724610000000001613536716263030470 0ustar 00000000000000Sphinx>=1.6.3 sphinxcontrib-svg2pdfconverter-1.0.1/sphinxcontrib_svg2pdfconverter.egg-info/top_level.txt0000644007267400724610000000001613536716263030622 0ustar 00000000000000sphinxcontrib