IReport Plugin Full Documentation


Interactive Reports create a text-based window in Understand to display information of your choosing. They can reference the entire Project, a given Architecture, or a specific Entity, and they can be as simple or complex as your imagination. Here is an IReport that ships with Understand that shows all the API information available for the selected entity. To see it yourself just right click on an entity in your Understand project and select Interactive Reports->API Info





Creating your own IReport Plugin


All IReport Plugins are python scripts just like the graph plugins in the previous tutorial. How to start a plugin script was covered in Tutorial 5 so we will skip that part and jump right into the logic.

An IReport must have a function called generate(report, target). This is where the report generation logic will be placed. A basic template for this report would look like the following:

# Report generation
def generate(report, target):
  """
  Required, generate the report
  """
  # If the report can be valid for multiple types of objects, use
  # isinstance to determine the target type.
  if isinstance(target, understand.Arch):
    report.print("arch: ")
  if isinstance(target, understand.Ent):
    report.print("ent: ")
  if isinstance(target, understand.Db):
    report.print("db: ")
  report.bold()
  # This take advantage of the fact that there is a name method
  # for entities, architectures, and datases.
  report.print(target.name())
  report.nobold()
  report.print("\n")

  # retrieve options defined in init like this:
  option = report.options().lookup("test")
  report.print("option: {}\n".format(option))
Python


The report parameter being used by generate() is an IReport object, this is how we will access various methods for our IReport. The target parameter is what the user has selected in Understand.

The rest of the function is easily explained by the comments contained in the code itself.

For more examples of what IReports can do, like checking your code complexity, grouping parameters by value, and finding all macro uses in a file, check out our Github plugin repository.


We also have some real world IReport uses on our blog: Custom Report: Finding Parameter Values



Continue to API Tutorial 7: Retrieving Violations ->


<- Return to API Tutorial 5: Graphs 



Need help? Contact support@scitools.com or visit our About the Understand Python API page.