List out diagram/model’s comment

Doc. Composer can let you output every details of your models and diagrams in fully customizable way. In this article you will learn how to create custom template to output the comments of diagrams or model elements in a project.

Let’s start!

  1. Go to Tools > Doc. Composer > Manage Template XMLs.

    Manage XML Template

    Manage XML Template

  2. Switch the template category to General.

    Switch to General category

    Switch to General category

  3. Right click on any template in the list and select Duplicate from popup menu.

    Duplicate a template

    Duplicate a template

  4. Name the template as General/Comments, and select Table as template icon.

    Name the template as General/Comments

    Name the template as General/Comments

  5. Replace the template with following content.
    <?xml version="1.0" encoding="UTF-8"?>
    <AnyBaseInitiationBlock>	
        <Property anchorMark="true" property="name" style="@heading+"/>
        <ParagraphBreak/>
        <HasValueChecker property="comments">
            <Text style="@heading+">Comments</Text>
            <TableBlock colWidths="20, 40, 15, 25" tableStyle="Summaries">
                <TableRow>
                    <TableCell><Text>Name</Text></TableCell>
                    <TableCell><Text>Details</Text></TableCell>
                    <TableCell><Text>Author</Text></TableCell>
                    <TableCell><Text>Date/Time</Text></TableCell>
                </TableRow>
                <ForEach property="comments">
                    <TableRow>
                        <TableCell>
                            <Property property="name"/>
                        </TableCell>
                        <TableCell>
                            <Property property="description"/>
                        </TableCell>
                        <TableCell>
                            <Property property="author"/>
                        </TableCell>
                        <TableCell>
                            <Property property="dateTime"/>
                        </TableCell>		
                    </TableRow>
                </ForEach>							
            </TableBlock>
        </HasValueChecker>	
    </AnyBaseInitiationBlock>
  6. Press Save button to confirm the change and close the Manage Template XML dialog.
  7. Go to Tools > Doc. Composer.

    Open Doc. Composer

    Open Doc. Composer

  8. Select Build Doc. from Scratch.

    Select Build Doc. from Scratch

    Select Build Doc. from Scratch

  9. Select the diagram or model you would like to output its comments.
  10. Right click on the Basic template and select Duplicate from popup menu.

    Duplicate the Basic template of the subject

    Duplicate the Basic template of the subject

  11. Name the template as Comments.
  12. Change the inline call to General/Comments.

    Change the inline call of the new template

    Change the inline call of the new template

  13. Press Save button to confirm the change, then close the template editor dialog.
  14. Drag out the Comments template into document editor.

    Drag out the template to render the comments

    Drag out the template to render the comments

Now the comments of the selected subject will be listed in a table.

Explanation of the Template

The reason why we create a Comments template under General category is to make it become a reusable component. This allow other elements reference to this template for outputting its comment, without writing the same template over and over on individual elements.

The template start with AnyBaseInitiationBlock which allow to be reuse by both diagrams and model elements.

<AnyBaseInitiationBlock>

Next we printout the name of the name of diagram or model element that the template works apply to in heading style.

<Property anchorMark="true" property="name" style="@heading+"/>
<ParagraphBreak/>

After that we check did the subject contain comments.

<HasValueChecker property="comments">

If the subject contain comments then we print out the section title of the comment, and start print the table header.

<Text style="@heading+">Comments</Text>
<TableBlock colWidths="20, 40, 15, 25" tableStyle="Summaries">
    <TableRow>
        <TableCell><Text>Name</Text></TableCell>
        <TableCell><Text>Details</Text></TableCell>
        <TableCell><Text>Author</Text></TableCell>
        <TableCell><Text>Date/Time</Text></TableCell>
    </TableRow>

Next we walk through the comment one by one to print out its details.

<ForEach property="comments">
    <TableRow>
        <TableCell>
            <Property property="name"/>
        </TableCell>
        <TableCell>
            <Property property="description"/>
        </TableCell>
        <TableCell>
            <Property property="author"/>
        </TableCell>
        <TableCell>
            <Property property="dateTime"/>
        </TableCell>		
    </TableRow>
</ForEach>							

Once this template is ready, we can then create comment template under individual diagram/model element, which call the General/Comments template for render of data.

<Inline template="General/Comments"/>

You can also call this template using Fill-in doc approach by specify the diagram/model level template.

${DIAGRAM, “DiagramComment”, “BPD”,Any, “Comments”}
${ELEMENT, “ClassComment”, “Class”,Any, “Comments”}

 

Related Know-how

Related Link

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply