sphinxcontrib-nwdiag-0.9.5/0000755000076600000240000000000012627333603016474 5ustar tkomiyastaff00000000000000sphinxcontrib-nwdiag-0.9.5/AUTHORS0000644000076600000240000000004512627064306017544 0ustar tkomiyastaff00000000000000Takeshi KOMIYA sphinxcontrib-nwdiag-0.9.5/LICENSE0000644000076600000240000000261212627064306017503 0ustar tkomiyastaff00000000000000If not otherwise noted, the extensions in this package are licensed under the following license. Copyright (c) 2009 by the contributors (see AUTHORS file). 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 OWNER 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-nwdiag-0.9.5/MANIFEST.in0000644000076600000240000000010512627064306020227 0ustar tkomiyastaff00000000000000include AUTHORS include LICENSE include README.rst include CHANGES.* sphinxcontrib-nwdiag-0.9.5/PKG-INFO0000644000076600000240000000501512627333603017572 0ustar tkomiyastaff00000000000000Metadata-Version: 1.1 Name: sphinxcontrib-nwdiag Version: 0.9.5 Summary: Sphinx "nwdiag" extension Home-page: http://github.com/blockdiag/sphinxcontrib-nwdiag Author: Takeshi KOMIYA Author-email: i.tkomiya@gmail.com License: BSD Description: ==================== sphinxcontrib-nwdiag ==================== .. image:: https://travis-ci.org/blockdiag/sphinxcontrib-nwdiag.svg?branch=master :target: https://travis-ci.org/blockdiag/sphinxcontrib-nwdiag .. image:: https://coveralls.io/repos/blockdiag/sphinxcontrib-nwdiag/badge.png?branch=master :target: https://coveralls.io/r/blockdiag/sphinxcontrib-nwdiag?branch=master .. image:: https://codeclimate.com/github/blockdiag/sphinxcontrib-nwdiag/badges/gpa.svg :target: https://codeclimate.com/github/blockdiag/sphinxcontrib-nwdiag A sphinx extension for embedding network related diagrams using blockdiag_. For now, nwdiag supports these diagrams: - logical network diagram - rack structure diagram - packet structure diagram This extension enables you to insert network related diagrams into your document. Following code is an example:: .. nwdiag:: nwdiag { network { web01; web02; } network { web01; web02; db01; } } .. _nwdiag: http://bitbucket.org/blockdiag/nwdiag/ For more details, see `online documentation`_ at http://blockdiag.com/. .. _online documentation: http://blockdiag.com/en/nwdiag/sphinxcontrib.html Platform: any Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console Classifier: Environment :: Web Environment Classifier: Framework :: Sphinx :: Extension Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Topic :: Documentation Classifier: Topic :: Documentation :: Sphinx Classifier: Topic :: Utilities sphinxcontrib-nwdiag-0.9.5/README.rst0000644000076600000240000000227512627332432020170 0ustar tkomiyastaff00000000000000==================== sphinxcontrib-nwdiag ==================== .. image:: https://travis-ci.org/blockdiag/sphinxcontrib-nwdiag.svg?branch=master :target: https://travis-ci.org/blockdiag/sphinxcontrib-nwdiag .. image:: https://coveralls.io/repos/blockdiag/sphinxcontrib-nwdiag/badge.png?branch=master :target: https://coveralls.io/r/blockdiag/sphinxcontrib-nwdiag?branch=master .. image:: https://codeclimate.com/github/blockdiag/sphinxcontrib-nwdiag/badges/gpa.svg :target: https://codeclimate.com/github/blockdiag/sphinxcontrib-nwdiag A sphinx extension for embedding network related diagrams using blockdiag_. For now, nwdiag supports these diagrams: - logical network diagram - rack structure diagram - packet structure diagram This extension enables you to insert network related diagrams into your document. Following code is an example:: .. nwdiag:: nwdiag { network { web01; web02; } network { web01; web02; db01; } } .. _nwdiag: http://bitbucket.org/blockdiag/nwdiag/ For more details, see `online documentation`_ at http://blockdiag.com/. .. _online documentation: http://blockdiag.com/en/nwdiag/sphinxcontrib.html sphinxcontrib-nwdiag-0.9.5/setup.cfg0000644000076600000240000000046512627333603020322 0ustar tkomiyastaff00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 [build] build-base = _build [sdist] formats = gztar [wheel] universal = 1 [aliases] release = check -r -s register sdist bdist_wheel upload [check] strict = 1 restructuredtext = 1 [flake8] max-line-length = 120 ignore = _ exclude = tests/docs/ sphinxcontrib-nwdiag-0.9.5/setup.py0000644000076600000240000000262112627333555020215 0ustar tkomiyastaff00000000000000# -*- coding: utf-8 -*- from setuptools import setup, find_packages requires = ['blockdiag>=1.5.0', 'nwdiag>=1.0.3', 'Sphinx>=0.6'] setup( name='sphinxcontrib-nwdiag', version='0.9.5', url='http://github.com/blockdiag/sphinxcontrib-nwdiag', license='BSD', author='Takeshi KOMIYA', author_email='i.tkomiya@gmail.com', description='Sphinx "nwdiag" extension', long_description=open('README.rst').read(), zip_safe=False, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Console', 'Environment :: Web Environment', 'Framework :: Sphinx :: Extension', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Topic :: Documentation', 'Topic :: Documentation :: Sphinx', 'Topic :: Utilities', ], platforms='any', packages=find_packages(exclude=['tests', 'tests.*']), include_package_data=True, install_requires=requires, namespace_packages=['sphinxcontrib'], ) sphinxcontrib-nwdiag-0.9.5/sphinxcontrib/0000755000076600000240000000000012627333603021366 5ustar tkomiyastaff00000000000000sphinxcontrib-nwdiag-0.9.5/sphinxcontrib/__init__.py0000644000076600000240000000055512627064306023505 0ustar tkomiyastaff00000000000000# -*- 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 for details. """ __import__('pkg_resources').declare_namespace(__name__) sphinxcontrib-nwdiag-0.9.5/sphinxcontrib/nwdiag.py0000644000076600000240000002602612627064306023220 0ustar tkomiyastaff00000000000000# -*- coding: utf-8 -*- """ nwdiag.sphinx_ext ~~~~~~~~~~~~~~~~~~~~ Allow nwdiag-formatted diagrams to be included in Sphinx-generated documents inline. :copyright: Copyright 2010 by Takeshi Komiya. :license: BSDL. """ from __future__ import absolute_import import os import re import posixpath import traceback import pkg_resources from collections import namedtuple from docutils import nodes from sphinx import addnodes from sphinx.util.osutil import ensuredir import nwdiag.utils.rst.nodes import nwdiag.utils.rst.directives from blockdiag.utils.bootstrap import detectfont, Application from blockdiag.utils.compat import u, string_types from blockdiag.utils.fontmap import FontMap from blockdiag.utils.rst.directives import with_blockdiag # fontconfig; it will be initialized on `builder-inited` event. fontmap = None class nwdiag_node(nwdiag.utils.rst.nodes.nwdiag): def to_drawer(self, image_format, builder, **kwargs): if 'filename' in kwargs: filename = kwargs.pop('filename') else: filename = self.get_abspath(image_format, builder) antialias = builder.config.nwdiag_antialias transparency = builder.config.nwdiag_transparency image = super(nwdiag_node, self).to_drawer(image_format, filename, fontmap, antialias=antialias, transparency=transparency, **kwargs) for node in image.diagram.traverse_nodes(): node.href = resolve_reference(builder, node.href) return image def get_relpath(self, image_format, builder): options = dict(antialias=builder.config.nwdiag_antialias, fontpath=builder.config.nwdiag_fontpath, fontmap=builder.config.nwdiag_fontmap, format=image_format, transparency=builder.config.nwdiag_transparency) if hasattr(builder, 'imgpath'): # Sphinx (<= 1.2.x) or HTML writer outputdir = builder.imgpath else: outputdir = '' return posixpath.join(outputdir, self.get_path(**options)) def get_abspath(self, image_format, builder): options = dict(antialias=builder.config.nwdiag_antialias, fontpath=builder.config.nwdiag_fontpath, fontmap=builder.config.nwdiag_fontmap, format=image_format, transparency=builder.config.nwdiag_transparency) if hasattr(builder, 'imagedir'): # Sphinx (>= 1.3.x) outputdir = os.path.join(builder.outdir, builder.imagedir) elif hasattr(builder, 'imgpath'): # Sphinx (<= 1.2.x) and HTML writer outputdir = os.path.join(builder.outdir, '_images') else: outputdir = builder.outdir path = os.path.join(outputdir, self.get_path(**options)) ensuredir(os.path.dirname(path)) return path class Nwdiag(nwdiag.utils.rst.directives.NwdiagDirective): node_class = nwdiag_node def node2image(self, node, diagram): return node def resolve_reference(builder, href): if href is None: return None pattern = re.compile(u("^:ref:`(.+?)`"), re.UNICODE) matched = pattern.search(href) if matched is None: return href elif not hasattr(builder, 'current_docname'): # ex. latex builder return matched.group(1) else: refid = matched.group(1) domain = builder.env.domains['std'] node = addnodes.pending_xref(refexplicit=False) xref = domain.resolve_xref(builder.env, builder.current_docname, builder, 'ref', refid, node, node) if xref: if 'refid' in xref: return "#" + xref['refid'] else: return xref['refuri'] else: builder.warn('undefined label: %s' % refid) return None def html_render_svg(self, node): image = node.to_drawer('SVG', self.builder, filename=None, nodoctype=True) image.draw() if 'align' in node['options']: align = node['options']['align'] self.body.append('
' % (align, align)) self.context.append('
\n') else: self.body.append('
') self.context.append('
\n') # reftarget for node_id in node['ids']: self.body.append('' % node_id) # resize image size = image.pagesize().resize(**node['options']) self.body.append(image.save(size)) self.context.append('') def html_render_clickablemap(self, image, width_ratio, height_ratio): href_nodes = [node for node in image.nodes if node.href] if not href_nodes: return self.body.append('' % id(image)) for node in href_nodes: x1, y1, x2, y2 = image.metrics.cell(node) x1 *= width_ratio x2 *= width_ratio y1 *= height_ratio y2 *= height_ratio areatag = '' % (x1, y1, x2, y2, node.href) self.body.append(areatag) self.body.append('') def html_render_png(self, node): image = node.to_drawer('PNG', self.builder) if not os.path.isfile(image.filename): image.draw() image.save() # align if 'align' in node['options']: align = node['options']['align'] self.body.append('
' % (align, align)) self.context.append('
\n') else: self.body.append('
') self.context.append('
') # link to original image relpath = node.get_relpath('PNG', self.builder) if 'width' in node['options'] or 'height' in node['options'] or 'scale' in node['options']: self.body.append('' % relpath) self.context.append('') else: self.context.append('') # tag original_size = image.pagesize() resized = original_size.resize(**node['options']) img_attr = dict(src=relpath, width=resized.width, height=resized.height) if any(node.href for node in image.nodes): img_attr['usemap'] = "#map_%d" % id(image) width_ratio = float(resized.width) / original_size.width height_ratio = float(resized.height) / original_size.height html_render_clickablemap(self, image, width_ratio, height_ratio) if 'alt' in node['options']: img_attr['alt'] = node['options']['alt'] self.body.append(self.starttag(node, 'img', '', empty=True, **img_attr)) @with_blockdiag def html_visit_nwdiag(self, node): try: image_format = get_image_format_for(self.builder) if image_format.upper() == 'SVG': html_render_svg(self, node) else: html_render_png(self, node) except UnicodeEncodeError: if self.builder.config.nwdiag_debug: traceback.print_exc() msg = ("nwdiag error: UnicodeEncodeError caught " "(check your font settings)") self.builder.warn(msg) raise nodes.SkipNode except Exception as exc: if self.builder.config.nwdiag_debug: traceback.print_exc() self.builder.warn('dot code %r: %s' % (node['code'], str(exc))) raise nodes.SkipNode def html_depart_nwdiag(self, node): self.body.append(self.context.pop()) self.body.append(self.context.pop()) def get_image_format_for(builder): if builder.format in ('html', 'slides'): image_format = builder.config.nwdiag_html_image_format.upper() elif builder.format == 'latex': if builder.config.nwdiag_tex_image_format: image_format = builder.config.nwdiag_tex_image_format.upper() else: image_format = builder.config.nwdiag_latex_image_format.upper() else: image_format = 'PNG' if image_format.upper() not in ('PNG', 'PDF', 'SVG'): raise ValueError('unknown format: %s' % image_format) if image_format.upper() == 'PDF': try: import reportlab # NOQA: importing test except ImportError: raise ImportError('Could not output PDF format. Install reportlab.') return image_format def on_builder_inited(self): # show deprecated message if self.builder.config.nwdiag_tex_image_format: self.builder.warn('nwdiag_tex_image_format is deprecated. Use nwdiag_latex_image_format.') # initialize fontmap global fontmap try: fontmappath = self.builder.config.nwdiag_fontmap fontmap = FontMap(fontmappath) except: fontmap = FontMap(None) try: fontpath = self.builder.config.nwdiag_fontpath if isinstance(fontpath, string_types): fontpath = [fontpath] if fontpath: config = namedtuple('Config', 'font')(fontpath) fontpath = detectfont(config) fontmap.set_default_font(fontpath) except: pass def on_doctree_resolved(self, doctree, docname): if self.builder.format in ('html', 'slides'): return try: image_format = get_image_format_for(self.builder) except Exception as exc: if self.builder.config.nwdiag_debug: traceback.print_exc() self.builder.warn('nwdiag error: %s' % exc) for node in doctree.traverse(nwdiag_node): node.parent.remove(node) return for node in doctree.traverse(nwdiag_node): try: with Application(): relfn = node.get_relpath(image_format, self.builder) image = node.to_drawer(image_format, self.builder) if not os.path.isfile(image.filename): image.draw() image.save() image = nodes.image(uri=relfn, candidates={'*': relfn}, **node['options']) node.parent.replace(node, image) except Exception as exc: if self.builder.config.nwdiag_debug: traceback.print_exc() self.builder.warn('dot code %r: %s' % (node['code'], str(exc))) node.parent.remove(node) def setup(app): app.add_node(nwdiag_node, html=(html_visit_nwdiag, html_depart_nwdiag)) app.add_directive('nwdiag', Nwdiag) app.add_config_value('nwdiag_fontpath', None, 'html') app.add_config_value('nwdiag_fontmap', None, 'html') app.add_config_value('nwdiag_antialias', False, 'html') app.add_config_value('nwdiag_transparency', True, 'html') app.add_config_value('nwdiag_debug', False, 'html') app.add_config_value('nwdiag_html_image_format', 'PNG', 'html') app.add_config_value('nwdiag_tex_image_format', None, 'html') # backward compatibility for 0.6.1 app.add_config_value('nwdiag_latex_image_format', 'PNG', 'html') app.connect("builder-inited", on_builder_inited) app.connect("doctree-resolved", on_doctree_resolved) return { 'version': pkg_resources.require('nwdiag')[0].version, 'parallel_read_safe': True, 'parallel_write_safe': True, } sphinxcontrib-nwdiag-0.9.5/sphinxcontrib/packetdiag.py0000644000076600000240000002636712627064306024053 0ustar tkomiyastaff00000000000000# -*- coding: utf-8 -*- """ packetdiag.sphinx_ext ~~~~~~~~~~~~~~~~~~~~~ Allow packetdiag-formatted diagrams to be included in Sphinx-generated documents inline. :copyright: Copyright 2010 by Takeshi Komiya. :license: BSDL. """ from __future__ import absolute_import import os import re import posixpath import traceback import pkg_resources from collections import namedtuple from docutils import nodes from sphinx import addnodes from sphinx.util.osutil import ensuredir import packetdiag.utils.rst.nodes import packetdiag.utils.rst.directives from blockdiag.utils.bootstrap import detectfont, Application from blockdiag.utils.compat import u, string_types from blockdiag.utils.fontmap import FontMap from blockdiag.utils.rst.directives import with_blockdiag # fontconfig; it will be initialized on `builder-inited` event. fontmap = None class packetdiag_node(packetdiag.utils.rst.nodes.packetdiag): def to_drawer(self, image_format, builder, **kwargs): if 'filename' in kwargs: filename = kwargs.pop('filename') else: filename = self.get_abspath(image_format, builder) antialias = builder.config.packetdiag_antialias transparency = builder.config.packetdiag_transparency image = super(packetdiag_node, self).to_drawer(image_format, filename, fontmap, antialias=antialias, transparency=transparency, **kwargs) for node in image.diagram.traverse_nodes(): node.href = resolve_reference(builder, node.href) return image def get_relpath(self, image_format, builder): options = dict(antialias=builder.config.packetdiag_antialias, fontpath=builder.config.packetdiag_fontpath, fontmap=builder.config.packetdiag_fontmap, format=image_format, transparency=builder.config.packetdiag_transparency) if hasattr(builder, 'imgpath'): # Sphinx (<= 1.2.x) or HTML writer outputdir = builder.imgpath else: outputdir = '' return posixpath.join(outputdir, self.get_path(**options)) def get_abspath(self, image_format, builder): options = dict(antialias=builder.config.packetdiag_antialias, fontpath=builder.config.packetdiag_fontpath, fontmap=builder.config.packetdiag_fontmap, format=image_format, transparency=builder.config.packetdiag_transparency) if hasattr(builder, 'imagedir'): # Sphinx (>= 1.3.x) outputdir = os.path.join(builder.outdir, builder.imagedir) elif hasattr(builder, 'imgpath'): # Sphinx (<= 1.2.x) and HTML writer outputdir = os.path.join(builder.outdir, '_images') else: outputdir = builder.outdir path = os.path.join(outputdir, self.get_path(**options)) ensuredir(os.path.dirname(path)) return path class Packetdiag(packetdiag.utils.rst.directives.PacketdiagDirective): node_class = packetdiag_node def node2image(self, node, diagram): return node def resolve_reference(builder, href): if href is None: return None pattern = re.compile(u("^:ref:`(.+?)`"), re.UNICODE) matched = pattern.search(href) if matched is None: return href elif not hasattr(builder, 'current_docname'): # ex. latex builder return matched.group(1) else: refid = matched.group(1) domain = builder.env.domains['std'] node = addnodes.pending_xref(refexplicit=False) xref = domain.resolve_xref(builder.env, builder.current_docname, builder, 'ref', refid, node, node) if xref: if 'refid' in xref: return "#" + xref['refid'] else: return xref['refuri'] else: builder.warn('undefined label: %s' % refid) return None def html_render_svg(self, node): image = node.to_drawer('SVG', self.builder, filename=None, nodoctype=True) image.draw() if 'align' in node['options']: align = node['options']['align'] self.body.append('
' % (align, align)) self.context.append('
\n') else: self.body.append('
') self.context.append('
\n') # reftarget for node_id in node['ids']: self.body.append('' % node_id) # resize image size = image.pagesize().resize(**node['options']) self.body.append(image.save(size)) self.context.append('') def html_render_clickablemap(self, image, width_ratio, height_ratio): href_nodes = [node for node in image.nodes if node.href] if not href_nodes: return self.body.append('' % id(image)) for node in href_nodes: x1, y1, x2, y2 = image.metrics.cell(node) x1 *= width_ratio x2 *= width_ratio y1 *= height_ratio y2 *= height_ratio areatag = '' % (x1, y1, x2, y2, node.href) self.body.append(areatag) self.body.append('') def html_render_png(self, node): image = node.to_drawer('PNG', self.builder) if not os.path.isfile(image.filename): image.draw() image.save() # align if 'align' in node['options']: align = node['options']['align'] self.body.append('
' % (align, align)) self.context.append('
\n') else: self.body.append('
') self.context.append('
') # link to original image relpath = node.get_relpath('PNG', self.builder) if 'width' in node['options'] or 'height' in node['options'] or 'scale' in node['options']: self.body.append('' % relpath) self.context.append('') else: self.context.append('') # tag original_size = image.pagesize() resized = original_size.resize(**node['options']) img_attr = dict(src=relpath, width=resized.width, height=resized.height) if any(node.href for node in image.nodes): img_attr['usemap'] = "#map_%d" % id(image) width_ratio = float(resized.width) / original_size.width height_ratio = float(resized.height) / original_size.height html_render_clickablemap(self, image, width_ratio, height_ratio) if 'alt' in node['options']: img_attr['alt'] = node['options']['alt'] self.body.append(self.starttag(node, 'img', '', empty=True, **img_attr)) @with_blockdiag def html_visit_packetdiag(self, node): try: image_format = get_image_format_for(self.builder) if image_format.upper() == 'SVG': html_render_svg(self, node) else: html_render_png(self, node) except UnicodeEncodeError: if self.builder.config.packetdiag_debug: traceback.print_exc() msg = ("packetdiag error: UnicodeEncodeError caught " "(check your font settings)") self.builder.warn(msg) raise nodes.SkipNode except Exception as exc: if self.builder.config.packetdiag_debug: traceback.print_exc() self.builder.warn('dot code %r: %s' % (node['code'], str(exc))) raise nodes.SkipNode def html_depart_packetdiag(self, node): self.body.append(self.context.pop()) self.body.append(self.context.pop()) def get_image_format_for(builder): if builder.format in ('html', 'slides'): image_format = builder.config.packetdiag_html_image_format.upper() elif builder.format == 'latex': if builder.config.packetdiag_tex_image_format: image_format = builder.config.packetdiag_tex_image_format.upper() else: image_format = builder.config.packetdiag_latex_image_format.upper() else: image_format = 'PNG' if image_format.upper() not in ('PNG', 'PDF', 'SVG'): raise ValueError('unknown format: %s' % image_format) if image_format.upper() == 'PDF': try: import reportlab # NOQA: importing test except ImportError: raise ImportError('Could not output PDF format. Install reportlab.') return image_format def on_builder_inited(self): # show deprecated message if self.builder.config.packetdiag_tex_image_format: self.builder.warn('packetdiag_tex_image_format is deprecated. Use packetdiag_latex_image_format.') # initialize fontmap global fontmap try: fontmappath = self.builder.config.packetdiag_fontmap fontmap = FontMap(fontmappath) except: fontmap = FontMap(None) try: fontpath = self.builder.config.packetdiag_fontpath if isinstance(fontpath, string_types): fontpath = [fontpath] if fontpath: config = namedtuple('Config', 'font')(fontpath) fontpath = detectfont(config) fontmap.set_default_font(fontpath) except: pass def on_doctree_resolved(self, doctree, docname): if self.builder.format in ('html', 'slides'): return try: image_format = get_image_format_for(self.builder) except Exception as exc: if self.builder.config.packetdiag_debug: traceback.print_exc() self.builder.warn('packetdiag error: %s' % exc) for node in doctree.traverse(packetdiag_node): node.parent.remove(node) return for node in doctree.traverse(packetdiag_node): try: with Application(): relfn = node.get_relpath(image_format, self.builder) image = node.to_drawer(image_format, self.builder) if not os.path.isfile(image.filename): image.draw() image.save() image = nodes.image(uri=relfn, candidates={'*': relfn}, **node['options']) node.parent.replace(node, image) except Exception as exc: if self.builder.config.packetdiag_debug: traceback.print_exc() self.builder.warn('dot code %r: %s' % (node['code'], str(exc))) node.parent.remove(node) def setup(app): app.add_node(packetdiag_node, html=(html_visit_packetdiag, html_depart_packetdiag)) app.add_directive('packetdiag', Packetdiag) app.add_config_value('packetdiag_fontpath', None, 'html') app.add_config_value('packetdiag_fontmap', None, 'html') app.add_config_value('packetdiag_antialias', False, 'html') app.add_config_value('packetdiag_transparency', True, 'html') app.add_config_value('packetdiag_debug', False, 'html') app.add_config_value('packetdiag_html_image_format', 'PNG', 'html') app.add_config_value('packetdiag_tex_image_format', None, 'html') # backward compatibility for 0.6.1 app.add_config_value('packetdiag_latex_image_format', 'PNG', 'html') app.connect("builder-inited", on_builder_inited) app.connect("doctree-resolved", on_doctree_resolved) return { 'version': pkg_resources.require('nwdiag')[0].version, 'parallel_read_safe': True, 'parallel_write_safe': True, } sphinxcontrib-nwdiag-0.9.5/sphinxcontrib/rackdiag.py0000644000076600000240000002620612627064306023514 0ustar tkomiyastaff00000000000000# -*- coding: utf-8 -*- """ rackdiag.sphinx_ext ~~~~~~~~~~~~~~~~~~~~ Allow rackdiag-formatted diagrams to be included in Sphinx-generated documents inline. :copyright: Copyright 2010 by Takeshi Komiya. :license: BSDL. """ from __future__ import absolute_import import os import re import posixpath import traceback import pkg_resources from collections import namedtuple from docutils import nodes from sphinx import addnodes from sphinx.util.osutil import ensuredir import rackdiag.utils.rst.nodes import rackdiag.utils.rst.directives from blockdiag.utils.bootstrap import detectfont, Application from blockdiag.utils.compat import u, string_types from blockdiag.utils.fontmap import FontMap from blockdiag.utils.rst.directives import with_blockdiag # fontconfig; it will be initialized on `builder-inited` event. fontmap = None class rackdiag_node(rackdiag.utils.rst.nodes.rackdiag): def to_drawer(self, image_format, builder, **kwargs): if 'filename' in kwargs: filename = kwargs.pop('filename') else: filename = self.get_abspath(image_format, builder) antialias = builder.config.rackdiag_antialias transparency = builder.config.rackdiag_transparency image = super(rackdiag_node, self).to_drawer(image_format, filename, fontmap, antialias=antialias, transparency=transparency, **kwargs) for node in image.diagram.traverse_nodes(): node.href = resolve_reference(builder, node.href) return image def get_relpath(self, image_format, builder): options = dict(antialias=builder.config.rackdiag_antialias, fontpath=builder.config.rackdiag_fontpath, fontmap=builder.config.rackdiag_fontmap, format=image_format, transparency=builder.config.rackdiag_transparency) if hasattr(builder, 'imgpath'): # Sphinx (<= 1.2.x) or HTML writer outputdir = builder.imgpath else: outputdir = '' return posixpath.join(outputdir, self.get_path(**options)) def get_abspath(self, image_format, builder): options = dict(antialias=builder.config.rackdiag_antialias, fontpath=builder.config.rackdiag_fontpath, fontmap=builder.config.rackdiag_fontmap, format=image_format, transparency=builder.config.rackdiag_transparency) if hasattr(builder, 'imagedir'): # Sphinx (>= 1.3.x) outputdir = os.path.join(builder.outdir, builder.imagedir) elif hasattr(builder, 'imgpath'): # Sphinx (<= 1.2.x) and HTML writer outputdir = os.path.join(builder.outdir, '_images') else: outputdir = builder.outdir path = os.path.join(outputdir, self.get_path(**options)) ensuredir(os.path.dirname(path)) return path class Rackdiag(rackdiag.utils.rst.directives.RackdiagDirective): node_class = rackdiag_node def node2image(self, node, diagram): return node def resolve_reference(builder, href): if href is None: return None pattern = re.compile(u("^:ref:`(.+?)`"), re.UNICODE) matched = pattern.search(href) if matched is None: return href elif not hasattr(builder, 'current_docname'): # ex. latex builder return matched.group(1) else: refid = matched.group(1) domain = builder.env.domains['std'] node = addnodes.pending_xref(refexplicit=False) xref = domain.resolve_xref(builder.env, builder.current_docname, builder, 'ref', refid, node, node) if xref: if 'refid' in xref: return "#" + xref['refid'] else: return xref['refuri'] else: builder.warn('undefined label: %s' % refid) return None def html_render_svg(self, node): image = node.to_drawer('SVG', self.builder, filename=None, nodoctype=True) image.draw() if 'align' in node['options']: align = node['options']['align'] self.body.append('
' % (align, align)) self.context.append('
\n') else: self.body.append('
') self.context.append('
\n') # reftarget for node_id in node['ids']: self.body.append('' % node_id) # resize image size = image.pagesize().resize(**node['options']) self.body.append(image.save(size)) self.context.append('') def html_render_clickablemap(self, image, width_ratio, height_ratio): href_nodes = [node for node in image.nodes if node.href] if not href_nodes: return self.body.append('' % id(image)) for node in href_nodes: x1, y1, x2, y2 = image.metrics.cell(node) x1 *= width_ratio x2 *= width_ratio y1 *= height_ratio y2 *= height_ratio areatag = '' % (x1, y1, x2, y2, node.href) self.body.append(areatag) self.body.append('') def html_render_png(self, node): image = node.to_drawer('PNG', self.builder) if not os.path.isfile(image.filename): image.draw() image.save() # align if 'align' in node['options']: align = node['options']['align'] self.body.append('
' % (align, align)) self.context.append('
\n') else: self.body.append('
') self.context.append('
') # link to original image relpath = node.get_relpath('PNG', self.builder) if 'width' in node['options'] or 'height' in node['options'] or 'scale' in node['options']: self.body.append('' % relpath) self.context.append('') else: self.context.append('') # tag original_size = image.pagesize() resized = original_size.resize(**node['options']) img_attr = dict(src=relpath, width=resized.width, height=resized.height) if any(node.href for node in image.nodes): img_attr['usemap'] = "#map_%d" % id(image) width_ratio = float(resized.width) / original_size.width height_ratio = float(resized.height) / original_size.height html_render_clickablemap(self, image, width_ratio, height_ratio) if 'alt' in node['options']: img_attr['alt'] = node['options']['alt'] self.body.append(self.starttag(node, 'img', '', empty=True, **img_attr)) @with_blockdiag def html_visit_rackdiag(self, node): try: image_format = get_image_format_for(self.builder) if image_format.upper() == 'SVG': html_render_svg(self, node) else: html_render_png(self, node) except UnicodeEncodeError: if self.builder.config.rackdiag_debug: traceback.print_exc() msg = ("rackdiag error: UnicodeEncodeError caught " "(check your font settings)") self.builder.warn(msg) raise nodes.SkipNode except Exception as exc: if self.builder.config.rackdiag_debug: traceback.print_exc() self.builder.warn('dot code %r: %s' % (node['code'], str(exc))) raise nodes.SkipNode def html_depart_rackdiag(self, node): self.body.append(self.context.pop()) self.body.append(self.context.pop()) def get_image_format_for(builder): if builder.format in ('html', 'slides'): image_format = builder.config.rackdiag_html_image_format.upper() elif builder.format == 'latex': if builder.config.rackdiag_tex_image_format: image_format = builder.config.rackdiag_tex_image_format.upper() else: image_format = builder.config.rackdiag_latex_image_format.upper() else: image_format = 'PNG' if image_format.upper() not in ('PNG', 'PDF', 'SVG'): raise ValueError('unknown format: %s' % image_format) if image_format.upper() == 'PDF': try: import reportlab # NOQA: importing test except ImportError: raise ImportError('Could not output PDF format. Install reportlab.') return image_format def on_builder_inited(self): # show deprecated message if self.builder.config.rackdiag_tex_image_format: self.builder.warn('rackdiag_tex_image_format is deprecated. Use rackdiag_latex_image_format.') # initialize fontmap global fontmap try: fontmappath = self.builder.config.rackdiag_fontmap fontmap = FontMap(fontmappath) except: fontmap = FontMap(None) try: fontpath = self.builder.config.rackdiag_fontpath if isinstance(fontpath, string_types): fontpath = [fontpath] if fontpath: config = namedtuple('Config', 'font')(fontpath) fontpath = detectfont(config) fontmap.set_default_font(fontpath) except: pass def on_doctree_resolved(self, doctree, docname): if self.builder.format in ('html', 'slides'): return try: image_format = get_image_format_for(self.builder) except Exception as exc: if self.builder.config.rackdiag_debug: traceback.print_exc() self.builder.warn('rackdiag error: %s' % exc) for node in doctree.traverse(rackdiag_node): node.parent.remove(node) return for node in doctree.traverse(rackdiag_node): try: with Application(): relfn = node.get_relpath(image_format, self.builder) image = node.to_drawer(image_format, self.builder) if not os.path.isfile(image.filename): image.draw() image.save() image = nodes.image(uri=relfn, candidates={'*': relfn}, **node['options']) node.parent.replace(node, image) except Exception as exc: if self.builder.config.rackdiag_debug: traceback.print_exc() self.builder.warn('dot code %r: %s' % (node['code'], str(exc))) node.parent.remove(node) def setup(app): app.add_node(rackdiag_node, html=(html_visit_rackdiag, html_depart_rackdiag)) app.add_directive('rackdiag', Rackdiag) app.add_config_value('rackdiag_fontpath', None, 'html') app.add_config_value('rackdiag_fontmap', None, 'html') app.add_config_value('rackdiag_antialias', False, 'html') app.add_config_value('rackdiag_transparency', True, 'html') app.add_config_value('rackdiag_debug', False, 'html') app.add_config_value('rackdiag_html_image_format', 'PNG', 'html') app.add_config_value('rackdiag_tex_image_format', None, 'html') # backward compatibility for 0.6.1 app.add_config_value('rackdiag_latex_image_format', 'PNG', 'html') app.connect("builder-inited", on_builder_inited) app.connect("doctree-resolved", on_doctree_resolved) return { 'version': pkg_resources.require('nwdiag')[0].version, 'parallel_read_safe': True, 'parallel_write_safe': True, } sphinxcontrib-nwdiag-0.9.5/sphinxcontrib_nwdiag.egg-info/0000755000076600000240000000000012627333603024411 5ustar tkomiyastaff00000000000000sphinxcontrib-nwdiag-0.9.5/sphinxcontrib_nwdiag.egg-info/dependency_links.txt0000644000076600000240000000000112627333562030463 0ustar tkomiyastaff00000000000000 sphinxcontrib-nwdiag-0.9.5/sphinxcontrib_nwdiag.egg-info/namespace_packages.txt0000644000076600000240000000001612627333562030745 0ustar tkomiyastaff00000000000000sphinxcontrib sphinxcontrib-nwdiag-0.9.5/sphinxcontrib_nwdiag.egg-info/not-zip-safe0000644000076600000240000000000112627331525026640 0ustar tkomiyastaff00000000000000 sphinxcontrib-nwdiag-0.9.5/sphinxcontrib_nwdiag.egg-info/PKG-INFO0000644000076600000240000000501512627333562025513 0ustar tkomiyastaff00000000000000Metadata-Version: 1.1 Name: sphinxcontrib-nwdiag Version: 0.9.5 Summary: Sphinx "nwdiag" extension Home-page: http://github.com/blockdiag/sphinxcontrib-nwdiag Author: Takeshi KOMIYA Author-email: i.tkomiya@gmail.com License: BSD Description: ==================== sphinxcontrib-nwdiag ==================== .. image:: https://travis-ci.org/blockdiag/sphinxcontrib-nwdiag.svg?branch=master :target: https://travis-ci.org/blockdiag/sphinxcontrib-nwdiag .. image:: https://coveralls.io/repos/blockdiag/sphinxcontrib-nwdiag/badge.png?branch=master :target: https://coveralls.io/r/blockdiag/sphinxcontrib-nwdiag?branch=master .. image:: https://codeclimate.com/github/blockdiag/sphinxcontrib-nwdiag/badges/gpa.svg :target: https://codeclimate.com/github/blockdiag/sphinxcontrib-nwdiag A sphinx extension for embedding network related diagrams using blockdiag_. For now, nwdiag supports these diagrams: - logical network diagram - rack structure diagram - packet structure diagram This extension enables you to insert network related diagrams into your document. Following code is an example:: .. nwdiag:: nwdiag { network { web01; web02; } network { web01; web02; db01; } } .. _nwdiag: http://bitbucket.org/blockdiag/nwdiag/ For more details, see `online documentation`_ at http://blockdiag.com/. .. _online documentation: http://blockdiag.com/en/nwdiag/sphinxcontrib.html Platform: any Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console Classifier: Environment :: Web Environment Classifier: Framework :: Sphinx :: Extension Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Topic :: Documentation Classifier: Topic :: Documentation :: Sphinx Classifier: Topic :: Utilities sphinxcontrib-nwdiag-0.9.5/sphinxcontrib_nwdiag.egg-info/requires.txt0000644000076600000240000000005312627333562027013 0ustar tkomiyastaff00000000000000blockdiag>=1.5.0 nwdiag>=1.0.3 Sphinx>=0.6 sphinxcontrib-nwdiag-0.9.5/sphinxcontrib_nwdiag.egg-info/SOURCES.txt0000644000076600000240000000163312627333562026304 0ustar tkomiyastaff00000000000000AUTHORS LICENSE MANIFEST.in README.rst setup.cfg setup.py sphinxcontrib/__init__.py sphinxcontrib/nwdiag.py sphinxcontrib/packetdiag.py sphinxcontrib/rackdiag.py sphinxcontrib_nwdiag.egg-info/PKG-INFO sphinxcontrib_nwdiag.egg-info/SOURCES.txt sphinxcontrib_nwdiag.egg-info/dependency_links.txt sphinxcontrib_nwdiag.egg-info/namespace_packages.txt sphinxcontrib_nwdiag.egg-info/not-zip-safe sphinxcontrib_nwdiag.egg-info/requires.txt sphinxcontrib_nwdiag.egg-info/top_level.txt tests/__init__.py tests/nwdiag/__init__.py tests/nwdiag/test_basic.py tests/nwdiag/test_errors.py tests/nwdiag/test_html.py tests/nwdiag/test_latex.py tests/packetdiag/__init__.py tests/packetdiag/test_basic.py tests/packetdiag/test_errors.py tests/packetdiag/test_html.py tests/packetdiag/test_latex.py tests/rackdiag/__init__.py tests/rackdiag/test_basic.py tests/rackdiag/test_errors.py tests/rackdiag/test_html.py tests/rackdiag/test_latex.pysphinxcontrib-nwdiag-0.9.5/sphinxcontrib_nwdiag.egg-info/top_level.txt0000644000076600000240000000001612627333562027144 0ustar tkomiyastaff00000000000000sphinxcontrib sphinxcontrib-nwdiag-0.9.5/tests/0000755000076600000240000000000012627333603017636 5ustar tkomiyastaff00000000000000sphinxcontrib-nwdiag-0.9.5/tests/__init__.py0000644000076600000240000000000012627064306021736 0ustar tkomiyastaff00000000000000sphinxcontrib-nwdiag-0.9.5/tests/nwdiag/0000755000076600000240000000000012627333603021107 5ustar tkomiyastaff00000000000000sphinxcontrib-nwdiag-0.9.5/tests/nwdiag/__init__.py0000644000076600000240000000000012627064306023207 0ustar tkomiyastaff00000000000000sphinxcontrib-nwdiag-0.9.5/tests/nwdiag/test_basic.py0000644000076600000240000000133712627064306023606 0ustar tkomiyastaff00000000000000# -*- coding: utf-8 -*- from sphinx_testing import with_app @with_app(buildername='html', srcdir='tests/docs/nwdiag/') def test_build_html(app, status, warning): app.builder.build_all() @with_app(buildername='singlehtml', srcdir='tests/docs/nwdiag/') def test_build_singlehtml(app, status, warning): app.builder.build_all() @with_app(buildername='latex', srcdir='tests/docs/nwdiag/') def test_build_latex(app, status, warning): app.builder.build_all() @with_app(buildername='epub', srcdir='tests/docs/nwdiag/') def test_build_epub(app, status, warning): app.builder.build_all() @with_app(buildername='json', srcdir='tests/docs/nwdiag/') def test_build_json(app, status, warning): app.builder.build_all() sphinxcontrib-nwdiag-0.9.5/tests/nwdiag/test_errors.py0000644000076600000240000000410012627064306024030 0ustar tkomiyastaff00000000000000# -*- coding: utf-8 -*- from mock import patch from sphinx_testing import with_app from blockdiag.utils.compat import u import sys if sys.version_info < (2, 7): import unittest2 as unittest else: import unittest class TestSphinxcontribNwdiagErrors(unittest.TestCase): @with_app(srcdir='tests/docs/nwdiag', write_docstring=True) def test_parse_error(self, app, status, warning): """ .. nwdiag:: { network { A; B; } """ app.builder.build_all() self.assertIn('got unexpected token:', warning.getvalue()) @with_app(srcdir='tests/docs/nwdiag', confoverrides=dict(nwdiag_html_image_format='JPG')) def test_unknown_format_error(self, app, status, warning): app.builder.build_all() self.assertIn('unknown format: JPG', warning.getvalue()) @with_app(srcdir='tests/docs/nwdiag', confoverrides=dict(nwdiag_html_image_format='PDF')) def test_reportlab_not_found_error(self, app, status, warning): try: # unload reportlab and make loading it impossible sys.modules.pop('reportlab', None) path = sys.path sys.path = [] app.builder.build_all() self.assertIn('Could not output PDF format. Install reportlab.', warning.getvalue()) finally: sys.path = path @with_app(srcdir='tests/docs/nwdiag') @patch("nwdiag.utils.rst.nodes.nwdiag.processor.drawer.DiagramDraw") def test_rendering_error(self, app, status, warning, DiagramDraw): DiagramDraw.side_effect = RuntimeError("UNKNOWN ERROR!") app.builder.build_all() self.assertIn('UNKNOWN ERROR!', warning.getvalue()) @with_app(srcdir='tests/docs/nwdiag') @patch("sphinxcontrib.nwdiag.nwdiag.drawer.DiagramDraw.draw") def test_font_settings_error(self, app, status, warning, draw): draw.side_effect = UnicodeEncodeError("", u(""), 0, 0, "") app.builder.build_all() self.assertIn('UnicodeEncodeError caught (check your font settings)', warning.getvalue()) sphinxcontrib-nwdiag-0.9.5/tests/nwdiag/test_html.py0000644000076600000240000003310512627064306023467 0ustar tkomiyastaff00000000000000# -*- coding: utf-8 -*- from sphinx_testing import with_app import sys if sys.version_info < (2, 7): import unittest2 as unittest else: import unittest with_png_app = with_app(srcdir='tests/docs/nwdiag', buildername='html', write_docstring=True) with_svg_app = with_app(srcdir='tests/docs/nwdiag', buildername='html', write_docstring=True, confoverrides={ 'nwdiag_html_image_format': 'SVG', }) class TestSphinxcontribNwdiagHTML(unittest.TestCase): @with_png_app def test_build_png_image(self, app, status, warning): """ .. nwdiag:: network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_app(srcdir='tests/docs/nwdiag-subdir', buildername='html', write_docstring=True) def test_build_png_image_in_subdir(self, app, status, warning): """ .. nwdiag:: network { A; B; } """ app.builder.build_all() source = (app.outdir / 'subdir' / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_png_app def test_width_option_on_png(self, app, status, warning): """ .. nwdiag:: :width: 228 network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
' '
')) @with_png_app def test_height_option_on_png(self, app, status, warning): """ .. nwdiag:: :height: 150 network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
' '
')) @with_png_app def test_width_option_and_height_option_on_png(self, app, status, warning): """ .. nwdiag:: :width: 100 :height: 200 network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
' '
')) @with_png_app def test_scale_option_on_png(self, app, status, warning): """ .. nwdiag:: :scale: 25% network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
' '
')) @with_png_app def test_width_option_and_scale_option_on_png(self, app, status, warning): """ .. nwdiag:: :width: 228 :scale: 25% network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
' '
')) @with_png_app def test_align_option_on_png(self, app, status, warning): """ .. nwdiag:: :align: center network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_png_app def test_align_option_and_width_option_on_png(self, app, status, warning): """ .. nwdiag:: :align: center :width: 228 network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
' '' '
')) @with_png_app def test_name_option_on_png(self, app, status, warning): """ .. nwdiag:: :name: target network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_png_app def test_name_option_and_width_option_on_png(self, app, status, warning): """ .. nwdiag:: :name: target :width: 228 network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
' '
')) @with_png_app def test_href_and_scale_option_on_png(self, app, status, warning): """ .. nwdiag:: :scale: 50% network { A; B; } A [href = 'http://blockdiag.com/']; """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
' '' '' '
')) @with_png_app def test_reftarget_in_href_on_png1(self, app, status, warning): """ .. _target: heading2 --------- .. nwdiag:: network { A; B; } A [href = ':ref:`target`']; """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
' '' '
')) @with_png_app def test_reftarget_in_href_on_png2(self, app, status, warning): """ .. _hello world: heading2 --------- .. nwdiag:: network { A; B; } A [href = ':ref:`hello world`']; """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
' '' '
')) @with_png_app def test_missing_reftarget_in_href_on_png(self, app, status, warning): """ .. nwdiag:: network { A; B; } A [href = ':ref:`unknown_target`']; """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
')) self.assertIn('undefined label: unknown_target', warning.getvalue()) @with_svg_app def test_build_svg_image(self, app, status, warning): """ .. nwdiag:: network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_width_option_on_svg(self, app, status, warning): """ .. nwdiag:: :width: 228 network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_height_option_on_svg(self, app, status, warning): """ .. nwdiag:: :height: 150 network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_width_option_and_height_option_on_svg(self, app, status, warning): """ .. nwdiag:: :width: 100 :height: 200 network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_scale_option_on_svg(self, app, status, warning): """ .. nwdiag:: :scale: 25% network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_width_option_and_scale_option_on_svg(self, app, status, warning): """ .. nwdiag:: :width: 228 :scale: 25% network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_align_option_on_svg(self, app, status, warning): """ .. nwdiag:: :align: center network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_name_option_on_svg(self, app, status, warning): """ .. nwdiag:: :name: target network { A; B; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_reftarget_in_href_on_svg1(self, app, status, warning): """ .. _target: heading2 --------- .. nwdiag:: network { A; B; } A [href = ':ref:`target`']; """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\n\\s*\\n\\s*') @with_svg_app def test_reftarget_in_href_on_svg2(self, app, status, warning): """ .. _hello world: heading2 --------- .. nwdiag:: network { A; B; } A [href = ':ref:`hello world`']; """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\n\\s*\\n\\s*') @with_svg_app def test_missing_reftarget_in_href_on_svg(self, app, status, warning): """ .. nwdiag:: network { A; B; } A [href = ':ref:`unknown_target`']; """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') if sys.version_info < (3, 0): self.assertNotRegexpMatches(source, '\\n\\s*\\n\\s*') else: self.assertNotRegex(source, '\\n\\s*\\n\\s*') self.assertIn('undefined label: unknown_target', warning.getvalue()) @with_svg_app def test_autoclass_should_not_effect_to_other_diagram(self, app, status, warning): """ This testcase checks that autoclass plugin is unloaded correctly (and it does not effect to other diagram). .. nwdiag:: plugin autoclass; class foo [color = red]; network { A_foo; } .. nwdiag:: class foo [color = red]; network { A_foo; } """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ']+>A_foo') # 2nd diagram has a node labeled 'A_foo'. �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������sphinxcontrib-nwdiag-0.9.5/tests/nwdiag/test_latex.py�����������������������������������������������0000644�0000766�0000024�00000015121�12627064306�023636� 0����������������������������������������������������������������������������������������������������ustar �tkomiya�������������������������staff���������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- import os import re from sphinx_testing import with_app from blockdiag.utils.compat import u import sys if sys.version_info < (2, 7): import unittest2 as unittest else: import unittest nwdiag_fontpath = '/usr/share/fonts/truetype/ipafont/ipagp.ttf' with_png_app = with_app(srcdir='tests/docs/nwdiag', buildername='latex', write_docstring=True, confoverrides={ 'latex_documents': [('index', 'test.tex', u(''), u('test'), 'manual')], }) with_pdf_app = with_app(srcdir='tests/docs/nwdiag', buildername='latex', write_docstring=True, confoverrides={ 'latex_documents': [('index', 'test.tex', u(''), u('test'), 'manual')], 'nwdiag_latex_image_format': 'PDF', 'nwdiag_fontpath': nwdiag_fontpath, }) with_oldpdf_app = with_app(srcdir='tests/docs/nwdiag', buildername='latex', write_docstring=True, confoverrides={ 'latex_documents': [('index', 'test.tex', u(''), u('test'), 'manual')], 'nwdiag_tex_image_format': 'PDF', 'nwdiag_fontpath': nwdiag_fontpath, }) class TestSphinxcontribNwdiagLatex(unittest.TestCase): @with_png_app def test_build_png_image(self, app, status, warning): """ .. nwdiag:: network { A; B; } """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{nwdiag-.*?.png}') @unittest.skipUnless(os.path.exists(nwdiag_fontpath), "TrueType font not found") @unittest.skipIf(sys.version_info[:2] == (3, 2), "reportlab does not support python 3.2") @with_pdf_app def test_build_pdf_image1(self, app, status, warning): """ .. nwdiag:: network { A; B; } """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{nwdiag-.*?.pdf}') @unittest.skipUnless(os.path.exists(nwdiag_fontpath), "TrueType font not found") @unittest.skipIf(sys.version_info[:2] == (3, 2), "reportlab does not support python 3.2") @with_oldpdf_app def test_build_pdf_image2(self, app, status, warning): """ .. nwdiag:: network { A; B; } """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{nwdiag-.*?.pdf}') @with_png_app def test_width_option(self, app, status, warning): """ .. nwdiag:: :width: 3cm network { A; B; } """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics\\[width=3cm\\]{nwdiag-.*?.png}') @with_png_app def test_height_option(self, app, status, warning): """ .. nwdiag:: :height: 4cm network { A; B; } """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics\\[height=4cm\\]{nwdiag-.*?.png}') @with_png_app def test_scale_option(self, app, status, warning): """ .. nwdiag:: :scale: 50% network { A; B; } """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\scalebox{0.500000}{\\\\includegraphics{nwdiag-.*?.png}}') @with_png_app def test_align_option_left(self, app, status, warning): """ .. nwdiag:: :align: left network { A; B; } """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '{\\\\includegraphics{nwdiag-.*?.png}\\\\hfill}') @with_png_app def test_align_option_center(self, app, status, warning): """ .. nwdiag:: :align: center network { A; B; } """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '{\\\\hfill\\\\includegraphics{nwdiag-.*?.png}\\\\hfill}') @with_png_app def test_align_option_right(self, app, status, warning): """ .. nwdiag:: :align: right network { A; B; } """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '{\\\\hfill\\\\includegraphics{nwdiag-.*?.png}}') @with_png_app def test_caption_option(self, app, status, warning): """ .. nwdiag:: :caption: hello world network { A; B; } """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{nwdiag-.*?.png}') figure = re.compile('\\\\begin{figure}\\[htbp\\]\r?\n\\\\centering.*?' '\\\\caption{hello world}\\\\end{figure}', re.DOTALL) self.assertRegexpMatches(source, figure) @with_png_app def test_caption_option_and_align_option(self, app, status, warning): """ .. nwdiag:: :align: left :caption: hello world network { A; B; } """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{nwdiag-.*?.png}') figure = re.compile('\\\\begin{figure}\\[htbp\\]\\\\begin{flushleft}.*?' '\\\\caption{hello world}\\\\end{flushleft}\\\\end{figure}', re.DOTALL) self.assertRegexpMatches(source, figure) @with_png_app def test_href(self, app, status, warning): """ .. nwdiag:: network { A; B; } A [href = ':ref:`target`']; """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{nwdiag-.*?.png}') �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������sphinxcontrib-nwdiag-0.9.5/tests/packetdiag/��������������������������������������������������������0000755�0000766�0000024�00000000000�12627333603�021732� 5����������������������������������������������������������������������������������������������������ustar �tkomiya�������������������������staff���������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������sphinxcontrib-nwdiag-0.9.5/tests/packetdiag/__init__.py���������������������������������������������0000644�0000766�0000024�00000000000�12627064306�024032� 0����������������������������������������������������������������������������������������������������ustar �tkomiya�������������������������staff���������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������sphinxcontrib-nwdiag-0.9.5/tests/packetdiag/test_basic.py�������������������������������������������0000644�0000766�0000024�00000001363�12627064306�024430� 0����������������������������������������������������������������������������������������������������ustar �tkomiya�������������������������staff���������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- from sphinx_testing import with_app @with_app(buildername='html', srcdir='tests/docs/packetdiag/') def test_build_html(app, status, warning): app.builder.build_all() @with_app(buildername='singlehtml', srcdir='tests/docs/packetdiag/') def test_build_singlehtml(app, status, warning): app.builder.build_all() @with_app(buildername='latex', srcdir='tests/docs/packetdiag/') def test_build_latex(app, status, warning): app.builder.build_all() @with_app(buildername='epub', srcdir='tests/docs/packetdiag/') def test_build_epub(app, status, warning): app.builder.build_all() @with_app(buildername='json', srcdir='tests/docs/packetdiag/') def test_build_json(app, status, warning): app.builder.build_all() �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������sphinxcontrib-nwdiag-0.9.5/tests/packetdiag/test_errors.py������������������������������������������0000644�0000766�0000024�00000004204�12627064306�024660� 0����������������������������������������������������������������������������������������������������ustar �tkomiya�������������������������staff���������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- from mock import patch from sphinx_testing import with_app from blockdiag.utils.compat import u import sys if sys.version_info < (2, 7): import unittest2 as unittest else: import unittest class TestSphinxcontribPacketdiagErrors(unittest.TestCase): @with_app(srcdir='tests/docs/packetdiag', write_docstring=True) def test_parse_error(self, app, status, warning): """ .. packetdiag:: { * A * B """ app.builder.build_all() self.assertIn('got unexpected token:', warning.getvalue()) @with_app(srcdir='tests/docs/packetdiag', confoverrides=dict(packetdiag_html_image_format='JPG')) def test_unknown_format_error(self, app, status, warning): app.builder.build_all() self.assertIn('unknown format: JPG', warning.getvalue()) @with_app(srcdir='tests/docs/packetdiag', confoverrides=dict(packetdiag_html_image_format='PDF')) def test_reportlab_not_found_error(self, app, status, warning): try: # unload reportlab and make loading it impossible sys.modules.pop('reportlab', None) path = sys.path sys.path = [] app.builder.build_all() self.assertIn('Could not output PDF format. Install reportlab.', warning.getvalue()) finally: sys.path = path @with_app(srcdir='tests/docs/packetdiag') @patch("packetdiag.utils.rst.nodes.packetdiag.processor.drawer.DiagramDraw") def test_rendering_error(self, app, status, warning, DiagramDraw): DiagramDraw.side_effect = RuntimeError("UNKNOWN ERROR!") app.builder.build_all() self.assertIn('UNKNOWN ERROR!', warning.getvalue()) @with_app(srcdir='tests/docs/packetdiag') @patch("sphinxcontrib.packetdiag.packetdiag.drawer.DiagramDraw.draw") def test_font_settings_error(self, app, status, warning, draw): draw.side_effect = UnicodeEncodeError("", u(""), 0, 0, "") app.builder.build_all() self.assertIn('UnicodeEncodeError caught (check your font settings)', warning.getvalue()) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������sphinxcontrib-nwdiag-0.9.5/tests/packetdiag/test_html.py��������������������������������������������0000644�0000766�0000024�00000032661�12627064306�024320� 0����������������������������������������������������������������������������������������������������ustar �tkomiya�������������������������staff���������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- from sphinx_testing import with_app import sys if sys.version_info < (2, 7): import unittest2 as unittest else: import unittest with_png_app = with_app(srcdir='tests/docs/packetdiag', buildername='html', write_docstring=True) with_svg_app = with_app(srcdir='tests/docs/packetdiag', buildername='html', write_docstring=True, confoverrides={ 'packetdiag_html_image_format': 'SVG', }) class TestSphinxcontribPacketdiagHTML(unittest.TestCase): @with_png_app def test_build_png_image(self, app, status, warning): """ .. packetdiag:: * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_app(srcdir='tests/docs/packetdiag-subdir', buildername='html', write_docstring=True) def test_build_png_image_in_subdir(self, app, status, warning): """ .. packetdiag:: * A * B """ app.builder.build_all() source = (app.outdir / 'subdir' / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_png_app def test_width_option_on_png(self, app, status, warning): """ .. packetdiag:: :width: 88 * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('')) @with_png_app def test_height_option_on_png(self, app, status, warning): """ .. packetdiag:: :height: 80 * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('')) @with_png_app def test_width_option_and_height_option_on_png(self, app, status, warning): """ .. packetdiag:: :width: 100 :height: 200 * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('')) @with_png_app def test_scale_option_on_png(self, app, status, warning): """ .. packetdiag:: :scale: 25% * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('')) @with_png_app def test_width_option_and_scale_option_on_png(self, app, status, warning): """ .. packetdiag:: :width: 88 :scale: 25% * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('')) @with_png_app def test_align_option_on_png(self, app, status, warning): """ .. packetdiag:: :align: center * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_png_app def test_align_option_and_width_option_on_png(self, app, status, warning): """ .. packetdiag:: :align: center :width: 88 * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
' '' '
')) @with_png_app def test_name_option_on_png(self, app, status, warning): """ .. packetdiag:: :name: target * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_png_app def test_name_option_and_width_option_on_png(self, app, status, warning): """ .. packetdiag:: :name: target :width: 88 * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('')) @with_png_app def test_href_and_scale_option_on_png(self, app, status, warning): """ .. packetdiag:: :scale: 50% * A [href = 'http://blockdiag.com/']; * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('')) @with_png_app def test_reftarget_in_href_on_png1(self, app, status, warning): """ .. _target: heading2 --------- .. packetdiag:: * A [href = ':ref:`target`']; * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
' '' '
')) @with_png_app def test_reftarget_in_href_on_png2(self, app, status, warning): """ .. _hello world: heading2 --------- .. packetdiag:: * A [href = ':ref:`hello world`']; * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
' '' '
')) @with_png_app def test_missing_reftarget_in_href_on_png(self, app, status, warning): """ .. packetdiag:: * A [href = ':ref:`unknown_target`']; * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
')) self.assertIn('undefined label: unknown_target', warning.getvalue()) @with_svg_app def test_build_svg_image(self, app, status, warning): """ .. packetdiag:: * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_width_option_on_svg(self, app, status, warning): """ .. packetdiag:: :width: 88 * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_height_option_on_svg(self, app, status, warning): """ .. packetdiag:: :height: 80 * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_width_option_and_height_option_on_svg(self, app, status, warning): """ .. packetdiag:: :width: 100 :height: 200 * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_scale_option_on_svg(self, app, status, warning): """ .. packetdiag:: :scale: 25% * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_width_option_and_scale_option_on_svg(self, app, status, warning): """ .. packetdiag:: :width: 88 :scale: 25% * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_align_option_on_svg(self, app, status, warning): """ .. packetdiag:: :align: center * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_name_option_on_svg(self, app, status, warning): """ .. packetdiag:: :name: target * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_reftarget_in_href_on_svg1(self, app, status, warning): """ .. _target: heading2 --------- .. packetdiag:: * A [href = ':ref:`target`']; * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\n\\s*') @with_svg_app def test_reftarget_in_href_on_svg2(self, app, status, warning): """ .. _hello world: heading2 --------- .. packetdiag:: * A [href = ':ref:`hello world`']; * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\n\\s*') @with_svg_app def test_missing_reftarget_in_href_on_svg(self, app, status, warning): """ .. packetdiag:: * A [href = ':ref:`unknown_target`']; * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') if sys.version_info < (3, 0): self.assertNotRegexpMatches(source, '\\n\\s*') else: self.assertNotRegex(source, '\\n\\s*') self.assertIn('undefined label: unknown_target', warning.getvalue()) @with_svg_app def test_attribute_plugin_should_not_effect_to_other_diagram(self, app, status, warning): """ This testcase checks that attribute plugin is unloaded correctly (and it does not effect to other diagram). .. packetdiag:: plugin attributes [property]; * A_foo [property = foo] .. packetdiag:: * A_foo [property = foo] """ app.builder.build_all() self.assertIn('Unknown attribute: FieldItem.property', warning.getvalue()) �������������������������������������������������������������������������������sphinxcontrib-nwdiag-0.9.5/tests/packetdiag/test_latex.py�������������������������������������������0000644�0000766�0000024�00000015343�12627064306�024467� 0����������������������������������������������������������������������������������������������������ustar �tkomiya�������������������������staff���������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- import os import re from sphinx_testing import with_app from blockdiag.utils.compat import u import sys if sys.version_info < (2, 7): import unittest2 as unittest else: import unittest packetdiag_fontpath = '/usr/share/fonts/truetype/ipafont/ipagp.ttf' with_png_app = with_app(srcdir='tests/docs/packetdiag', buildername='latex', write_docstring=True, confoverrides={ 'latex_documents': [('index', 'test.tex', u(''), u('test'), 'manual')], }) with_pdf_app = with_app(srcdir='tests/docs/packetdiag', buildername='latex', write_docstring=True, confoverrides={ 'latex_documents': [('index', 'test.tex', u(''), u('test'), 'manual')], 'packetdiag_latex_image_format': 'PDF', 'packetdiag_fontpath': packetdiag_fontpath, }) with_oldpdf_app = with_app(srcdir='tests/docs/packetdiag', buildername='latex', write_docstring=True, confoverrides={ 'latex_documents': [('index', 'test.tex', u(''), u('test'), 'manual')], 'packetdiag_tex_image_format': 'PDF', 'packetdiag_fontpath': packetdiag_fontpath, }) class TestSphinxcontribPacketdiagLatex(unittest.TestCase): @with_png_app def test_build_png_image(self, app, status, warning): """ .. packetdiag:: * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{packetdiag-.*?.png}') @unittest.skipUnless(os.path.exists(packetdiag_fontpath), "TrueType font not found") @unittest.skipIf(sys.version_info[:2] == (3, 2), "reportlab does not support python 3.2") @with_pdf_app def test_build_pdf_image1(self, app, status, warning): """ .. packetdiag:: * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{packetdiag-.*?.pdf}') @unittest.skipUnless(os.path.exists(packetdiag_fontpath), "TrueType font not found") @unittest.skipIf(sys.version_info[:2] == (3, 2), "reportlab does not support python 3.2") @with_oldpdf_app def test_build_pdf_image2(self, app, status, warning): """ .. packetdiag:: * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{packetdiag-.*?.pdf}') @with_png_app def test_width_option(self, app, status, warning): """ .. packetdiag:: :width: 3cm * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics\\[width=3cm\\]{packetdiag-.*?.png}') @with_png_app def test_height_option(self, app, status, warning): """ .. packetdiag:: :height: 4cm * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics\\[height=4cm\\]{packetdiag-.*?.png}') @with_png_app def test_scale_option(self, app, status, warning): """ .. packetdiag:: :scale: 50% * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\scalebox{0.500000}{\\\\includegraphics{packetdiag-.*?.png}}') @with_png_app def test_align_option_left(self, app, status, warning): """ .. packetdiag:: :align: left * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '{\\\\includegraphics{packetdiag-.*?.png}\\\\hfill}') @with_png_app def test_align_option_center(self, app, status, warning): """ .. packetdiag:: :align: center * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '{\\\\hfill\\\\includegraphics{packetdiag-.*?.png}\\\\hfill}') @with_png_app def test_align_option_right(self, app, status, warning): """ .. packetdiag:: :align: right * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '{\\\\hfill\\\\includegraphics{packetdiag-.*?.png}}') @with_png_app def test_caption_option(self, app, status, warning): """ .. packetdiag:: :caption: hello world * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{packetdiag-.*?.png}') figure = re.compile('\\\\begin{figure}\\[htbp\\]\r?\n\\\\centering.*?' '\\\\caption{hello world}\\\\end{figure}', re.DOTALL) self.assertRegexpMatches(source, figure) @with_png_app def test_caption_option_and_align_option(self, app, status, warning): """ .. packetdiag:: :align: left :caption: hello world * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{packetdiag-.*?.png}') figure = re.compile('\\\\begin{figure}\\[htbp\\]\\\\begin{flushleft}.*?' '\\\\caption{hello world}\\\\end{flushleft}\\\\end{figure}', re.DOTALL) self.assertRegexpMatches(source, figure) @with_png_app def test_href(self, app, status, warning): """ .. packetdiag:: * A [href = ':ref:`target`'] * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{packetdiag-.*?.png}') ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������sphinxcontrib-nwdiag-0.9.5/tests/rackdiag/����������������������������������������������������������0000755�0000766�0000024�00000000000�12627333603�021403� 5����������������������������������������������������������������������������������������������������ustar �tkomiya�������������������������staff���������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������sphinxcontrib-nwdiag-0.9.5/tests/rackdiag/__init__.py�����������������������������������������������0000644�0000766�0000024�00000000000�12627064306�023503� 0����������������������������������������������������������������������������������������������������ustar �tkomiya�������������������������staff���������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������sphinxcontrib-nwdiag-0.9.5/tests/rackdiag/test_basic.py���������������������������������������������0000644�0000766�0000024�00000001351�12627064306�024076� 0����������������������������������������������������������������������������������������������������ustar �tkomiya�������������������������staff���������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- from sphinx_testing import with_app @with_app(buildername='html', srcdir='tests/docs/rackdiag/') def test_build_html(app, status, warning): app.builder.build_all() @with_app(buildername='singlehtml', srcdir='tests/docs/rackdiag/') def test_build_singlehtml(app, status, warning): app.builder.build_all() @with_app(buildername='latex', srcdir='tests/docs/rackdiag/') def test_build_latex(app, status, warning): app.builder.build_all() @with_app(buildername='epub', srcdir='tests/docs/rackdiag/') def test_build_epub(app, status, warning): app.builder.build_all() @with_app(buildername='json', srcdir='tests/docs/rackdiag/') def test_build_json(app, status, warning): app.builder.build_all() ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������sphinxcontrib-nwdiag-0.9.5/tests/rackdiag/test_errors.py��������������������������������������������0000644�0000766�0000024�00000004152�12627064306�024333� 0����������������������������������������������������������������������������������������������������ustar �tkomiya�������������������������staff���������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- from mock import patch from sphinx_testing import with_app from blockdiag.utils.compat import u import sys if sys.version_info < (2, 7): import unittest2 as unittest else: import unittest class TestSphinxcontribRackdiagErrors(unittest.TestCase): @with_app(srcdir='tests/docs/rackdiag', write_docstring=True) def test_parse_error(self, app, status, warning): """ .. rackdiag:: { * A * B """ app.builder.build_all() self.assertIn('got unexpected token:', warning.getvalue()) @with_app(srcdir='tests/docs/rackdiag', confoverrides=dict(rackdiag_html_image_format='JPG')) def test_unknown_format_error(self, app, status, warning): app.builder.build_all() self.assertIn('unknown format: JPG', warning.getvalue()) @with_app(srcdir='tests/docs/rackdiag', confoverrides=dict(rackdiag_html_image_format='PDF')) def test_reportlab_not_found_error(self, app, status, warning): try: # unload reportlab and make loading it impossible sys.modules.pop('reportlab', None) path = sys.path sys.path = [] app.builder.build_all() self.assertIn('Could not output PDF format. Install reportlab.', warning.getvalue()) finally: sys.path = path @with_app(srcdir='tests/docs/rackdiag') @patch("rackdiag.utils.rst.nodes.rackdiag.processor.drawer.DiagramDraw") def test_rendering_error(self, app, status, warning, DiagramDraw): DiagramDraw.side_effect = RuntimeError("UNKNOWN ERROR!") app.builder.build_all() self.assertIn('UNKNOWN ERROR!', warning.getvalue()) @with_app(srcdir='tests/docs/rackdiag') @patch("sphinxcontrib.rackdiag.rackdiag.drawer.DiagramDraw.draw") def test_font_settings_error(self, app, status, warning, draw): draw.side_effect = UnicodeEncodeError("", u(""), 0, 0, "") app.builder.build_all() self.assertIn('UnicodeEncodeError caught (check your font settings)', warning.getvalue()) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������sphinxcontrib-nwdiag-0.9.5/tests/rackdiag/test_html.py����������������������������������������������0000644�0000766�0000024�00000033121�12627064306�023761� 0����������������������������������������������������������������������������������������������������ustar �tkomiya�������������������������staff���������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- from sphinx_testing import with_app import sys if sys.version_info < (2, 7): import unittest2 as unittest else: import unittest with_png_app = with_app(srcdir='tests/docs/rackdiag', buildername='html', write_docstring=True) with_svg_app = with_app(srcdir='tests/docs/rackdiag', buildername='html', write_docstring=True, confoverrides={ 'rackdiag_html_image_format': 'SVG', }) class TestSphinxcontribRackdiagHTML(unittest.TestCase): @with_png_app def test_build_png_image(self, app, status, warning): """ .. rackdiag:: * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_app(srcdir='tests/docs/rackdiag-subdir', buildername='html', write_docstring=True) def test_build_png_image_in_subdir(self, app, status, warning): """ .. rackdiag:: * A * B """ app.builder.build_all() source = (app.outdir / 'subdir' / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_png_app def test_width_option_on_png(self, app, status, warning): """ .. rackdiag:: :width: 128 * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('')) @with_png_app def test_height_option_on_png(self, app, status, warning): """ .. rackdiag:: :height: 880 * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('')) @with_png_app def test_width_option_and_height_option_on_png(self, app, status, warning): """ .. rackdiag:: :width: 100 :height: 200 * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('')) @with_png_app def test_scale_option_on_png(self, app, status, warning): """ .. rackdiag:: :scale: 25% * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('')) @with_png_app def test_width_option_and_scale_option_on_png(self, app, status, warning): """ .. rackdiag:: :width: 128 :scale: 25% * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('')) @with_png_app def test_align_option_on_png(self, app, status, warning): """ .. rackdiag:: :align: center * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_png_app def test_align_option_and_width_option_on_png(self, app, status, warning): """ .. rackdiag:: :align: center :width: 128 * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
' '' '
')) @with_png_app def test_name_option_on_png(self, app, status, warning): """ .. rackdiag:: :name: target * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_png_app def test_name_option_and_width_option_on_png(self, app, status, warning): """ .. rackdiag:: :name: target :width: 128 * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('')) @with_png_app def test_href_and_scale_option_on_png(self, app, status, warning): """ .. rackdiag:: :scale: 50% * A [href = 'http://blockdiag.com/']; * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('')) @with_png_app def test_reftarget_in_href_on_png1(self, app, status, warning): """ .. _target: heading2 --------- .. rackdiag:: * A [href = ':ref:`target`']; * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
' '' '
')) @with_png_app def test_reftarget_in_href_on_png2(self, app, status, warning): """ .. _hello world: heading2 --------- .. rackdiag:: * A [href = ':ref:`hello world`']; * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
' '' '
')) @with_png_app def test_missing_reftarget_in_href_on_png(self, app, status, warning): """ .. rackdiag:: * A [href = ':ref:`unknown_target`']; * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('
')) self.assertIn('undefined label: unknown_target', warning.getvalue()) @with_svg_app def test_build_svg_image(self, app, status, warning): """ .. rackdiag:: * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_width_option_on_svg(self, app, status, warning): """ .. rackdiag:: :width: 128 * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_height_option_on_svg(self, app, status, warning): """ .. rackdiag:: :height: 880 * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_width_option_and_height_option_on_svg(self, app, status, warning): """ .. rackdiag:: :width: 100 :height: 200 * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_scale_option_on_svg(self, app, status, warning): """ .. rackdiag:: :scale: 25% * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_width_option_and_scale_option_on_svg(self, app, status, warning): """ .. rackdiag:: :width: 128 :scale: 25% * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_align_option_on_svg(self, app, status, warning): """ .. rackdiag:: :align: center * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_name_option_on_svg(self, app, status, warning): """ .. rackdiag:: :name: target * A * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, '
') @with_svg_app def test_reftarget_in_href_on_svg1(self, app, status, warning): """ .. _target: heading2 --------- .. rackdiag:: * A [href = ':ref:`target`']; * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('\\n\\s*\\n' '\\s*A\\n\\s*')) @with_svg_app def test_reftarget_in_href_on_svg2(self, app, status, warning): """ .. _hello world: heading2 --------- .. rackdiag:: * A [href = ':ref:`hello world`']; * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') self.assertRegexpMatches(source, ('\\n\\s*\\n' '\\s*A\\n\\s*')) @with_svg_app def test_missing_reftarget_in_href_on_svg(self, app, status, warning): """ .. rackdiag:: * A [href = ':ref:`unknown_target`']; * B """ app.builder.build_all() source = (app.outdir / 'index.html').read_text(encoding='utf-8') if sys.version_info < (3, 0): self.assertNotRegexpMatches(source, '\\n\\s*\\n\\s*') else: self.assertNotRegex(source, '\\n\\s*\\n\\s*') self.assertIn('undefined label: unknown_target', warning.getvalue()) @with_svg_app def test_attribute_plugin_should_not_effect_to_other_diagram(self, app, status, warning): """ This testcase checks that attribute plugin is unloaded correctly (and it does not effect to other diagram). .. rackdiag:: plugin attributes [property]; * A_foo [property = foo] .. rackdiag:: * A_foo [property = foo] """ app.builder.build_all() self.assertIn('Unknown attribute: RackItem.property', warning.getvalue()) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������sphinxcontrib-nwdiag-0.9.5/tests/rackdiag/test_latex.py���������������������������������������������0000644�0000766�0000024�00000015231�12627064306�024134� 0����������������������������������������������������������������������������������������������������ustar �tkomiya�������������������������staff���������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- coding: utf-8 -*- import os import re from sphinx_testing import with_app from blockdiag.utils.compat import u import sys if sys.version_info < (2, 7): import unittest2 as unittest else: import unittest rackdiag_fontpath = '/usr/share/fonts/truetype/ipafont/ipagp.ttf' with_png_app = with_app(srcdir='tests/docs/rackdiag', buildername='latex', write_docstring=True, confoverrides={ 'latex_documents': [('index', 'test.tex', u(''), u('test'), 'manual')], }) with_pdf_app = with_app(srcdir='tests/docs/rackdiag', buildername='latex', write_docstring=True, confoverrides={ 'latex_documents': [('index', 'test.tex', u(''), u('test'), 'manual')], 'rackdiag_latex_image_format': 'PDF', 'rackdiag_fontpath': rackdiag_fontpath, }) with_oldpdf_app = with_app(srcdir='tests/docs/rackdiag', buildername='latex', write_docstring=True, confoverrides={ 'latex_documents': [('index', 'test.tex', u(''), u('test'), 'manual')], 'rackdiag_tex_image_format': 'PDF', 'rackdiag_fontpath': rackdiag_fontpath, }) class TestSphinxcontribRackdiagLatex(unittest.TestCase): @with_png_app def test_build_png_image(self, app, status, warning): """ .. rackdiag:: * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{rackdiag-.*?.png}') @unittest.skipUnless(os.path.exists(rackdiag_fontpath), "TrueType font not found") @unittest.skipIf(sys.version_info[:2] == (3, 2), "reportlab does not support python 3.2") @with_pdf_app def test_build_pdf_image1(self, app, status, warning): """ .. rackdiag:: * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{rackdiag-.*?.pdf}') @unittest.skipUnless(os.path.exists(rackdiag_fontpath), "TrueType font not found") @unittest.skipIf(sys.version_info[:2] == (3, 2), "reportlab does not support python 3.2") @with_oldpdf_app def test_build_pdf_image2(self, app, status, warning): """ .. rackdiag:: * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{rackdiag-.*?.pdf}') @with_png_app def test_width_option(self, app, status, warning): """ .. rackdiag:: :width: 3cm * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics\\[width=3cm\\]{rackdiag-.*?.png}') @with_png_app def test_height_option(self, app, status, warning): """ .. rackdiag:: :height: 4cm * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics\\[height=4cm\\]{rackdiag-.*?.png}') @with_png_app def test_scale_option(self, app, status, warning): """ .. rackdiag:: :scale: 50% * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\scalebox{0.500000}{\\\\includegraphics{rackdiag-.*?.png}}') @with_png_app def test_align_option_left(self, app, status, warning): """ .. rackdiag:: :align: left * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '{\\\\includegraphics{rackdiag-.*?.png}\\\\hfill}') @with_png_app def test_align_option_center(self, app, status, warning): """ .. rackdiag:: :align: center * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '{\\\\hfill\\\\includegraphics{rackdiag-.*?.png}\\\\hfill}') @with_png_app def test_align_option_right(self, app, status, warning): """ .. rackdiag:: :align: right * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '{\\\\hfill\\\\includegraphics{rackdiag-.*?.png}}') @with_png_app def test_caption_option(self, app, status, warning): """ .. rackdiag:: :caption: hello world * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{rackdiag-.*?.png}') figure = re.compile('\\\\begin{figure}\\[htbp\\]\r?\n\\\\centering.*?' '\\\\caption{hello world}\\\\end{figure}', re.DOTALL) self.assertRegexpMatches(source, figure) @with_png_app def test_caption_option_and_align_option(self, app, status, warning): """ .. rackdiag:: :align: left :caption: hello world * A * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{rackdiag-.*?.png}') figure = re.compile('\\\\begin{figure}\\[htbp\\]\\\\begin{flushleft}.*?' '\\\\caption{hello world}\\\\end{flushleft}\\\\end{figure}', re.DOTALL) self.assertRegexpMatches(source, figure) @with_png_app def test_href(self, app, status, warning): """ .. rackdiag:: * A [href = ':ref:`target`'] * B """ app.builder.build_all() source = (app.outdir / 'test.tex').read_text(encoding='utf-8') self.assertRegexpMatches(source, '\\\\includegraphics{rackdiag-.*?.png}') �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������