main content

reporting on docblock blocks -凯发k8网页登录

this example shows how to include the contents of simulink docblock blocks in a microsoft® word report generated by the report api. the example model, slreportgen_demo_docblock, contains only docblock blocks, with one block for each kind of docblock document type:

  • rtf

  • html

  • text

in the generated report, the contents of the docblock blocks look like this:

import the api packages so that you can refer to api classes by their unqualified names, that is, without the names of the class packages in which they reside.

import mlreportgen.report.*
import slreportgen.report.*
import slreportgen.finder.*
import mlreportgen.dom.*

load the model for this example.

model = 'slreportgen_demo_docblock';
load_system(model);

create a container to hold the report content. to avoid a compilation error due to the model containing only virtual blocks, set the compilemodelbeforereporting property of the report object to false.

rpt = slreportgen.report.report('modeldoc', 'docx');
rpt.compilemodelbeforereporting = false;

add a title page and table of contents.

add(rpt,titlepage('title',sprintf('%s model documentation',model)));
add(rpt,tableofcontents);

find and loop through all the systems in the model.

finder = systemdiagramfinder(model);
for system = find(finder)

create a chapter for each system. include the system name in the chapter title. use the chapter to report on the docblock content of the system.

    ch = chapter('title',sprintf('system %s', system.name));

find all the docblock blocks in the current system. each result returns the docblock reporter for the found docblock. the add method invokes the docblock reporter.

    docblockfinder = blockfinder(system);
    docblockfinder.properties = {'masktype', 'docblock'}';
    results = find(docblockfinder);
    if ~isempty(results)
        add(ch, results);
        else
        add(ch, "this system does not have documentation.");
    end
    add(rpt,ch)
end 

close and view the report.

close(rpt);
close_system(model);
rptview(rpt);

see also

| | | |

related topics

网站地图