This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
pf:rpldocs:prpldoccompiler_compare [2016/10/20 15:50] – created with K75 Version Karsten75 | pf: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< | private OrderedDictionaryG< | ||
- | + | | |
- | public string | + | public string |
public void MakePRPLDocs(Main main, string srcDir, string outputDir) { | public void MakePRPLDocs(Main main, string srcDir, string outputDir) { | ||
this.main = main; | this.main = main; | ||
- | | + | |
cmdCount = 0; | cmdCount = 0; | ||
currentSection = null; | currentSection = null; | ||
sectionDict = new OrderedDictionaryG< | sectionDict = new OrderedDictionaryG< | ||
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 + " | docIndexLines = System.IO.File.ReadAllLines(srcDir + " | ||
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(@" | ||
< | < | ||
Line 68: | Line 64: | ||
} | } | ||
.command_syntax { padding: 1px 5px; font-size: 110%; font-weight: | .command_syntax { padding: 1px 5px; font-size: 110%; font-weight: | ||
- | .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: | .index {border-spacing: | ||
.index tr{vertical-align: | .index tr{vertical-align: | ||
Line 79: | Line 75: | ||
.section tr: | .section tr: | ||
.sectionHead{background-color:# | .sectionHead{background-color:# | ||
- | .backtotop{font-size:60%; padding:0; float:right} | + | .fullList{font-size:55%; padding:0} |
</style > | </style > | ||
</head > | </head > | ||
+ | < | ||
+ | <div id="" | ||
"); | "); | ||
- | # | + | sb.Append("" |
- | + | GenerateDocSections(sb,sbIndex); | |
- | GenerateDocSections(sb); | + | sb.Append(" |
- | sb.Append("< | + | |
sb.Append(sbcommands); | sb.Append(sbcommands); | ||
- | | + | sb.Append(@" |
+ | </ | ||
+ | <div class="" | ||
+ | "); | ||
+ | sb.Append(sbIndex); | ||
+ | sb.Append(@"</ | ||
+ | <script type="" | ||
+ | function handleListClick(e) { | ||
+ | var anchor = e.target; | ||
+ | var cmd = anchor.firstChild.nodeValue; | ||
+ | |||
+ | // | ||
+ | // | ||
+ | // | ||
+ | funcById(cmd, | ||
+ | document.title = defaultTitle + "": | ||
+ | } | ||
+ | |||
+ | function handleListSectionTitleClick(e) { | ||
+ | toggle(e.target.parentElement.parentElement.nextElementSibling); | ||
+ | document.title = defaultTitle; | ||
+ | } | ||
+ | |||
+ | function toggle(elem) { | ||
+ | if (elem.style.display == "" | ||
+ | elem.style.display = """"; | ||
+ | } else { | ||
+ | elem.style.display = "" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function funcById(id, | ||
+ | func(document.getElementById(id)); | ||
+ | } | ||
+ | |||
+ | function close(elem) { | ||
+ | elem.style.display = "" | ||
+ | } | ||
+ | |||
+ | function open(elem) { | ||
+ | elem.style.display = """"; | ||
+ | } | ||
+ | |||
+ | var defaultTitle = "" | ||
+ | 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;// | ||
+ | var docCmd; | ||
+ | // | ||
+ | open(cmdList); | ||
+ | while (docSection.tagName !== "" | ||
+ | docCmd = docSection.firstElementChild; | ||
+ | while (docCmd !== null) { | ||
+ | close(docCmd); | ||
+ | docCmd = docCmd.nextElementSibling; | ||
+ | } | ||
+ | docSection = docSection.nextElementSibling; | ||
+ | } | ||
+ | } | ||
+ | reset(); | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
System.IO.File.WriteAllText(outputDir + " | System.IO.File.WriteAllText(outputDir + " | ||
- | | + | |
- | main.LogMessage(" | + | main.LogMessage(" |
- | Debug.Log(" | + | |
- | main.LogMessage(" | + | |
} catch (Exception e) { | } catch (Exception e) { | ||
main.LogMessage(" | main.LogMessage(" | ||
Line 103: | Line 170: | ||
currentSection = sect; | currentSection = sect; | ||
string f = srcDir + sect + " | string f = srcDir + sect + " | ||
- | int cmdSubtotal = 0; | ||
main.LogMessage(" | main.LogMessage(" | ||
if (System.IO.File.Exists(f)) { | if (System.IO.File.Exists(f)) { | ||
Line 111: | Line 177: | ||
if (l.StartsWith(" | if (l.StartsWith(" | ||
i = ProcessDocCMD(sbcommands, | i = ProcessDocCMD(sbcommands, | ||
- | cmdSubtotal++; | ||
} | } | ||
} | } | ||
- | this.cmdTotal += cmdSubtotal; | ||
- | main.LogMessage(" | ||
- | Debug.Log(" | ||
} else { | } else { | ||
main.LogMessage(" | main.LogMessage(" | ||
Line 122: | Line 184: | ||
} | } | ||
- | | + | private void GenerateDocSections(System.Text.StringBuilder sb, System.Text.StringBuilder sbIndex) { |
- | sb.Append("< | + | sb.Append("< |
- | bool open = false; | + | |
for (int i = 0; i < docIndexLines.Length; | for (int i = 0; i < docIndexLines.Length; | ||
- | | + | |
- | | + | //sb.Append("< |
- | open = true; | + | |
- | } | + | |
- | + | ||
- | | + | |
if (!sectionDict.ContainsKey(docIndexLines[i].Trim())) { | if (!sectionDict.ContainsKey(docIndexLines[i].Trim())) { | ||
sb.Append("& | sb.Append("& | ||
} else { | } else { | ||
- | | + | GenerateDocSection(sb, sbIndex, docIndexLines[i].Trim()); |
} | } | ||
- | sb.Append("</ | + | |
- | if (i % 2 == 1) { | + | |
- | sb.Append("</ | + | // sb.Append("</ |
- | open = false; | + | |
- | } | + | |
} | } | ||
- | if (open) { | + | |
- | sb.Append("</ | + | |
- | open = false; | + | |
- | } | + | |
- | sb.Append("</ | + | |
+ | sb.Append("< | ||
+ | sb.Append("< | ||
+ | GenerateDocSection(sb, | ||
+ | sb.Append("</ | ||
+ | |||
+ | sb.Append("< | ||
+ | GenerateDocSection(sb, | ||
+ | sb.Append("</ | ||
+ | |||
+ | sb.Append("</ | ||
+ | */ | ||
+ | |||
+ | sb.Append("</ | ||
} | } | ||
- | | + | private void GenerateDocSection(System.Text.StringBuilder sb, System.Text.StringBuilder sbIndex, string section) { |
- | int cols = 2; | + | int cols = 1; |
- | sb.Append("< | + | sb.Append("< |
- | sb.Append(" | + | sb.Append(" |
- | sb.Append(" | + | |
- | sb.Append("</ | + | |
List< | List< | ||
int cc = 0; | int cc = 0; | ||
- | bool open = false; | + | // |
+ | // open = false; | ||
foreach (Tuple< | foreach (Tuple< | ||
if (cc % cols == 0) { | if (cc % cols == 0) { | ||
- | sb.Append("< | + | sb.Append(" |
- | open = true; | + | |
} | } | ||
Line 174: | Line 244: | ||
cs = ""; | cs = ""; | ||
} | } | ||
- | | + | sb.Append(" |
+ | sbIndex.Append(" | ||
if (cc % cols == cols-1) { | if (cc % cols == cols-1) { | ||
- | sb.Append("</ | + | sb.Append(" |
- | open = false; | + | |
} | } | ||
cc++; | cc++; | ||
} | } | ||
- | if (open) { | + | |
- | sb.Append("</ | + | sb.Append(" |
- | open = false; | + | // open = false; |
- | } | + | |
+ | // | ||
sb.Append("</ | sb.Append("</ | ||
} | } | ||
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) { | ||
- | | + | System.Text.StringBuilder currCmdStr = new System.Text.StringBuilder (); |
- | <div class=' | + | string cmd = ""; |
- | "); | + | |
+ | sb.Append (@" | ||
+ | <div class=' | ||
+ | currCmdStr.Append(" | ||
string startingSection = currentSection; | string startingSection = currentSection; | ||
int i; | int i; | ||
Line 202: | Line 277: | ||
} else | } else | ||
if (l.StartsWith(" | if (l.StartsWith(" | ||
- | | + | ProcessDocCMDCLASS(currCmdStr, l); |
} else | } else | ||
if (l.StartsWith(" | if (l.StartsWith(" | ||
- | | + | cmd = ProcessDocCOMMAND(currCmdStr, l); |
} else | } else | ||
if (l.StartsWith(" | if (l.StartsWith(" | ||
- | | + | i = ProcessDocDESC(currCmdStr, lines, i); |
} else | } else | ||
if (l.StartsWith(" | if (l.StartsWith(" | ||
- | | + | i = ProcessDocEX(currCmdStr, lines, i); |
} | } | ||
} | } | ||
currentSection = startingSection; | currentSection = startingSection; | ||
- | + | sb.Append(cmd); | |
- | sb.Append("</ | + | sb.Append(currCmdStr); |
- | sb.Append("</ | + | sb.Append(" |
+ | sb.Append(" | ||
return i; | return i; | ||
Line 230: | Line 306: | ||
} | } | ||
- | private | + | private |
string cmd = l.Substring(" | string cmd = l.Substring(" | ||
string[] splitcmd = cmd.Split(' | string[] splitcmd = cmd.Split(' | ||
Line 241: | Line 317: | ||
} | } | ||
section.Add(new Tuple< | section.Add(new Tuple< | ||
- | | + | sb.Append(" |
sb.Append(cmd); | sb.Append(cmd); | ||
- | sb.Append("< | + | |
- | sb.Append("</ | + | sb.Append(" |
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("< | + | sb.Append(" |
- | sb.Append("< | + | sb.Append(" |
- | sb.Append("< | + | sb.Append(" |
- | sb.Append("< | + | sb.Append(" |
int i; | int i; | ||
for (i = pos + 1; i < lines.Length; | for (i = pos + 1; i < lines.Length; | ||
Line 262: | Line 339: | ||
} | } | ||
} | } | ||
- | sb.Append("</ | + | sb.Append(" |
- | sb.Append("</ | + | sb.Append(" |
- | sb.Append("< | + | sb.Append(" |
- | sb.Append("< | + | sb.Append(" |
- | sb.Append("</ | + | sb.Append(" |
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("< | + | sb.Append(" |
- | sb.Append("< | + | sb.Append(" |
int i; | int i; | ||
for (i = pos + 1; i < lines.Length; | for (i = pos + 1; i < lines.Length; | ||
Line 283: | Line 360: | ||
} | } | ||
} | } | ||
- | sb.Append("</ | + | sb.Append(" |
- | sb.Append("</ | + | sb.Append(" |
return i; | return i; | ||
} | } | ||
- | #region constant text | ||
- | public const string flubberyGibbet = @" | ||
- | #endregion | ||
} | } | ||
</ | </ |