Main Content

Subclass Reporter Definitions

If a built-in reporter meets some of your requirements, consider subclassing the reporter. Subclassing a reporter allows you to rearrange and expand the content of a built-in reporter. To subclass a built-in reporter:

  1. Create a custom reporter definition based on the class definition of the built-in reporter, using the customizeReporter method of the built-in reporter.

    For example, the following code creates a folder named @MyTitlePage in the current folder.

     mlreportgen.report.TitlePage.customizeReporter('@MyTitlePage');

    The created folder contains a class definition file named MyTitlePage.m. The class definition file defines a subclass of the built-in TitlePage reporter. The class definition folder also contains copies of the TitlePage reporter templates, which are stored in a subfolder named resources.

  2. Edit the template copies to rearrange the holes for the content of the built-in reporter or add holes for additional generated content.

  3. If you add holes to the templates of the new reporter, edit the reporter class definition file to define properties that specify the content that fills the holes. Define a property for each hole that you have added to the template of the new reporter. The name of the property must be the same as the name of the hole.

See Also

Related Topics