//will insert <a> tags for any links it finds in the source string private string convertLinkTags(string source) { //EngineGovernor.log("DEBUG - : Checking '" + source + "' for links...", 1); if (source.Contains("@l:") || source.Contains("@link:")) { string[] words = source.Split(' '); string result = ""; for (int i = 0; i < words.Length; i++) { if (words[i].Contains("@l:") || words[i].Contains("@link:")) { string linkText = ""; if (words[i].IndexOf("@l:") != -1 && words[i].Length > words[i].IndexOf("@l:") + 3) { linkText = words[i].Substring(words[i].IndexOf("@l:") + 3); } else if (words[i].IndexOf("@link:") != -1 && words[i].Length > words[i].IndexOf("@link:") + 6) { linkText = words[i].Substring(words[i].IndexOf("@link:") + 6); } else { EngineGovernor.log("WARNING - Found an empty link tag: '" + source + "'", -1); } //string endpunctuation = ""; words[i] = "<a href='" + DocGenerator.makeSafeLink(linkText) + ".html'>" + linkText + "</a>"; } //recombine into the result string if (i == 0) { result = words[i]; } else { result += " " + words[i]; } } return(result); } else { return(source); } }
//returns a version of the link text WITHOUT punctuation, and lowercase, etc. etc.... // (static so that it can be accessed ffrom outside) public static string makeSafeLink(string originalLink) { string link = originalLink.ToLower(); link = DocGenerator.takeOutString(link, ","); link = DocGenerator.takeOutString(link, "."); link = DocGenerator.takeOutString(link, "'"); link = DocGenerator.takeOutString(link, "\""); link = DocGenerator.takeOutString(link, ";"); link = DocGenerator.takeOutString(link, "?"); link = DocGenerator.takeOutString(link, "!"); link = DocGenerator.takeOutString(link, "("); link = DocGenerator.takeOutString(link, ")"); link = DocGenerator.takeOutString(link, "["); link = DocGenerator.takeOutString(link, "]"); link = DocGenerator.takeOutString(link, "{"); link = DocGenerator.takeOutString(link, "}"); link = DocGenerator.takeOutString(link, "|"); link = DocGenerator.takeOutString(link, "/"); link = DocGenerator.takeOutString(link, "\\"); return(link); }
// creates the html API documentation (assumes m_cWorkingDocument has already been assigned) // NOTE: generates ALL api documentation of ALL code that has been analyzed up until this point! public void generateAPIDoc(string location, string topHeaderText) { List <List <string> > info = new List <List <string> >(); for (int i = 0; i < m_cWorkingDocuments.Count; i++) { DocGenerator generator = new DocGenerator(m_cWorkingDocuments[i], m_cWorkingDocumentsAssoc[i]); generator.TopHeaderText = topHeaderText; info.Add(generator.createHTMLDocument(location)); } // sections string sectionsJS = "var SECTION_LIST = ["; for (int i = 0; i < m_cSections.Count; i++) { sectionsJS += "'" + m_cSections[i] + "'"; if (i < m_cSections.Count - 1) { sectionsJS += ","; } } sectionsJS += "];"; writeToFile(location, "sections.js", sectionsJS); // classes string classesJS = "var CLASS_LIST = ["; for (int i = 0; i < m_cClasses.Count; i++) { string link = DocGenerator.makeSafeLink(m_cClasses[i]) + ".html"; classesJS += "'" + m_cClasses[i] + "," + m_cClassesAssoc[i] + "," + link + "'"; if (i < m_cClasses.Count - 1) { classesJS += ","; } } classesJS += "];"; writeToFile(location, "classes.js", classesJS); // write interfaces string interfacesJS = "var INTERFACE_LIST = ["; for (int i = 0; i < m_cInterfaces.Count; i++) { string link = DocGenerator.makeSafeLink(m_cInterfaces[i]) + ".html"; interfacesJS += "'" + m_cInterfaces[i] + "," + m_cInterfacesAssoc[i] + "," + link + "'"; if (i < m_cInterfaces.Count - 1) { interfacesJS += ","; } } interfacesJS += "];"; writeToFile(location, "interfaces.js", interfacesJS); // write "files" string filesJS = "var FILE_LIST = ["; for (int i = 0; i < m_cFiles.Count; i++) { string link = DocGenerator.makeSafeLink(m_cFiles[i]) + ".html"; filesJS += "'" + m_cFiles[i] + "," + m_cFilesAssoc[i] + "," + link + "'"; if (i < m_cFiles.Count - 1) { filesJS += ","; } } filesJS += "];"; writeToFile(location, "files.js", filesJS); createIndex(info, topHeaderText, location); }