User Tools

Site Tools


pf:rpldocs:prpldoccompiler_compare

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
pf:rpldocs:prpldoccompiler_compare [2016/10/20 15:50] – created with K75 Version Karsten75pf:rpldocs:prpldoccompiler_compare [2025/02/14 14:57] (current) – external edit 127.0.0.1
Line 8: Line 8:
     private Main main;     private Main main;
     private int cmdCount;     private int cmdCount;
-    private int cmdTotal = 0; 
     private string currentSection;     private string currentSection;
     private string[] docIndexLines;     private string[] docIndexLines;
     private OrderedDictionaryG<string, List<Tuple<int, string>>> sectionDict;     private OrderedDictionaryG<string, List<Tuple<int, string>>> sectionDict;
- +     
-    public string resultHTMLFile;+    public string resultFile;
  
     public void MakePRPLDocs(Main main, string srcDir, string outputDir) {     public void MakePRPLDocs(Main main, string srcDir, string outputDir) {
         this.main = main;         this.main = main;
-        resultHTMLFile = null;+        resultFile = null;
         cmdCount = 0;         cmdCount = 0;
         currentSection = null;         currentSection = null;
         sectionDict = new OrderedDictionaryG<string, List<Tuple<int, string>>>();         sectionDict = new OrderedDictionaryG<string, List<Tuple<int, string>>>();
         System.Text.StringBuilder sbcommands = new System.Text.StringBuilder();         System.Text.StringBuilder sbcommands = new System.Text.StringBuilder();
 + System.Text.StringBuilder sbIndex = new System.Text.StringBuilder();
  
         srcDir = srcDir.Trim();         srcDir = srcDir.Trim();
Line 33: Line 33:
         }         }
  
-        // read document index file - each line has filename of next syntax files 
         try {         try {
             docIndexLines = System.IO.File.ReadAllLines(srcDir + "prpldocindex.txt");             docIndexLines = System.IO.File.ReadAllLines(srcDir + "prpldocindex.txt");
Line 41: Line 40:
  
             System.Text.StringBuilder sb = new System.Text.StringBuilder();             System.Text.StringBuilder sb = new System.Text.StringBuilder();
-/* stringBuilder sb contains final output HTML header, CSS and JavaScript  
-/* */ 
-            #region HTML/CSS 
             sb.Append(@"             sb.Append(@"
 <html> <html>
Line 68: Line 64:
  }  }
  .command_syntax { padding: 1px 5px; font-size: 110%; font-weight:bold; background-color: #bfc7cf; color: #000000; width:850px; }  .command_syntax { padding: 1px 5px; font-size: 110%; font-weight:bold; background-color: #bfc7cf; color: #000000; width:850px; }
- .command_body{ padding: 1px 1px 50px 15px; width:840px; }+ .command_body{ padding: 1px 1px 50px 15px; }
  .example{ padding: 0px 0px 5px 0px; }  .example{ padding: 0px 0px 5px 0px; }
- .description{ padding: 0px 0px 5px 0px; width:840px; }+ .description{ padding: 0px 0px 5px 0px; }
  .index {border-spacing:20px;}  .index {border-spacing:20px;}
  .index tr{vertical-align:top;}  .index tr{vertical-align:top;}
Line 79: Line 75:
  .section tr:nth-child(even) {background-color: #ffffff;}  .section tr:nth-child(even) {background-color: #ffffff;}
  .sectionHead{background-color:#e0e7ef !important;}  .sectionHead{background-color:#e0e7ef !important;}
- .backtotop{font-size:60%; padding:0; float:right}+ .fullList{font-size:55%; padding:0}
 </style > </style >
 </head > </head >
 +<body>
 +<div id=""wrapper"" style=""display:flex"">
 "); ");
-            #endregion + sb.Append(""); 
- + GenerateDocSections(sb,sbIndex); 
-            GenerateDocSections(sb); + sb.Append("\n<div style=\"float:right\">");
-            sb.Append("<br/>");+
             sb.Append(sbcommands);             sb.Append(sbcommands);
-            sb.Append(@"</html>");+ sb.Append(@" </div> 
 +</div> 
 +<div class=""fullList""><p> 
 +"); 
 + sb.Append(sbIndex); 
 + sb.Append(@"</p></div> 
 +<script type=""text/javascript""> 
 +function handleListClick(e) { 
 + var anchor = e.target; 
 + var cmd = anchor.firstChild.nodeValue; 
 +  
 + //funcById(""commandList"",close); 
 + //reset(); 
 + //funcById(""topLink"",open); 
 + funcById(cmd,toggle); 
 + document.title = defaultTitle + "": "" + cmd; 
 +
 + 
 +function handleListSectionTitleClick(e) { 
 + toggle(e.target.parentElement.parentElement.nextElementSibling); 
 + document.title = defaultTitle; 
 +
 + 
 +function toggle(elem) { 
 + if (elem.style.display == ""none"") { 
 + elem.style.display = """"; 
 + } else { 
 + elem.style.display = ""none""; 
 +
 +
 + 
 +function funcById(id, func) { 
 + func(document.getElementById(id)); 
 +
 + 
 +function close(elem) { 
 + elem.style.display = ""none""; 
 +
 + 
 +function open(elem) { 
 + elem.style.display = """"; 
 +
 + 
 +var defaultTitle = ""PRPL Docs""; 
 +document.title = defaultTitle; 
 + 
 +var wrapper = document.body.firstElementChild; 
 +var cmdList = wrapper.firstElementChild; 
 +var cmdSection = cmdList.firstElementChild; 
 +while (cmdSection !== null) { 
 + close(cmdSection.firstElementChild.nextElementSibling); 
 + cmdSection = cmdSection.nextElementSibling; 
 +
 +//var toplink = cmdList.nextElementSibling; 
 + 
 +function reset() { 
 + var docSection = cmdList.nextElementSibling;//start at the first doc section. 
 + var docCmd; 
 + //close(toplink); 
 + open(cmdList); 
 + while (docSection.tagName !== ""SCRIPT"") { 
 + docCmd = docSection.firstElementChild; 
 + while (docCmd !== null) { 
 + close(docCmd); 
 + docCmd = docCmd.nextElementSibling; 
 +
 + docSection = docSection.nextElementSibling; 
 +
 +
 +reset(); 
 +</script> 
 +</body> 
 +</html>");
             System.IO.File.WriteAllText(outputDir + "PRPLDocs.html", sb.ToString());             System.IO.File.WriteAllText(outputDir + "PRPLDocs.html", sb.ToString());
-            resultHTMLFile = outputDir + "PRPLDocs.html"+            resultFile = outputDir + "PRPLDocs.html"; 
-            main.LogMessage("\n      Processed Total " + cmdTotal + " comands."); +            main.LogMessage("COMPLETE: HTML file created: " + resultFile);
-            Debug.Log("      Processed " + cmdTotal + " comands.")+
-            main.LogMessage("COMPLETE: HTML file created: " + resultHTMLFile);+
         } catch (Exception e) {         } catch (Exception e) {
             main.LogMessage("ERROR: " + e.Message);             main.LogMessage("ERROR: " + e.Message);
Line 103: Line 170:
         currentSection = sect;         currentSection = sect;
         string f = srcDir + sect + ".txt";         string f = srcDir + sect + ".txt";
-        int cmdSubtotal = 0; 
         main.LogMessage("Processing File: " + f);         main.LogMessage("Processing File: " + f);
         if (System.IO.File.Exists(f)) {         if (System.IO.File.Exists(f)) {
Line 111: Line 177:
                 if (l.StartsWith("=CMD")) {                 if (l.StartsWith("=CMD")) {
                     i = ProcessDocCMD(sbcommands, lines, i);                     i = ProcessDocCMD(sbcommands, lines, i);
-                    cmdSubtotal++; 
                 }                 }
             }             }
-            this.cmdTotal += cmdSubtotal; 
-            main.LogMessage("      Processed " + cmdSubtotal + " comands."); 
-            Debug.Log("      Processed " + cmdSubtotal + " comands."); 
         } else {         } else {
             main.LogMessage("File Not Found: " + f);             main.LogMessage("File Not Found: " + f);
Line 122: Line 184:
     }     }
  
-    private void GenerateDocSections(System.Text.StringBuilder sb) { + private void GenerateDocSections(System.Text.StringBuilder sb, System.Text.StringBuilder sbIndex) { 
-        sb.Append("<table id='index' class='index'>\r\n");+ sb.Append("<div id=\"commandList\" style=\"float:left\">\r\n");
  
-        bool open = false;+        //bool open = false;
         for (int i = 0; i < docIndexLines.Length; i++) {         for (int i = 0; i < docIndexLines.Length; i++) {
-            if (i % 2 == 0) { +             
-                sb.Append("<tr>\r\n"); + //sb.Append("<td>\r\n");
-                open = true; +
-            } +
- +
-            sb.Append("<td>\r\n");+
             if (!sectionDict.ContainsKey(docIndexLines[i].Trim())) {             if (!sectionDict.ContainsKey(docIndexLines[i].Trim())) {
                 sb.Append("&nbsp;");                 sb.Append("&nbsp;");
             } else {             } else {
-                GenerateDocSection(sb, docIndexLines[i].Trim());+ GenerateDocSection(sb, sbIndex, docIndexLines[i].Trim());
             }             }
-            sb.Append("</td>\r\n");+            //sb.Append("</td>\r\n");
  
-            if (i % 2 == 1) { +            //if (i % 2 == 1) { 
-                sb.Append("</tr>\r\n"); +               // sb.Append("</tr>\r\n"); 
-                open = false; +                //open = false; 
-            }+            //}
         }         }
-        if (open) { +        //if (open) { 
-            sb.Append("</tr>\r\n"); +            //sb.Append("</tr>\r\n"); 
-            open = false; +            //open = false; 
-        } +        //
-        sb.Append("</table>");+        /* 
 +        sb.Append("<tr>\r\n"); 
 +        sb.Append("<td>\r\n"); 
 +        GenerateDocSection(sb, "Vars and Functions"); 
 +        sb.Append("</td>\r\n"); 
 + 
 +        sb.Append("<td>\r\n"); 
 +        GenerateDocSection(sb, "Logic"); 
 +        sb.Append("</td>\r\n"); 
 + 
 +        sb.Append("</tr>\r\n"); 
 +        */ 
 + 
 + sb.Append("</div>");
  
     }     }
  
-    private void GenerateDocSection(System.Text.StringBuilder sb, string section) { + private void GenerateDocSection(System.Text.StringBuilder sb, System.Text.StringBuilder sbIndex, string section) { 
-        int cols = 2+        int cols = 1
-        sb.Append("<table class='section'>\r\n"); + sb.Append("<table class='section'>\n\t<thead>\n\t\t<tr>\n\t\t\t<th colspan='" + cols.ToString() +"' onclick=handleListSectionTitleClick(event)>" + section + "</th>\r\n"); 
-        sb.Append("<thead>\r\n"); + sb.Append("\t\t</tr>\n\t</thead>\n\t<tbody>\n");
-        sb.Append("<th colspan='" + cols.ToString() +"'>" + section + "</th>\r\n"); +
-        sb.Append("</thead>\r\n");+
         List<Tuple<int, string>> list = sectionDict[section];         List<Tuple<int, string>> list = sectionDict[section];
         int cc = 0;         int cc = 0;
-        bool open = false;+ //sbIndex.Append("<p>\n"); 
 +        // open = false;
         foreach (Tuple<int, string> tup in list) {         foreach (Tuple<int, string> tup in list) {
             if (cc % cols == 0) {             if (cc % cols == 0) {
-                sb.Append("<tr>\r\n"); +                sb.Append("\t\t<tr>\r\n"); 
-                open = true;+                //open = true;
             }             }
  
Line 174: Line 244:
                 cs = "";                 cs = "";
             }             }
-            sb.Append("<td " + cs + " ><href='#cmd" + tup.Item1.ToString() + "'>" + tup.Item2 + "</a></td>\r\n");+ sb.Append("\t\t\t<td " + cs + " >\n\t\t\t\t<a onclick=handleListClick(event)>" + tup.Item2 + "</a>\n\t\t\t</td>\r\n"); 
 + sbIndex.Append("  <a onclick=handleListClick(event)>" + tup.Item2 + "</a>  \r\n");
  
             if (cc % cols == cols-1) {             if (cc % cols == cols-1) {
-                sb.Append("</tr>\r\n"); +                sb.Append("\t\t</tr>\r\n"); 
-                open = false;+                //open = false;
             }             }
             cc++;             cc++;
         }         }
-        if (open) { +        //if (open) { 
-            sb.Append("</tr>\r\n"); + sb.Append("\t</tbody>\r\n"); 
-            open = false; +           // open = false; 
-        }+        //} 
 + //sbIndex.Append("</p>\n");
         sb.Append("</table>\r\n");         sb.Append("</table>\r\n");
     }     }
Line 191: Line 263:
  
     private int ProcessDocCMD(System.Text.StringBuilder sb, string[] lines, int pos) {     private int ProcessDocCMD(System.Text.StringBuilder sb, string[] lines, int pos) {
-        sb.Append(@" + System.Text.StringBuilder currCmdStr = new System.Text.StringBuilder (); 
-<div class='command'> + string cmd = ""; 
-");+ 
 + sb.Append (@" 
 + <div class='command' id="""); 
 + currCmdStr.Append("\" >\n");
         string startingSection = currentSection;         string startingSection = currentSection;
         int i;         int i;
Line 202: Line 277:
             } else             } else
             if (l.StartsWith("=CMDCLASS")) {             if (l.StartsWith("=CMDCLASS")) {
-                ProcessDocCMDCLASS(sb, l);+ ProcessDocCMDCLASS(currCmdStr, l);
             } else             } else
             if (l.StartsWith("=COMMAND")) {             if (l.StartsWith("=COMMAND")) {
-                ProcessDocCOMMAND(sb, l);+ cmd = ProcessDocCOMMAND(currCmdStr, l);
             } else             } else
             if (l.StartsWith("=DESC")) {             if (l.StartsWith("=DESC")) {
-                i = ProcessDocDESC(sb, lines, i);+ i = ProcessDocDESC(currCmdStr, lines, i);
             } else             } else
             if (l.StartsWith("=EX")) {             if (l.StartsWith("=EX")) {
-                i = ProcessDocEX(sb, lines, i);+ i = ProcessDocEX(currCmdStr, lines, i);
             }             }
         }         }
         currentSection = startingSection;         currentSection = startingSection;
- + sb.Append(cmd); 
-        sb.Append("</div>\r\n"); + sb.Append(currCmdStr); 
-        sb.Append("</div>\r\n");+        sb.Append("\t\t</div>\r\n"); 
 +        sb.Append("\t</div>\r\n");
  
         return i;         return i;
Line 230: Line 306:
     }     }
  
-    private void ProcessDocCOMMAND(System.Text.StringBuilder sb, string l) {+    private string ProcessDocCOMMAND(System.Text.StringBuilder sb, string l) {
         string cmd = l.Substring("=COMMAND".Length).Trim();         string cmd = l.Substring("=COMMAND".Length).Trim();
         string[] splitcmd = cmd.Split(' ', '(');         string[] splitcmd = cmd.Split(' ', '(');
Line 241: Line 317:
         }         }
         section.Add(new Tuple<int, string>(cmdCount, splitcmd[0]));         section.Add(new Tuple<int, string>(cmdCount, splitcmd[0]));
-        sb.Append("<div id='cmd" + cmdCount.ToString() + "' class='command_syntax'>\r\n");+ sb.Append("\t\t<div class='command_syntax'><a onclick=handleListClick(event)>");
         sb.Append(cmd);         sb.Append(cmd);
-        sb.Append("<span class='backtotop'><a href='#index'>[TOP]</a></span>"); +        //sb.Append("<span class='backtotop'><a href='#index'>[TOP]</a></span>"); 
-        sb.Append("</div>\r\n");+        sb.Append("</a></div>\r\n");
         cmdCount++;         cmdCount++;
 + return splitcmd [0];
     }     }
  
     private int ProcessDocDESC(System.Text.StringBuilder sb, string[] lines, int pos) {     private int ProcessDocDESC(System.Text.StringBuilder sb, string[] lines, int pos) {
-        sb.Append("<div class='command_body'>\r\n"); +        sb.Append("\t\t<div class='command_body'>\r\n"); 
-        sb.Append("<div class='description'>\r\n"); +        sb.Append("\t\t\t<div class='description'>\r\n"); 
-        sb.Append("<b>Description</b>\r\n"); +        sb.Append("\t\t\t\t<b>Description</b>\r\n"); 
-        sb.Append("<div>\r\n");+        sb.Append("\t\t\t\t<div>\r\n");
         int i;         int i;
         for (i = pos + 1; i < lines.Length; i++) {         for (i = pos + 1; i < lines.Length; i++) {
Line 262: Line 339:
             }             }
         }         }
-        sb.Append("</div>\r\n"); +        sb.Append("\n\t\t\t</div>\r\n"); 
-        sb.Append("</div>\r\n");+        sb.Append("\t\t</div>\r\n");
  
-        sb.Append("<div>\r\n"); +        sb.Append("\t\t<div>\r\n"); 
-        sb.Append("<b>Examples</b>\r\n"); +        sb.Append("\t\t\t<b>Examples</b>\r\n"); 
-        sb.Append("</div>\r\n");+        sb.Append("\t\t</div>\r\n");
         return i;         return i;
     }     }
  
     private int ProcessDocEX(System.Text.StringBuilder sb, string[] lines, int pos) {     private int ProcessDocEX(System.Text.StringBuilder sb, string[] lines, int pos) {
-        sb.Append("<div class='example'>\r\n"); +        sb.Append("\t\t\t<div class='example'>\r\n"); 
-        sb.Append("<code>");+        sb.Append("\t\t\t\t<code>\n");
         int i;         int i;
         for (i = pos + 1; i < lines.Length; i++) {         for (i = pos + 1; i < lines.Length; i++) {
Line 283: Line 360:
             }             }
         }         }
-        sb.Append("</code>\r\n"); +        sb.Append("\t\t\t\t</code>\r\n"); 
-        sb.Append("</div>\r\n");+        sb.Append("\t\t\t</div>\r\n");
         return i;         return i;
     }     }
-    #region constant text 
-    public const string flubberyGibbet = @"Simple text"; 
-    #endregion 
 } }
  
 </code> </code>
pf/rpldocs/prpldoccompiler_compare.1476978613.txt.gz · Last modified: 2025/02/14 14:56 (external edit)