sphinxext.plot_workflow

Module: sphinxext.plot_workflow

Inheritance diagram for nipype.sphinxext.plot_workflow:

Inheritance diagram of nipype.sphinxext.plot_workflow

nipype.sphinxext.plot_workflow – Workflow plotting extension

A directive for including a nipype workflow graph in a Sphinx document.

This code is forked from the plot_figure sphinx extension of matplotlib.

By default, in HTML output, workflow will include a .png file with a link to a high-res .png. In LaTeX output, it will include a .pdf. The source code for the workflow may be included as inline content to the directive workflow:

.. workflow ::
    :graph2use: flat
    :simple_form: no

    from nipype.workflows.dmri.camino.connectivity_mapping import create_connectivity_pipeline
    wf = create_connectivity_pipeline()

For example, the following graph has been generated inserting the previous code block in this documentation:

../../_images/nipype-sphinxext-plot_workflow-1.png

(Source code, png, svg, pdf)

Options

The workflow directive supports the following options:
graph2use : {‘hierarchical’, ‘colored’, ‘flat’, ‘orig’, ‘exec’}
Specify the type of graph to be generated.
simple_form: bool
Whether the graph will be in detailed or simple form.
format : {‘python’, ‘doctest’}
Specify the format of the input
include-source : bool
Whether to display the source code. The default can be changed using the workflow_include_source variable in conf.py
encoding : str
If this source file is in a non-UTF8 or non-ASCII encoding, the encoding must be specified using the :encoding: option. The encoding will not be inferred using the -*- coding -*- metacomment.

Additionally, this directive supports all of the options of the image directive, except for target (since workflow will add its own target). These include alt, height, width, scale, align and class.

Configuration options

The workflow directive has the following configuration options:
graph2use
Select a graph type to use
simple_form
determines if the node name shown in the visualization is either of the form nodename (package) when set to True or nodename.Class.package when set to False.
wf_include_source
Default value for the include-source option
wf_html_show_source_link
Whether to show a link to the source in HTML.
wf_pre_code
Code that should be executed before each workflow.
wf_basedir
Base directory, to which workflow:: file names are relative to. (If None or empty, file names are relative to the directory where the file containing the directive is.)
wf_formats
File formats to generate. List of tuples or strings::
[(suffix, dpi), suffix, …]

that determine the file format and the DPI. For entries whose DPI was omitted, sensible defaults are chosen. When passing from the command line through sphinx_build the list should be passed as suffix:dpi,suffix:dpi, ….

wf_html_show_formats
Whether to show links to the files in HTML.
wf_rcparams
A dictionary containing any non-standard rcParams that should be applied before each workflow.
wf_apply_rcparams
By default, rcParams are applied when context option is not used in a workflow directive. This configuration option overrides this behavior and applies rcParams before each workflow.
wf_working_directory
By default, the working directory will be changed to the directory of the example, so the code can get at its data files, if any. Also its path will be added to sys.path so it can import any helper modules sitting beside it. This configuration option can be used to specify a central directory (also added to sys.path) where data files and helper modules for all code are located.
wf_template
Provide a customized template for preparing restructured text.

Classes

GraphError

class nipype.sphinxext.plot_workflow.GraphError

Bases: RuntimeError

Attributes:
args

Methods

with_traceback() Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
__init__(self, /, *args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

ImageFile

class nipype.sphinxext.plot_workflow.ImageFile(basename, dirname)

Bases: object

Methods

filename  
filenames  
__init__(self, basename, dirname)

Initialize self. See help(type(self)) for accurate signature.

filename(self, fmt)
filenames(self)

Functions

nipype.sphinxext.plot_workflow.contains_doctest(text)
nipype.sphinxext.plot_workflow.get_wf_formats(config)
nipype.sphinxext.plot_workflow.mark_wf_labels(app, document)

To make graphs referenceable, we need to move the reference from the “htmlonly” (or “latexonly”) node to the actual figure node itself.

nipype.sphinxext.plot_workflow.out_of_date(original, derived)

Returns True if derivative is out-of-date wrt original, both of which are full file paths.

nipype.sphinxext.plot_workflow.remove_coding(text)

Remove the coding comment, which exec doesn’t like.

nipype.sphinxext.plot_workflow.render_figures(code, code_path, output_dir, output_base, context, function_name, config, graph2use, simple_form, context_reset=False, close_figs=False)

Run a nipype workflow creation script and save the graph in output_dir. Save the images under output_dir with file names derived from output_base

nipype.sphinxext.plot_workflow.run(arguments, content, options, state_machine, state, lineno)
nipype.sphinxext.plot_workflow.run_code(code, code_path, ns=None, function_name=None)

Import a Python module from a path, and run the function given by name, if function_name is not None.

nipype.sphinxext.plot_workflow.setup(app)
nipype.sphinxext.plot_workflow.unescape_doctest(text)

Extract code from a piece of text, which contains either Python code or doctests.

nipype.sphinxext.plot_workflow.wf_directive(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)