private PageTree(string name, PageTree parent) { Name = name; Path = $"{parent.Path}/{name}"; _children = new Dictionary <string, PageTree>(); Parent = parent; }
public override void Render(PageTree parent, MarkdownWriter writer) { writer.WriteHeader(1, Title); writer.WriteParagraph(Docs?.Summary ?? "_(No Description)_"); writer.WriteHeader(2, "Signature"); writer.WriteCodeBlock("csharp", DocUtilities.GetPropertySignature(_property, true, true, true)); }
public PageTree(string name) { Name = name; Path = name; _children = new Dictionary <string, PageTree>(); Parent = null; }
public override void Render(PageTree parent, MarkdownWriter writer) { writer.WriteHeader(1, Title); foreach (var data in _methodData.OrderBy(m => m.Key.GetParameters().Length)) { var method = data.Key; var docs = data.Value; writer.WriteHeader(2, DocUtilities.GetMethodSignature(method, false, false)); writer.WriteParagraph(docs?.Summary); writer.WriteHeader(3, "Signature"); writer.WriteCodeBlock("csharp", DocUtilities.GetMethodSignature(method, true, true)); if (docs != null) { if (docs.HasTypeParameters) { writer.WriteHeader(3, "Type Parameters"); foreach (var tp in method.GetGenericArguments()) { var desc = docs?.GetTypeParameterDescription(tp.Name) ?? "_(No Description)_"; writer.WriteLine($"- `{tp.Name}`: {desc}"); } writer.WriteLine(); } if (docs.HasParameters) { writer.WriteHeader(3, "Parameters"); foreach (var p in method.GetParameters()) { var desc = docs?.GetParameterDescription(p.Name) ?? "_(No Description)_"; writer.WriteLine($"- `{p.Name}`: {desc}"); } writer.WriteLine(); } if (docs.Returns != null) { writer.WriteHeader(3, "Returns"); writer.WriteLine(docs.Returns); } if (docs.Remarks != null) { writer.WriteHeader(3, "Remarks"); writer.WriteLine(docs.Remarks); } } } }
public PageTree GetNode(string path) { PageTree child = this; var parts = path.Split('/').Select(str => str.Trim()); foreach (var part in parts) { if (String.IsNullOrWhiteSpace(part)) { return(null); } if (!child._children.TryGetValue(part, out child)) { return(null); } } return(child); }
public Page this[string path] { get { PageTree child = this; var parts = path.Split('/').Select(str => str.Trim()); foreach (var part in parts) { if (String.IsNullOrWhiteSpace(part)) { return(null); } if (!child._children.TryGetValue(part, out child)) { return(null); } } return(child.Page); } set { PageTree child = this; var parts = path.Split('/').Select(str => str.Trim()); foreach (var part in parts) { if (String.IsNullOrWhiteSpace(part)) { return; } if (child._children.TryGetValue(part, out PageTree foundChild)) { child = foundChild; } else { var oldChild = child; child = child._children[part] = new PageTree(part, oldChild); } } child.Page = value; Console.WriteLine(child.Path); } }
public override void Render(PageTree parent, MarkdownWriter writer) { writer.WriteHeader(1, Title); foreach (var(ctor, idx) in _ctors.Select((ctor, idx) => (ctor, idx))) { if (idx > 0) { writer.WriteLine(); writer.WriteLine("<p> </p>"); writer.WriteLine("<p> </p>"); writer.WriteLine("<hr/>"); writer.WriteLine(); } writer.WriteHeader(2, DocUtilities.GetMethodSignature(ctor, false, false)); var docs = _ctorsData[ctor]; writer.WriteParagraph(docs?.Summary); writer.WriteHeader(3, "Signature"); writer.WriteCodeBlock("csharp", DocUtilities.GetMethodSignature(ctor, true, true)); if (docs != null) { if (docs.HasParameters) { writer.WriteHeader(3, "Parameters"); foreach (var p in ctor.GetParameters()) { var desc = docs?.GetParameterDescription(p.Name) ?? "_(No Description)_"; writer.WriteLine($"- `{p.Name}`: {desc}"); } writer.WriteLine(); } if (docs.Remarks != null) { writer.WriteHeader(3, "Remarks"); writer.WriteLine(docs.Remarks); } } } }
public override void Render(PageTree parent, MarkdownWriter writer) { writer.WriteHeader(1, Title); writer.WriteParagraph($"**Namespace:** {Type.Namespace}"); var inheritance = DocUtilities.GetInheritanceString(Type); if (!String.IsNullOrEmpty(inheritance)) { writer.WriteParagraph($"**Inheritance:** {inheritance}"); } writer.WriteParagraph(Docs?.Summary ?? "(No Description)"); writer.WriteHeader(2, "Signature"); writer.WriteCodeBlock("csharp", DocUtilities.GetClassSignature(Type)); var ctors = Type.GetConstructors().OrderBy(c => c.Name).ToArray(); if (ctors.Length > 0) { writer.WriteHeader(2, "Constructors"); if (Args.MethodGroupsTable) { writer.WriteLine("|**Name**|**Summary**|"); writer.WriteLine("|---|---|"); } var ctorNum = 1; foreach (var ctor in ctors) { if (Args.MethodGroupsTable) { var anchor = ""; if (ctorNum > 1) { anchor = $"#{DocUtilities.GetAnchor(DocUtilities.GetMethodSignature(ctor, false, false))}"; } var sbLink = new StringBuilder(); sbLink.Append($"[{DocUtilities.GetMethodSignature(ctor, false, false)}]"); sbLink.Append($"({DocUtilities.GetURLTitle(Type)}/ctors.md{anchor})"); bool isStatic = ctor.IsStatic; if (isStatic) { sbLink.Append(" (static)"); } var summary = ""; var doc = _prjDocs[ID.GetIDString(ctor)]; if (doc != null && !string.IsNullOrEmpty(doc.Summary)) { summary = doc.Summary.Replace("|", "\\|").Replace("\n", "<br/>"); } writer.WriteLine($"|{sbLink.ToString()}|{summary}|"); } else { var sbLink = new StringBuilder($"[{DocUtilities.GetMethodSignature(ctor, false, true)}]({DocUtilities.GetURLTitle(Type)}/ctors.md)"); bool isStatic = ctor.IsStatic; if (isStatic) { sbLink.Append(" (static)"); } writer.WriteLine($"- {sbLink.ToString()}"); } ++ctorNum; } } var methods = Type.GetMethods().OrderBy(m => m.Name).ToArray(); if (methods.Length > 0) { writer.WriteHeader(2, "Methods"); if (Args.MethodGroupsTable) { writer.WriteLine("|**Name**|**Summary**|"); writer.WriteLine("|---|---|"); } foreach (var methodGroup in methods.Where(m => !m.IsSpecialName).GroupBy(m => m.Name)) { if (Args.MethodGroupsTable) { foreach (var(method, idx) in methodGroup .OrderBy(m => m.GetParameters().Length) .Select((method, idx) => (method, idx))) { var anchor = ""; if (idx > 0) { anchor = $"#{DocUtilities.GetAnchor(DocUtilities.GetMethodSignature(method, false, false))}"; } var sbLink = new StringBuilder(); sbLink.Append($"[{DocUtilities.GetIdentifier(methodGroup.Key)}]"); sbLink.Append($"({DocUtilities.GetURLTitle(Type)}/{DocUtilities.GetIdentifier(methodGroup.Key)}.md{anchor})"); bool isStatic = method.IsStatic; if (isStatic) { sbLink.Append(" (static)"); } var summary = ""; var doc = _prjDocs[ID.GetIDString(method)]; if (doc != null && !string.IsNullOrEmpty(doc.Summary)) { summary = doc.Summary.Replace("|", "\\|").Replace("\n", "<br/>"); } writer.WriteLine($"|{sbLink.ToString()}|{summary}|"); } } else { var sbLink = new StringBuilder($"[{DocUtilities.GetIdentifier(methodGroup.Key)}]({DocUtilities.GetURLTitle(Type)}/{DocUtilities.GetIdentifier(methodGroup.Key)}.md)"); bool isStatic = methodGroup.All(m => m.IsStatic); if (isStatic) { sbLink.Append(" (static)"); } writer.WriteLine($"- {sbLink.ToString()}"); } } } var props = Type.GetProperties() .Where(p => p.GetIndexParameters().Length == 0) .OrderBy(p => p.Name) .ToArray(); if (props.Length > 0) { writer.WriteHeader(2, "Properties"); if (Args.PropertiesTable) { writer.WriteLine("|**Name**|**Summary**|"); writer.WriteLine("|---|---|"); } foreach (var prop in props) { var sbLink = new StringBuilder($"[{DocUtilities.GetIdentifier(prop.Name)}]({DocUtilities.GetURLTitle(Type)}/{DocUtilities.GetIdentifier(prop.Name)}.md)"); bool isStatic = prop.CanRead && prop.GetGetMethod(true).IsStatic || prop.CanWrite && prop.GetSetMethod(true).IsStatic; if (isStatic) { sbLink.Append(" (static)"); } if (Args.PropertiesTable) { var summary = ""; var doc = _prjDocs[ID.GetIDString(prop)]; if (doc != null && !string.IsNullOrEmpty(doc.Summary)) { summary = doc.Summary.Replace("|", "\\|").Replace("\n", "<br/>"); } writer.WriteLine($"|{sbLink.ToString()}|{summary}"); } else { writer.WriteLine($"- {sbLink.ToString()}"); } } } var fields = Type.GetFields() .Where(f => !f.IsSpecialName) .OrderBy(f => f.Name) .ToArray(); if (fields.Length > 0) { writer.WriteHeader(2, "Fields"); foreach (var field in fields) { var sbLink = new StringBuilder($"- [{DocUtilities.GetIdentifier(field.Name)}]({DocUtilities.GetURLTitle(Type)}/{DocUtilities.GetIdentifier(field.Name)}.md)"); if (field.IsStatic) { sbLink.Append(" (static)"); } writer.WriteLine(sbLink.ToString()); } } // TODO: Events //writer.WriteHeader(2, "Events"); var operators = Type.GetMethods() .Where(m => m.Name.StartsWith("op_") && m.Name != "op_Explicit" && m.Name != "op_Implicit") .ToArray(); if (operators.Length > 0) { writer.WriteHeader(2, "Operators"); foreach (var op in operators) { writer.WriteLine($"- [{DocUtilities.GetOperatorSymbol(op.Name)}]({DocUtilities.GetURLTitle(Type)}/{op.Name}.md)"); } } writer.WriteHeader(2, "Conversions"); }
public override void Render(PageTree parent, MarkdownWriter writer) { writer.WriteHeader(1, Title); writer.WriteParagraph($"**Namespace:** {Type.Namespace}"); var inheritance = DocUtilities.GetInheritanceString(Type); if (!String.IsNullOrEmpty(inheritance)) { writer.WriteParagraph($"**Inheritance:** {inheritance}"); } writer.WriteParagraph(Docs?.Summary ?? "(No Description)"); writer.WriteHeader(2, "Signature"); writer.WriteCodeBlock("csharp", DocUtilities.GetClassSignature(Type)); var methods = Type.GetMethods().OrderBy(m => m.Name).ToArray(); if (methods.Length > 0) { writer.WriteHeader(2, "Methods"); foreach (var methodGroup in methods.Where(m => !m.IsSpecialName).GroupBy(m => m.Name)) { var sbLink = new StringBuilder($"- [{DocUtilities.GetIdentifier(methodGroup.Key)}]({DocUtilities.GetURLTitle(Type)}/{DocUtilities.GetIdentifier(methodGroup.Key)}.md)"); bool isStatic = methodGroup.All(m => m.IsStatic); if (isStatic) { sbLink.Append(" (static)"); } writer.WriteLine(sbLink.ToString()); } } var props = Type.GetProperties() .Where(p => p.GetIndexParameters().Length == 0) .OrderBy(p => p.Name) .ToArray(); if (props.Length > 0) { writer.WriteHeader(2, "Properties"); foreach (var prop in props) { var sbLink = new StringBuilder($"- [{DocUtilities.GetIdentifier(prop.Name)}]({DocUtilities.GetURLTitle(Type)}/{DocUtilities.GetIdentifier(prop.Name)}.md)"); bool isStatic = prop.CanRead && prop.GetGetMethod(true).IsStatic || prop.CanWrite && prop.GetSetMethod(true).IsStatic; if (isStatic) { sbLink.Append(" (static)"); } writer.WriteLine(sbLink.ToString()); } } var fields = Type.GetFields() .Where(f => !f.IsSpecialName) .OrderBy(f => f.Name) .ToArray(); if (fields.Length > 0) { writer.WriteHeader(2, "Fields"); foreach (var field in fields) { var sbLink = new StringBuilder($"- [{DocUtilities.GetIdentifier(field.Name)}]({DocUtilities.GetURLTitle(Type)}/{DocUtilities.GetIdentifier(field.Name)}.md)"); if (field.IsStatic) { sbLink.Append(" (static)"); } writer.WriteLine(sbLink.ToString()); } } // TODO: Events //writer.WriteHeader(2, "Events"); var operators = Type.GetMethods() .Where(m => m.Name.StartsWith("op_") && m.Name != "op_Explicit" && m.Name != "op_Implicit") .ToArray(); if (operators.Length > 0) { writer.WriteHeader(2, "Operators"); foreach (var op in operators) { writer.WriteLine($"- [{DocUtilities.GetOperatorSymbol(op.Name)}]({DocUtilities.GetURLTitle(Type)}/{op.Name}.md)"); } } writer.WriteHeader(2, "Conversions"); }