Contenuto principale

generateHTMLReport

R2026b

Class: matlab.buildtool.BuildResult
Namespace: matlab.buildtool

Generate HTML report from build result

Since R2026b

Description

generateHTMLReport(result) generates an interactive build report in HTML format from the build result and saves it to a temporary folder. By default, the method names the main file of the report index.html.

The build report provides detailed information about the build, including the build environment, build summary, and individual task results. You can interact with the report, for example, by filtering the list of tasks by status.

generateHTMLReport(result,folderName) saves the report to the specified folder.

example

generateHTMLReport(___,Name=Value) specifies options using one or more name-value arguments in addition to any of the input argument combinations in previous syntaxes. For example, generateHTMLReport(result,MainFile="main.html") generates a build report whose main file is main.html.

Input Arguments

expand all

Build result, specified as a matlab.buildtool.BuildResult object.

Name of the build report folder, specified as a string scalar or character vector. The value can be a path relative to the current folder or an absolute path.

Example: "myBuildReport"

Example: "C:\work\myBuildReport"

Name-Value Arguments

expand all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: generateHTMLReport(result,MainFile="main.html")

Name of the main HTML file, specified as a string scalar or character vector ending in .html or .htm. If you do not specify a name, the method names the main file of the report index.html.

Example: MainFile="main.html"

Build report title, specified as a string scalar or character vector. By default, the report title is MATLAB Build Report.

Example: Title="My Build Report"

Examples

expand all

Run the tasks in a build file, and then generate an HTML build report from the build result.

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

cd run_plan_example

This code shows the contents of the build file.

function plan = buildfile
import matlab.buildtool.tasks.CodeIssuesTask
import matlab.buildtool.tasks.TestTask

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

% Add the "check" task to identify code issues
plan("check") = CodeIssuesTask;

% Add the "test" task to run tests
plan("test") = TestTask;

% 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 archiveTask(~)
% Create ZIP file
filename = "source_" + ...
    string(datetime("now",Format="yyyyMMdd'T'HHmmss"));
zip(filename,"*")
end

Run the default task in the build file by using the run method of the matlab.buildtool.Plan class. The method provides programmatic access to the build result. In this example, the build runs successfully.

plan = buildfile;
result = run(plan)
** Starting check

Analysis Summary:
    Total Files: 3
         Errors: 0 (Threshold: 0)
       Warnings: 0 (Threshold: Inf)
           Info: 0 (Threshold: Inf)
** Finished check

** Starting test
...

Test Summary:
    Total Tests: 3
         Passed: 3
         Failed: 0
     Incomplete: 0
       Duration: 0.053209 seconds testing time.
                 
** Finished test

** Starting archive
** Finished archive

Build Successful:
    3 Tasks: 0 Failed, 0 Skipped
    3.4156 sec total build time
result = 
  BuildResult with properties:

         Failed: 0
       Duration: 3.4156 sec
    TaskResults: [1×3 matlab.buildtool.TaskResult]

Generate an HTML build report from the build result, and save the report to a folder named reports in the current folder.

generateHTMLReport(result,"reports")
MATLAB build report has been saved to:
 'reports\index.html'

Open the generated build report.

open(fullfile("reports","index.html"))

Tips

  • To generate a build report using the buildtool command, specify the -report build option.

Version History

Introduced in R2026b