def visit_html(builder, node):
        """Wrap the standard graphviz output to provide alignment for svg.

        At present the ``align`` option for ``sphinx.ext.graphviz`` directives
        does nothing for html output when ``graphviz_output_format`` is set to
        ``svg``. This method wraps the html output to provide alignment
        capability.

        """
        # Alignment.
        try:
            align = node['align']
        except KeyError:
            align = 'center'
        style = 'text-align: %s;' % align

        # Theme.
        theme = node.get('theme', 'default')

        # Graphing.
        data = '//'.join(node['graph_lines'])

        # Construct <div> element.
        builder.body.append(
            ('<div class="minicylc" style="{0}" data-dependencies="{1}" '
             'data-theme="{2}" >').format(style, data, theme))

        # Call graphviz html builder.
        try:
            # This method raises nodes.SkipNode in the success and fail case!
            html_visit_graphviz(builder, node)
        except nodes.SkipNode:
            # Close <div> element (we are not using an exit_html function.
            builder.body.append('</div>')
            raise
Exemplo n.º 2
0
    def visit_html(builder, node):
        """Wrap the standard graphviz output to provide alignment for svg.

        At present the ``align`` option for ``sphinx.ext.graphviz`` directives
        does nothing for html output when ``graphviz_output_format`` is set to
        ``svg``. This method wraps the html output to provide alignment
        capability.

        """
        # Alignment.
        try:
            align = node['align']
        except KeyError:
            align = 'center'
        style = 'text-align: %s;' % align

        # Theme.
        theme = node.get('theme', 'default')

        # Graphing.
        data = '//'.join(node['graph_lines'])

        # Construct <div> element.
        builder.body.append(
            ('<div class="minicylc" style="{0}" data-dependencies="{1}" '
             'data-theme="{2}" >').format(style, data, theme))

        # Call graphviz html builder.
        try:
            # This method raises nodes.SkipNode in the success and fail case!
            html_visit_graphviz(builder, node)
        except nodes.SkipNode:
            # Close <div> element (we are not using an exit_html function.
            builder.body.append('</div>')
            raise
def visit_gdot_node_html(self, node):
    """
    visit collapse_node, the function switches between
    `graphviz.py <https://github.com/sphinx-doc/sphinx/blob/
    master/sphinx/ext/graphviz.py>`_ and the :epkg:`SVG` format.
    """
    if node['format'].lower() == 'png':
        from sphinx.ext.graphviz import html_visit_graphviz
        return html_visit_graphviz(self, node)
    if node['format'].lower() in ('?', 'svg'):
        return visit_gdot_node_html_svg(self, node)
    raise RuntimeError("Unexpected format for graphviz '{}'.".format(
        node['format']))