public ProjectXmlDocs(XmlDocument xml) { _docs = new Dictionary <string, MemberXmlDocs>(); _xml = xml; foreach (XmlNode item in xml.SelectNodes("//doc/members/member")) { var id = item.Attributes["name"].Value; var data = _docs[id] = new MemberXmlDocs { Summary = item.SelectSingleNode("summary")?.InnerText.Trim() ?? "(No Description)", Returns = item.SelectSingleNode("returns")?.InnerText.Trim() ?? String.Empty, Remarks = item.SelectSingleNode("remarks")?.InnerText.Trim() ?? String.Empty }; foreach (XmlNode desc in item.SelectNodes("param")) { data.SetParameterDescription(desc.Attributes["name"].Value, desc.InnerText.Trim()); } foreach (XmlNode desc in item.SelectNodes("typeparam")) { data.SetTypeParameterDescription(desc.Attributes["name"].Value, desc.InnerText.Trim()); } } }
private static void Returns(int rank, MemberXmlDocs docs, MarkdownWriter writer) { var returns = docs?.Returns; if (!String.IsNullOrWhiteSpace(returns)) { writer.WriteHeader(rank, "Returns"); writer.WriteParagraph(returns); } }
private static string TypeParam(MemberXmlDocs docs, string name) => docs?.GetTypeParameterDescription(name) ?? "_No Description_";
private static string Param(MemberXmlDocs docs, ParameterInfo param) => docs?.GetParameterDescription(param.Name) ?? "_No Description_";
private static void Summary(MemberXmlDocs docs, MarkdownWriter writer) => writer.WriteParagraph(docs?.Summary ?? "_No Summary_");
private void WriteParamList(int rank, MethodBase method, MarkdownWriter writer, MemberXmlDocs docs) { var plist = method.GetParameters(); if (method.ContainsGenericParameters) { var tplist = method.GetGenericArguments(); writer.WriteParagraph("**Type Parameters**"); for (int i = 0; i < tplist.Length; i++) { writer.WriteLine($"- `{tplist[i].Name}`: {TypeParam(docs, tplist[i].Name)}"); } } if (plist.Length > 0) { writer.WriteParagraph("**Parameters**"); for (int i = 0; i < plist.Length; i++) { writer.WriteLine($"- `{plist[i].Name}`: {Param(docs, plist[i])}"); } } }