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 VisitValue(INode node) { using (var ch = this.Change(this.returnStr)) { this.WriteLine("<b>Returns:</b>\r\n"); XmlDoc.VisitInnerNode(node, this); this.WriteLine("\r\n\r\n"); } }
public void VisitTypeParam(INode node) { using (var ch = this.Change(this.paramStr)) { this.Write(" * <" + node.GetAttribute("name") + ">: "); XmlDoc.VisitInnerNode(node, this); this.WriteLine("\r\n\r\n"); } }
public void VisitException(INode node) { using (var ch = this.Change(this.exceptionStr)) { var cref = node.GetAttribute("cref"); if (cref.StartsWith("T:", StringComparison.Ordinal)) { cref = cref.Substring(2); } this.WriteLine(" * " + cref + ": "); XmlDoc.VisitInnerNode(node, this); this.WriteLine("\r\n\r\n"); } }
public void VisitException(INode node) { using (var ch = this.Change(this.exceptionStr)) { var cref = node.GetAttribute("cref"); if (cref == null) { cref = String.Empty; Console.WriteLine("Warning: cref attribute absent in <exception>"); } if (cref.StartsWith("T:", StringComparison.Ordinal)) { cref = cref.Substring(2); } this.WriteLine(" * " + cref + ": "); XmlDoc.VisitInnerNode(node, this); this.WriteLine("\r\n\r\n"); } }
public void VisitNode(INode node) { if (String.IsNullOrEmpty(node.LocalName)) { this.sb.Append(node.GetContent()); } else { var c = node.GetAttribute("cref"); var n = node.GetAttribute("name"); if (c != null) { this.sb.Append(c); } else if (n != null) { this.sb.Append(n); } } XmlDoc.VisitInnerNode(node, this); }
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 VisitList(INode node) { this.WriteLine("\r\n\r\n"); XmlDoc.VisitInnerNode(node, this); }
public void VisitExample(INode node) { XmlDoc.VisitInnerNode(node, this); this.WriteLine("\r\n\r\n"); }
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); } } }
public void VisitParamRef(INode node) { this.WriteLine(" <i>" + node.GetAttribute("name") + "</i>"); XmlDoc.VisitInnerNode(node, this); }