public override string OutputOf(IList <Topic> topics) { if (topics == null || topics.Count == 0) { return("(No topics found)"); } StringBuilder output = new StringBuilder(); for (int topicIndex = 0; topicIndex < topics.Count; topicIndex++) { if (topicIndex != 0) { output.AppendLine(); output.AppendLine("------------------------------"); output.AppendLine(); } if (topics[topicIndex].Prototype == null) { output.AppendLine("(No prototype detected)"); continue; } var parsedPrototype = topics[topicIndex].ParsedPrototype; for (int sectionIndex = 0; sectionIndex < parsedPrototype.Sections.Count; sectionIndex++) { if (sectionIndex != 0) { output.AppendLine(); } if (parsedPrototype.Sections[sectionIndex] is Prototypes.ParameterSection) { Prototypes.ParameterSection section = (parsedPrototype.Sections[sectionIndex] as Prototypes.ParameterSection); output.AppendLine("- Parameter Section:"); TokenIterator start, end; section.GetBeforeParameters(out start, out end); output.AppendLine(" - Before Parameters: " + start.TextBetween(end)); output.AppendLine(" - Access Level: " + section.GetAccessLevel()); output.Append(" - Link Candidates: "); AppendLinkCandidates(start, end, output); output.AppendLine(); for (int paramIndex = 0; paramIndex < section.NumberOfParameters; paramIndex++) { output.AppendLine(); section.GetParameterBounds(paramIndex, out start, out end); output.AppendLine(" - Parameter " + (paramIndex + 1) + ": " + start.TextBetween(end)); if (section.GetParameterName(paramIndex, out start, out end)) { output.AppendLine(" - Name: " + start.TextBetween(end)); } else { output.AppendLine(" - Name: (not detected)"); } string fullType = null; if (section.BuildFullParameterType(paramIndex, out start, out end, false)) { fullType = start.TextBetween(end); } string impliedType = null; if (section.BuildFullParameterType(paramIndex, out start, out end, true)) { impliedType = start.TextBetween(end); } if (fullType != null) { output.AppendLine(" - Full Type: " + fullType); } if (impliedType != null) { if (fullType == null) { output.AppendLine(" - Full Type (implied): " + impliedType); } else if (impliedType != fullType) { output.AppendLine(" - Full Type (plus implied): " + impliedType); } } if (fullType == null && impliedType == null) { output.AppendLine(" - Full Type: (not detected)"); } if (section.GetBaseParameterType(paramIndex, out start, out end, false)) { output.AppendLine(" - Base Type: " + start.TextBetween(end)); } else if (section.GetBaseParameterType(paramIndex, out start, out end, true)) { output.AppendLine(" - Base Type (implied): " + start.TextBetween(end)); } else { output.AppendLine(" - Base Type: (not detected)"); } section.GetParameterBounds(paramIndex, out start, out end); output.Append(" - Link Candidates: "); AppendLinkCandidates(start, end, output); output.AppendLine(); if (section.GetParameterDefaultValue(paramIndex, out start, out end)) { output.AppendLine(" - Default Value: " + start.TextBetween(end)); } else { output.AppendLine(" - Default Value: (not detected)"); } } if (section.GetAfterParameters(out start, out end)) { output.AppendLine(); output.AppendLine(" - After Parameters: " + start.TextBetween(end)); output.Append(" - Link Candidates: "); AppendLinkCandidates(start, end, output); output.AppendLine(); } } else // Plain section { Prototypes.Section section = parsedPrototype.Sections[sectionIndex]; output.AppendLine("- Plain Section: " + section.Start.TextBetween(section.End)); output.AppendLine(" - Access Level: " + section.GetAccessLevel()); output.Append(" - Link Candidates: "); AppendLinkCandidates(section.Start, section.End, output); output.AppendLine(); } } } return(output.ToString()); }
/* Function: AppendParameterSection * Builds the HTML for a <Prototypes.ParameterSection>. It will always be in wide form. */ protected void AppendParameterSection(Prototypes.ParameterSection parameterTableSection, StringBuilder output) { this.parameterTableSection = parameterTableSection; string parameterClass; switch (parameterTableSection.ParameterStyle) { case ParsedPrototype.ParameterStyle.C: parameterClass = "CStyle"; break; case ParsedPrototype.ParameterStyle.Pascal: parameterClass = "PascalStyle"; break; default: throw new NotImplementedException(); } output.Append("<div class=\"PSection PParameterSection " + parameterClass + "\">"); output.Append("<table><tr>"); TokenIterator start, end; parameterTableSection.GetBeforeParameters(out start, out end); output.Append("<td class=\"PBeforeParameters\">"); bool addNBSP = end.PreviousPastWhitespace(PreviousPastWhitespaceMode.EndingBounds, start); if (addLinks) { AppendSyntaxHighlightedTextWithTypeLinks(start, end, output, links, linkTargets); } else { AppendSyntaxHighlightedText(start, end, output); } if (addNBSP) { output.Append(" "); } output.Append("</td>"); output.Append("<td class=\"PParametersParentCell\">"); AppendParameterTable(output); output.Append("</td>"); parameterTableSection.GetAfterParameters(out start, out end); output.Append("<td class=\"PAfterParameters\">"); if (start.NextPastWhitespace(end)) { output.Append(" "); } ; if (addLinks) { AppendSyntaxHighlightedTextWithTypeLinks(start, end, output, links, linkTargets); } else { AppendSyntaxHighlightedText(start, end, output); } output.Append("</td></tr></table>"); output.Append("</div>"); }