slreportgen.report.DocBlock class

Package: slreportgen.report

DocBlock reporter

Description

Creates a DocBlock reporter.

Note

To use a DocBlock reporter in a report, you must create the report using the slreportgen.report.Report class or subclass.

The reporter adds the DocBlock content or a link to the content to a report, depending on the type of content in the DocBlock and the report type. For Microsoft® Word and PDF reports, when a DocBlock contains HTML, you can specify that the reporter links to the content by setting the ConvertHTML property to true. This table shows when the report includes the content and when it links to the content.

DocBlock Content TypeReport TypeConvertHTML PropertyReport Contains DocBlock ContentReport Contains Link to DocBlock Content
textHTMLN/Ayesno
textWordN/Ayesno
textPDFN/Ayesno
HTMLHTMLN/Ayesno
HTMLWordtrueyesno
HTMLWordfalsenoyes
HTMLPDFtrueyesno
HTMLPDFfalsenoyes
RTFWordN/Ayesno
RTFPDFN/Anoyes
RTFHTMLN/Anoyes

The slreportgen.report.DocBlock class is a handle class.

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes (MATLAB).

Creation

Description

rptr = slreportgen.report.DocBlock() creates an empty DocBlock reporter based on a default template. Customize the content and format of the generated content by using the reporter properties. Before you add the reporter to a report, you must specify the DocBlock in the Object property of the reporter. Adding an empty reporter to a report produces an error.

example

rptr = slreportgen.report.DocBlock(docBlockObj) creates a DocBlock reporter for the DocBlock specified by docBlockObj, which can be a DocBlock path or handle. See the Object property.

rptr = slreportgen.report.DocBlock(Name,Value) sets the reporter properties using name-value pairs. You can specify multiple name-value pair arguments in any order. Enclose each property name in single or double quotes.

Properties

expand all

Simulink DocBlock block, specified as a string scalar or character vector that contains the path to a DocBlock or as a handle to a DocBlock block.

Note

If you use a finder to find DocBlock blocks and add the results directly to a report, DocBlock reporters are used to report on the DocBlock blocks rather than Simulink object property reporters.

Whether to import plain text content in line, specified as true or false. If ImportTextInline is false, before the reporter appends the content to a hole, it wraps the content in one or more paragraphs, depending on the value of the TexSep property. Set ImportTextInline to true to append DocBlock text content to a hole in a paragraph (an inline hole).

Separator used to delimit paragraphs in plain text content, specified as one of the values in the table. You can specify the value as a string scalar or a character vector.

ValueDescription
"Ignore"Wrap text in a single paragraph regardless of whether it contains separators. (default)
"LineFeed"If a text segment ends with a line feed, wrap it in a paragraph.
"BlankLine"If a text segment ends with a blank line, wrap it in a paragraph.

ConvertHTML applies only to Word and PDF reports. If ConvertHTML is true, HTML content is converted to DOM objects and appended to a report. If ConvertHTML is false, HTML content is saved in a file and a link to the file is appended to the report. If the report is an HTML or HTML file report, the HTML content is included in the report, regardless of the value of ConvertHTML.

Paragraph formatter object that formats plain text if the ImportTextInline property is false, specified as an mlreportgen.dom.Paragraph object. The initial value of the ParagraphFormatter property is a mlreportgen.dom.Paragraph with default property values. To customize the appearance of the paragraph, modify the mlreportgen.dom.Paragraph object properties or replace the object with a customized mlreportgen.dom.Paragraph object. If you add content to the default or replacement paragraph object, the content appears in front of the DocBlock content in the generated report.

Text formatter object that formats plain text if the ImportTextInline property is true, specified as an mlreportgen.dom.Text object. The initial value of the TextFormatter property is a mlreportgen.dom.Text with default property values. To customize the appearance of the text, modify the mlreportgen.dom.Text object properties or replace the object with a customized mlreportgen.dom.Text object. If you add content to the default or replacement paragraph object, the content appears in front of the DocBlock content in the generated report.

Source of the template for this reporter, specified in one of these ways:

  • Character vector or string scalar that specifies the path of the file that contains the template for this reporter

  • Reporter or report whose template is used for this reporter or whose template library contains the template for this reporter

  • DOM document or document part whose template is used for this reporter or whose template library contains the template for this reporter

The specified template must be the same type as the report to which this reporter is appended. For example, for a Microsoft Word report, TemplateSrc must be a Word reporter template. If the TemplateSrc property is empty, this reporter uses the default reporter template for the output type of the report.

Name of the template for this reporter, specified as a character vector or string scalar. The template for this reporter is in the template library of the template source (TemplateSrc) for this reporter.

Hyperlink target for this reporter, specified as a string or character array that specifies the link target ID, or an mlreportgen.dom.LinkTarget object. A string or character array value is converted to a LinkTarget object. The link target object immediately precedes the content of this reporter in the output report.

Methods

expand all

Examples

collapse all

Include the content from the Sensor Info DocBlock of the sldemo_fuelsys model in a report by adding a DocBlock reporter to the report. Specify that paragraphs in the DocBlock are delimited by a linefeed.

% Import the API package
import slreportgen.report.*
import mlreportgen.report.*

% Load the model
model_name = 'sldemo_fuelsys';
load_system(model_name);
docBlock = 'sldemo_fuelsys/To Controller/Sensor Info';

% Create a report 
rpt = slreportgen.report.Report('output','pdf');

% Create a chapter reporter
chapter = Chapter(docBlock);

% Create a DocBlock reporter
% Specify that paragraphs are delimited by a linefeed 
rptr = DocBlock(docBlock);
rptr.TextSep = 'LineFeed';

% Add the DocBlock reporter to the chapter
% Add the chapter to the report
add(chapter, rptr);
add(rpt, chapter);

% Close and view the output report
close(rpt);
close_system(model_name);
rptview(rpt);

Here is the content from the Sensor Info DocBlock in the generated report:

Introduced in R2019b