public void VisitSee(INode see) { string cref = see.GetAttribute("cref"); if (cref == null) { cref = String.Empty; Console.WriteLine("Warning: cref attribute absent in <see>"); } if (cref.Substring(0, 2).Equals("T:", StringComparison.Ordinal)) { string typeName = TypeNameUtil.UndecorateTypeName(cref.Substring(2)); string content = DocGenUtil.HtmlEscape(see.GetContent()); if (String.IsNullOrEmpty(content)) { content = typeName; } this.Write("[" + content + "]"); this.Write("(" + typeName + ".md)"); XmlDoc.VisitInnerNode(see, this); } else if (cref.Substring(0, 2).Equals("M:", StringComparison.Ordinal)) { string content = DocGenUtil.HtmlEscape(see.GetContent()); if (String.IsNullOrEmpty(content)) { content = cref; } this.Write("**" + content + "**"); } else { XmlDoc.VisitInnerNode(see, this); } }
public void Finish() { var sb = new StringBuilder(); string finalString; sb.Append("### Member Summary\n"); foreach (var key in this.docs.Keys) { finalString = this.docs[key].ToString(); var typeName = this.memberFormats[key]; typeName = typeName.Replace("&", "&"); typeName = typeName.Replace("<", "<"); typeName = typeName.Replace(">", ">"); typeName = "[" + typeName + "](#" + key + ")"; finalString = Regex.Replace(finalString, "\\s+", " "); if (finalString.IndexOf(".", StringComparison.Ordinal) >= 0) { finalString = finalString.Substring( 0, finalString.IndexOf(".", StringComparison.Ordinal) + 1); } sb.Append("* <code>" + typeName + "</code> - "); sb.Append(finalString + "\n"); } finalString = DocGenUtil.NormalizeLines(sb.ToString()); this.summaryString = finalString; }
public TypeLinkAndBuilder(Type type) { var typeName = DocVisitor.FormatType(type); typeName = "[" + DocGenUtil.HtmlEscape(typeName) + "](" + DocVisitor.GetTypeID(type) + ".md)"; this.TypeLink = typeName; this.Builder = new StringBuilder(); }
public void Finish() { var sb = new StringBuilder(); string finalString; sb.Append("## API Documentation\r\n\r\n"); foreach (var key in this.docs.Keys) { finalString = this.docs[key].Builder.ToString(); sb.Append(" * " + this.docs[key].TypeLink + " - "); sb.Append(finalString + "\n"); } finalString = DocGenUtil.NormalizeLines( sb.ToString()); DocGenUtil.FileEdit(this.filename, finalString); }
public void Finish() { var sb = new StringBuilder(); string finalString; sb.Append("### Member Summary\n"); foreach (var key in this.docs.Keys) { finalString = this.docs[key].ToString(); var typeName = this.memberFormats[key]; typeName = "[" + DocGenUtil.HtmlEscape(typeName) + "](#" + key + ")"; finalString = Regex.Replace(finalString, "\\s+", " "); sb.Append("* <code>" + typeName + "</code> - "); sb.Append(finalString + "\n"); } finalString = DocGenUtil.NormalizeLines(sb.ToString()); this.summaryString = finalString; }
public void Finish() { foreach (var key in this.docs.Keys) { var finalString = this.docs[key].ToString(); this.memSummaries[key].Finish(); var memSummaryString = this.memSummaries[key].ToString(); var filename = Path.Combine( this.directory, this.typeIDs[key] + ".md"); finalString = DocGenUtil.NormalizeLines(finalString); finalString = Regex.Replace( finalString, "<<<MEMBER_SUMMARY>>>", memSummaryString); DocGenUtil.FileEdit(filename, finalString); } }
internal static string GetSummary(MemberInfo info, XmlDoc xdoc, string memberName) { string summary; var attr = info?.GetCustomAttribute(typeof(ObsoleteAttribute)) as ObsoleteAttribute; summary = (attr != null) ? ("<b>Deprecated:</b> " + DocGenUtil.HtmlEscape(attr.Message)) : xdoc?.GetSummary(memberName); if (summary != null && attr == null && summary.IndexOf(".", StringComparison.Ordinal) >= 0) { summary = summary.Substring( 0, summary.IndexOf(".", StringComparison.Ordinal) + 1); } return(summary); }
public void Finish() { var sb = new StringBuilder(); string finalString; sb.Append("## API Documentation\r\n\r\n"); foreach (var key in this.docs.Keys) { finalString = this.docs[key].Builder.ToString(); if (finalString.IndexOf(".", StringComparison.Ordinal) >= 0) { finalString = finalString.Substring( 0, finalString.IndexOf(".", StringComparison.Ordinal) + 1); } sb.Append(" * " + this.docs[key].TypeLink + " - "); sb.Append(finalString + "\n"); } finalString = DocGenUtil.NormalizeLines( sb.ToString()); DocGenUtil.FileEdit(this.filename, finalString); }
public void HandleMember(MemberInfo info, XmlDoc xmldoc) { var signature = String.Empty; var mnu = TypeNameUtil.XmlDocMemberName(info); var mnm = xmldoc.GetMemberNode(mnu); if (info is MethodBase) { var method = (MethodBase)info; if (!method.IsPublic && !method.IsFamily) { // Ignore methods other than public and protected // methods return; } if (mnm == null) { Console.WriteLine("member info not found: " + mnu); return; } using (var ch = this.AddMember(info)) { signature = FormatMethod(method, false); this.WriteLine("<a id=\"" + MemberSummaryVisitor.MemberAnchor(info) + "\"></a>"); this.WriteLine("### " + Heading(info) + "\r\n\r\n" + signature + "\r\n\r\n"); var attr = method.GetCustomAttribute(typeof(ObsoleteAttribute)) as ObsoleteAttribute; if (attr != null) { this.WriteLine("<b>Deprecated.</b> " + DocGenUtil.HtmlEscape(attr.Message) + "\r\n\r\n"); } var cattr = method.GetCustomAttribute(typeof(CLSCompliantAttribute)) as CLSCompliantAttribute; if (cattr != null && !cattr.IsCompliant) { this.WriteLine("<b>This API is not CLS-compliant.</b>\r\n\r\n"); } this.paramStr.Clear(); this.returnStr.Clear(); this.exceptionStr.Clear(); XmlDoc.VisitInnerNode(mnm, this); if (this.paramStr.Length > 0) { this.Write("<b>Parameters:</b>\r\n\r\n"); var paramString = this.paramStr.ToString(); // Decrease spacing between list items paramString = paramString.Replace("\r\n * ", " * "); this.Write(paramString); } this.Write(this.returnStr.ToString()); if (this.exceptionStr.Length > 0) { this.Write("<b>Exceptions:</b>\r\n\r\n"); this.Write(this.exceptionStr.ToString()); } } } else if (info is Type) { var type = (Type)info; if (!(type.IsNested ? type.IsNestedPublic : type.IsPublic)) { // Ignore nonpublic types return; } if (mnm == null) { Console.WriteLine("member info not found: " + mnu); return; } using (var ch = this.AddMember(info)) { this.WriteLine("## " + Heading(type) + "\r\n\r\n"); this.WriteLine(FormatTypeSig(type) + "\r\n\r\n"); var attr = type.GetCustomAttribute(typeof(ObsoleteAttribute)) as ObsoleteAttribute; if (attr != null) { this.WriteLine("<b>Deprecated.</b> " + attr.Message + "\r\n\r\n"); } var cattr = type.GetCustomAttribute(typeof(CLSCompliantAttribute)) as CLSCompliantAttribute; if (cattr != null && !cattr.IsCompliant) { this.WriteLine("<b>This API is not CLS-compliant.</b>\r\n\r\n"); } this.paramStr.Clear(); XmlDoc.VisitInnerNode(mnm, this); this.Write("\r\n\r\n"); this.WriteLine("<<<MEMBER_SUMMARY>>>"); if (this.paramStr.Length > 0) { this.Write("<b>Parameters:</b>\r\n\r\n"); var paramString = this.paramStr.ToString(); // Decrease spacing between list items paramString = paramString.Replace("\r\n * ", " * "); this.Write(paramString); } } } else if (info is PropertyInfo) { var property = (PropertyInfo)info; if (!PropertyIsPublicOrFamily(property)) { // Ignore methods other than public and protected // methods return; } if (mnm == null) { Console.WriteLine("member info not found: " + mnu); return; } using (var ch = this.AddMember(info)) { signature = FormatProperty(property); this.WriteLine("<a id=\"" + MemberSummaryVisitor.MemberAnchor(info) + "\"></a>"); this.WriteLine("### " + property.Name + "\r\n\r\n" + signature + "\r\n\r\n"); var attr = property.GetCustomAttribute(typeof(ObsoleteAttribute)) as ObsoleteAttribute; if (attr != null) { this.WriteLine("<b>Deprecated.</b> " + attr.Message + "\r\n\r\n"); } var cattr = property.GetCustomAttribute(typeof(CLSCompliantAttribute)) as CLSCompliantAttribute; if (cattr != null && !cattr.IsCompliant) { this.WriteLine("<b>This API is not CLS-compliant.</b>\r\n\r\n"); } this.paramStr.Clear(); this.returnStr.Clear(); this.exceptionStr.Clear(); XmlDoc.VisitInnerNode(mnm, this); if (this.paramStr.Length > 0) { this.Write("<b>Parameters:</b>\r\n\r\n"); this.Write(this.paramStr.ToString()); } this.Write(this.returnStr.ToString()); if (this.exceptionStr.Length > 0) { this.Write("<b>Exceptions:</b>\r\n\r\n"); this.Write(this.exceptionStr.ToString()); } } } else if (info is FieldInfo) { var field = (FieldInfo)info; if (!field.IsPublic && !field.IsFamily) { // Ignore nonpublic, nonprotected fields return; } if (mnm == null) { Console.WriteLine("member info not found: " + mnu); return; } using (var ch = this.AddMember(info)) { signature = FormatField(field); this.WriteLine("<a id=\"" + MemberSummaryVisitor.MemberAnchor(info) + "\"></a>"); this.WriteLine("### " + field.Name + "\r\n\r\n" + signature + "\r\n\r\n"); var attr = field.GetCustomAttribute(typeof(ObsoleteAttribute)) as ObsoleteAttribute; if (attr != null) { this.WriteLine("<b>Deprecated.</b> " + attr.Message + "\r\n\r\n"); } var cattr = field.GetCustomAttribute(typeof(CLSCompliantAttribute)) as CLSCompliantAttribute; if (cattr != null && !cattr.IsCompliant) { this.WriteLine("<b>This API is not CLS-compliant.</b>\r\n\r\n"); } XmlDoc.VisitInnerNode(mnm, this); } } }
public void VisitNode(INode node) { if (String.IsNullOrEmpty(node.LocalName)) { var t = node.GetContent(); // Collapse multiple spaces into a single space t = Regex.Replace(t, @"\s+", " "); if (t.Length != 1 || t[0] != ' ') { // Don't write if result is a single space this.Write(t); } XmlDoc.VisitInnerNode(node, this); } else { var xmlName = PeterO.DataUtilities.ToLowerCaseAscii(node.LocalName); if (xmlName.Equals("c", StringComparison.Ordinal)) { this.VisitC(node); } else if (xmlName.Equals("code", StringComparison.Ordinal)) { this.VisitCode(node); } else if (xmlName.Equals("example", StringComparison.Ordinal)) { this.VisitExample(node); } else if (xmlName.Equals("exception", StringComparison.Ordinal)) { this.VisitException(node); } else if (xmlName.Equals("see", StringComparison.Ordinal)) { this.VisitSee(node); } else if (xmlName.Equals("item", StringComparison.Ordinal)) { this.VisitItem(node); } else if (xmlName.Equals("list", StringComparison.Ordinal)) { this.VisitList(node); } else if (xmlName.Equals("para", StringComparison.Ordinal)) { this.VisitPara(node); } else if (xmlName.Equals("param", StringComparison.Ordinal)) { this.VisitParam(node); } else if (xmlName.Equals("paramref", StringComparison.Ordinal)) { this.VisitParamRef(node); } else if (xmlName.Equals("remarks", StringComparison.Ordinal) || xmlName.Equals("summary", StringComparison.Ordinal)) { XmlDoc.VisitInnerNode(node, this); this.Write("\r\n\r\n"); } else if (xmlName.Equals("returns", StringComparison.Ordinal)) { this.VisitReturns(node); } else if (xmlName.Equals("typeparam", StringComparison.Ordinal)) { this.VisitTypeParam(node); } else if (xmlName.Equals("value", StringComparison.Ordinal)) { this.VisitValue(node); } else if (xmlName.Equals("b", StringComparison.Ordinal) || xmlName.Equals("strong", StringComparison.Ordinal) || xmlName.Equals("i", StringComparison.Ordinal) || xmlName.Equals("a", StringComparison.Ordinal) || xmlName.Equals("sup", StringComparison.Ordinal) || xmlName.Equals("em", StringComparison.Ordinal)) { var sb = new StringBuilder(); sb.Append("<" + xmlName); foreach (var attr in node.GetAttributes()) { sb.Append(" " + attr + "="); sb.Append("\"" + DocGenUtil.HtmlEscape( node.GetAttribute(attr)) + "\""); } sb.Append('>'); this.Write(sb.ToString()); XmlDoc.VisitInnerNode(node, this); this.Write("</" + xmlName + ">"); } else { XmlDoc.VisitInnerNode(node, this); } } }