How to add block(function) description for library blocks in autocode

Hi there, I try to add customized function(block) description for library block in generated auto code. Is there a way to do it? Thanks in advance!

Answers (1)

I have not been able to get a description to appear for a block in autocode by using the DocBlock. However, I have found success by editing the properties of the library block and putting my intended comments in the "Description" field. I am using this for tracking copyright for a few of our lower-level blocks that came from another developer.
With my current .cgt file settings, I see the copyright statement in the auto-generated code both where the library function is called and where it is defined. The key is including
%<BlockDescription>
In the FunctionBanner portion of your .cgt file.
I have found that setting the library block to atomic and generating it as a reusable function seems to be required. It also seemed like it helped if the library block was actually embedded within another library block, but I am not sure if that is actually necessary (due to the nature of my team's development approach, we have multiple layers of library blocks).
You can edit the Description property of a library block within another library block, and it will not break the link to the original. Apparently, this is a property that is unique. Thus, if you have your library block in use in multiple locations and you go change the Description in the library, that change will not propagate to all of the places it is used - you will have to go through all of them and add it manually. If you put your Description in the library block before you place it in other models or libraries, then each implementation will bring the Description with it.

Asked:

Bo
on 11 Apr 2016

Answered:

on 21 Mar 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!