Main Content

plot

Class: matlab.buildtool.Plan
Package: matlab.buildtool

Plot tasks in plan

Since R2022b

Description

example

plot(plan) plots the tasks in the plan as a dependency graph where nodes represent tasks and edges represent dependencies. Edges in the graph flow from dependent tasks to depended-on tasks.

The plot visualizes the plan as a directed acyclic graph. It cannot contain any cycles.

Input Arguments

expand all

Plan, specified as a matlab.buildtool.Plan object.

Examples

expand all

Plot the tasks in a build plan as a dependency graph.

Open the example and then navigate to the plot_plan_example folder, which contains a build file.

openExample("matlab/PlotTasksAsDependencyGraphExample")
cd plot_plan_example

This code shows the contents of the build file.

function plan = buildfile
% Create a plan from the task functions
plan = buildplan(localfunctions);

% Make the "archive" task the default task in the plan
plan.DefaultTasks = "archive";

% Make the "archive" task dependent on the "check" and "test" tasks
plan("archive").Dependencies = ["check" "test"];
end

function checkTask(~)
% Identify code issues
issues = codeIssues;
assert(isempty(issues.Issues),formattedDisplayText( ...
    issues.Issues(:,["Location" "Severity" "Description"])))
end

function testTask(~)
% Run unit tests
results = runtests(IncludeSubfolders=true,OutputDetail="terse");
assertSuccess(results);
end

function archiveTask(~)
% Create ZIP file
zipFileName = "source_" + ...
    string(datetime("now",Format="yyyyMMdd'T'HHmmss"));
zip(zipFileName,"*")
end

Load a plan from the build file.

plan = buildfile
plan = 
  Plan with tasks:

    archive - Create ZIP file
    check   - Identify code issues
    test    - Run unit tests

Plot the tasks in the plan as a dependency graph. The graph displays the tasks as nodes. Because the "archive" task depends on the "check" and "test" tasks, the graph also includes two edges that represent these dependencies.

plot(plan)

Version History

Introduced in R2022b