Book a Demo

Author Topic: How to Suppress Stereotype in HTML Document  (Read 5654 times)

PaulY

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
How to Suppress Stereotype in HTML Document
« on: April 12, 2010, 03:39:39 pm »
Can anyone tell me if it is possible to suppress the Stereotype and other information in the HTML documentation, i.e. In my project browser I have unchecked 'Show Stereotypes' and voila stereotype information is removed (from project browser), but when I generate the HTML documentation, all the stereotype information is included.

I would ideally like it if possible instead of showing :-
<<Stereotype>>Class Name
in the HTML Browser pane it just showed Class Name
and in the HTML detail pane instead of showing
Class Name:Scope<<Stereotype>> Class
it just showed Class Name

Thanks in advance
Paul

Krzysztof Swiatkowski

  • EA User
  • **
  • Posts: 76
  • Karma: +0/-0
  • Understanding is a three-edged sword
    • View Profile
Re: How to Suppress Stereotype in HTML Document
« Reply #1 on: April 13, 2010, 12:15:06 am »
For first part unfortunately I don't have the access to the code now, but I did it by modifiying javascript in HTML template, IIRC this was done in tocBuildItem function. I belive I simply cut out the stereotype near the end :).

The second part is easier: you just need to change template "Body Object" and remove unncessary text. Element fields are marked with #....#.
so the beginning may look like this:
<span class="ObjectTitle">#NAME#</span>

Regards
Kris
If I put you finger in the eye
then you have finger in the eye
and I have finger in the eye
but it's not the same

PaulY

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: How to Suppress Stereotype in HTML Document
« Reply #2 on: April 13, 2010, 10:55:25 am »
Kris, thanks for that, I have modified the Body Object as suggested, and that works great, having trouble finding the correct part of the javascript to modify, so if you or anybody else comes across the piece of code in question please let me know!

Thanks

Paul

Graham_Moir

  • EA User
  • **
  • Posts: 749
  • Karma: +10/-15
    • View Profile
Re: How to Suppress Stereotype in HTML Document
« Reply #3 on: April 13, 2010, 11:57:53 pm »
I'm interested in this too.

The javascript code for tocBuildItem is quite long - so I'm including it in 2 parts in 2 messages in this thread.     It can be found to start at approx line 514 of the "Javascript" section of the HTML and CSS templates.

What needs to be changed/removed to suppress the stereotype ?

function tocBuildItem(i) {

      var childItem = false;

      if (tocTab[0].indexOf(':')!=-1) tocBranch = document.getElementById("toc"+tocTab[0].substring(0, tocTab[0].lastIndexOf(':')));
      else if (tocTab[0].indexOf('.')!=-1) tocBranch = document.getElementById("toc"+tocTab[0].substring(0, tocTab[0].lastIndexOf('.')));
      else if (tocTab[0]!="0") tocBranch = document.getElementById("toc0");
      else if (tocTab[1]==3) tocBranch = document.getElementById("System").parentNode.lastChild;
      else tocBranch = tocRoot;
      
      //Check if item is child
      if (tocTab[5]&&tocTab[6]&&tocTab[6]!="0") {
            if (document.getElementById(tocTab[6])==null) return 'i'+i;
            tocBranch = document.getElementById(tocTab[6]).parentNode.lastChild;
            childItem = true;
      }

      tocBranch = tocBranch.appendChild(document.createElement('li'));

      if (tocTab[0]!=0||tocTab[1]==3) {
            tocImage = tocBranch.appendChild(document.createElement('img'));

            if (tocTab[0].indexOf('.')==-1&&(tocTab[0].indexOf(':')==-1||tocTab[0].indexOf('0')==0)) tocImage.src = "images/join01.gif";
            else if (tocTab[0].indexOf('.')!=-1||tocTab[0].indexOf(':')!=-1) {
                  var tocTmp=tocTab[0].replace(':','.');
                  for (var m=0; tocTmp.split('.').length>m+1; m++) {
                        if (document.getElementById("toc"+tocTmp.substring(0,tocTmp.lastIndexOf('.'))).parentNode.childNodes[m].src.substring(document.getElementById("toc"+tocTmp.substring(0,tocTmp.lastIndexOf('.'))).parentNode.childNodes[m].src.lastIndexOf('images')).indexOf('02')!=-1||document.getElementById("toc"+tocTmp.substring(0,tocTmp.lastIndexOf('.'))).parentNode.childNodes[m].src.substring(document.getElementById("toc"+tocTmp.substring(0,tocTmp.lastIndexOf('.'))).parentNode.childNodes[m].src.lastIndexOf('images')).indexOf('04')!=-1) tocImage.src = "images/join04.gif";
                        else tocImage.src = "images/join03.gif";
                        tocImage = tocBranch.appendChild(document.createElement('img'));
                  }
                  tocImage.src = "images/join01.gif";
            }
            tocImage.onclick = function() { tocClick(this); }

            if (tocTab[1]==3) {
                  tocImage.src=tocImage.src.substring(tocImage.src.lastIndexOf('images')).replace("01","02");
                  if (tocImage.parentNode.parentNode.childNodes.length>1) {
                        tocTmp = tocImage.parentNode.previousSibling.childNodes[tocImage.parentNode.previousSibling.childNodes.length-4];
                        tocTmp.src=tocTmp.src.substring(tocTmp.src.lastIndexOf('images')).replace("02","01");
                  }
            }

continued.....  
« Last Edit: April 13, 2010, 11:59:46 pm by Graham_Moir »

Graham_Moir

  • EA User
  • **
  • Posts: 749
  • Karma: +10/-15
    • View Profile
Re: How to Suppress Stereotype in HTML Document
« Reply #4 on: April 13, 2010, 11:59:04 pm »
... continued from last message


            //Check if item has children data
            if (tocTab[1]&&tocTab[1]!=3) {
                  tocImage.id=tocTab[7];
                  tocImage.alt=tocTab[7];
            } else if (childItem==true) {
                  while (tocImage.parentNode.childNodes.length<document.getElementById(tocTab[6]).parentNode.childNodes.length-2) {
                        tocImage.parentNode.insertBefore(document.createElement('img'), tocImage).src="images/join03.gif";
                  }
                  tocImage.src=tocImage.src.substring(tocImage.src.lastIndexOf("images")).replace('01','02');
                  if (document.getElementById(tocTab[6]).parentNode.lastChild.childNodes.length>1) {
                        tocTmpSrc=document.getElementById(tocTab[6]).parentNode.lastChild.lastChild.previousSibling.childNodes[document.getElementById(tocTab[6]).parentNode.lastChild.lastChild.previousSibling.childNodes.length-4];
                        tocTmpSrc.src=tocTmpSrc.src.substring(tocTmpSrc.src.lastIndexOf('images')).replace('02','01');
                  }
                  tocImage = document.getElementById(tocTab[6]).parentNode.childNodes[document.getElementById(tocTab[6]).parentNode.childNodes.length-4];
                  tocImage.parentNode.lastChild.style.display = "none";
            }

            if ((tocTab[1]&&tocTab[1]!=3)||childItem==true) {
                  tocImage.id=tocImage.id.substr(1,tocImage.id.length-2);
                  tocImage.src=tocImage.src.substring(tocImage.src.lastIndexOf('images')).replace('join','plus');
            }
      }

      //Set Icon
      if (tocTab[3]) {
            tocImg = tocBranch.appendChild(document.createElement('a'));
            tocImg.href = tocTab[3];
            tocImg.target = top.frames[1].name;
      } else tocImg = tocBranch;
      tocTab[4]=tocTab[4].substring(0,tocTab[4].indexOf('.'))

      tocImg = tocImg.appendChild(document.createElement('img'));
      if(top.icon[tocTab[4]])
            tocImg.src = top.icon[tocTab[4]].src;
      else
            tocImg.src = "images/"+tocTab[4]+".png";

      if (tocTab[3])
            tocImg.id=tocTab[3];

      //Set Text/Link
      if (tocTab[5]&&tocTab[8]!="0Diagram") tocBranch.lastChild.id=tocTab[5];
      else tocBranch.lastChild.id="0";
      tocBranch.lastChild.style.marginRight="4px";
      if (tocTab[3]) {
            tocText = tocBranch.appendChild(document.createElement('a'));
            tocText.href = tocTab[3];
            tocText.target = top.frames[1].name;
            if (tocTab[9])
                  tocText.id = tocTab[9];
            else if (tocTab[7])
                  tocText.id = tocTab[7];
      }
      else tocText = tocBranch;
      var j=0;
      var nodeText;

      //Replace values
      while (tocTab[2].indexOf('&quot;')!=-1) tocTab[2] = tocTab[2].replace('&quot;','\"');
      while (tocTab[2].indexOf('<br />')!=-1) tocTab[2] = tocTab[2].replace('<br />','\n');
      while (tocTab[2].indexOf('&#39;')!=-1) tocTab[2] = tocTab[2].replace('&#39;','\'');
      if (tocTab[2]=="") tocTab[2]="               ";

      nodeText = tocText.appendChild(document.createTextNode(tocTab[2]));      
      while (nodeText.nodeValue.indexOf('&lt;')!=-1) nodeText.nodeValue = nodeText.nodeValue.replace('&lt;','<');
      while (nodeText.nodeValue.indexOf('&gt;')!=-1) nodeText.nodeValue = nodeText.nodeValue.replace('&gt;','>');
      
      tocBranch.appendChild(document.createElement('ul')).id = "toc"+tocTab[0];

      tocLastID = tocTab[0];

      return true;

}

Graham_Moir

  • EA User
  • **
  • Posts: 749
  • Karma: +10/-15
    • View Profile
Re: How to Suppress Stereotype in HTML Document
« Reply #5 on: April 21, 2010, 07:52:20 pm »
Thanks to Kris who has provided the change required to the code to remove the stereotype.  Method is to use a regular expression to replace the stereotype value with an empty string.

2 lines need to be added at the end of the tocBuildItem function in the Javascript template so that the final lines of the function are as follows:


if (tocTab[2]=="") tocTab[2]="               ";

      nodeText = tocText.appendChild(document.createTextNode(tocTab[2]));
      while (nodeText.nodeValue.indexOf('&lt;')!=-1) nodeText.nodeValue = nodeText.nodeValue.replace('&lt;','<');
      while (nodeText.nodeValue.indexOf('&gt;')!=-1) nodeText.nodeValue = nodeText.nodeValue.replace('&gt;','>');

      var re = new RegExp("[«]+.*[»]+", "g");
      nodeText.nodeValue = nodeText.nodeValue.replace(re,"");

      tocBranch.appendChild(document.createElement('ul')).id = "toc"+tocTab[0];

      tocLastID = tocTab[0];

      return true;

« Last Edit: April 23, 2010, 01:28:29 am by Graham_Moir »

PaulY

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: How to Suppress Stereotype in HTML Document
« Reply #6 on: April 22, 2010, 10:07:58 am »
Great stuff, works a treat, thanks Kris & Graham.  ;D
Paul