private void BuildContent(MarkdownBuilder mb, TypeScriptAccessor accessor) { mb.Header(3, accessor.Name); if (accessor.GetSignature != null) { mb.AppendLine("⇄ " + accessor.GetSignature.Format(_lib)); mb.AppendLine(); BuildParameters(mb, accessor.GetSignature.Parameters); mb.AppendLine(); mb.Append($"**Returns** " + accessor.GetSignature.Type.Format(_lib)); if (!string.IsNullOrEmpty(accessor.GetSignature.Comment?.Returns)) { mb.Append(" - " + accessor.GetSignature.Comment.Returns); } mb.AppendLine(); mb.AppendLine(); mb.AppendSeparateLine(); } if (accessor.SetSignature != null) { mb.AppendLine("⇄ " + accessor.SetSignature.Format(_lib)); mb.AppendLine(); BuildParameters(mb, accessor.SetSignature.Parameters); mb.AppendLine(); mb.Append($"**Returns** " + accessor.SetSignature.Type.Format(_lib)); if (!string.IsNullOrEmpty(accessor.SetSignature.Comment?.Returns)) { mb.Append(" - " + accessor.SetSignature.Comment.Returns); } mb.AppendLine(); mb.AppendLine(); mb.AppendSeparateLine(); } }
private void BuildContent(MarkdownBuilder mb, TypeScriptFunction function) { mb.Header(4, function.Name); mb.AppendLine(); if (!string.IsNullOrEmpty(function.Signatures.First().Comment?.ShortText)) { mb.AppendLine(function.Signatures.First().Comment.ShortText); mb.AppendLine(); } foreach (var signature in function.Signatures) { mb.AppendLine("▸ " + signature.Format(_lib)); mb.AppendLine(); BuildParameters(mb, signature.Parameters); mb.AppendLine(); mb.Append($"**Returns** " + signature.Type.Format(_lib)); if (!string.IsNullOrEmpty(signature.Comment?.Returns)) { mb.Append(" - " + signature.Comment.Returns); } mb.AppendLine(); mb.AppendLine(); } BuildExample(mb, function.Signatures.First().Comment); mb.AppendLine(); mb.AppendSeparateLine(); }
private void BuildContent(MarkdownBuilder mb, TypeScriptMethod method) { mb.Header(3, method.Name); if (!string.IsNullOrEmpty(method.Signature.Comment?.ShortText)) { mb.AppendLine(method.Signature.Comment.ShortText); mb.AppendLine(); } mb.AppendLine(method.Format(_lib)); mb.AppendLine(); BuildParameters(mb, method.Signature.Parameters); mb.AppendLine(); mb.Append($"**Returns** " + method.Signature.Type.Format(_lib)); if (!string.IsNullOrEmpty(method.Signature.Comment?.Returns)) { mb.Append(" - " + method.Signature.Comment.Returns); } mb.AppendLine(); BuildExample(mb, method.Signature.Comment); mb.AppendSeparateLine(); }
private string BuildContent(TypeScriptInterface @interface, bool extension = false, string articleUrl = null) { var mb = new MarkdownBuilder(); if (!string.IsNullOrEmpty(@interface.Comment?.ShortText)) { mb.AppendLine(@interface.Comment.ShortText); mb.AppendLine(); } BuildExample(mb, @interface.Comment); if (!extension) { BuildExtendedTypes(mb, @interface); } BuildIndex(mb, @interface, extension, articleUrl); if (@interface.Properties.Any()) { mb.Header(2, "Properties"); mb.AppendSeparateLine(); foreach (var property in @interface.Properties) { BuildContent(mb, property); } } if (@interface.Methods.Any()) { mb.Header(2, "Methods"); mb.AppendSeparateLine(); foreach (var method in @interface.Methods) { BuildContent(mb, method); } } return(mb.ToString()); }
private void BuildContent(MarkdownBuilder mb, TypeScriptVariable variable) { mb.Header(3, MarkdownBuilder.MarkdownCodeQuote(variable.IsConst ? "const" : variable.IsLet ? "let" : "var") + " " + variable.Name); mb.AppendLine(); if (!string.IsNullOrEmpty(variable.Comment?.ShortText)) { mb.AppendLine(variable.Comment.ShortText); mb.AppendLine(); } mb.AppendLine(variable.Format(_lib)); mb.AppendLine(); BuildExample(mb, variable.Comment); mb.AppendSeparateLine(); }
private void BuildContent(MarkdownBuilder mb, TypeScriptProperty property) { mb.Header(3, property.Name); mb.AppendLine(); if (!string.IsNullOrEmpty(property.Comment?.ShortText)) { mb.AppendLine(property.Comment.ShortText); mb.AppendLine(); } mb.AppendLine(property.Format(_lib)); BuildExample(mb, property.Comment); mb.AppendSeparateLine(); }
private string BuildContent(TypeScriptClass @class) { var mb = new MarkdownBuilder(); if (!string.IsNullOrEmpty(@class.Comment?.ShortText)) { mb.AppendLine(@class.Comment.ShortText); mb.AppendLine(); } BuildExample(mb, @class.Comment); BuildImplementedTypes(mb, @class); BuildExtendedTypes(mb, @class); BuildIndex(mb, @class); if (@class.Constructor != null) { mb.Header(2, "Constructors"); mb.AppendSeparateLine(); mb.Header(4, "constructor"); mb.AppendLine(); if (!string.IsNullOrEmpty(@class.Constructor.Signatures.First().Comment?.ShortText)) { mb.AppendLine(@class.Constructor.Signatures.First().Comment.ShortText); } foreach (var signature in @class.Constructor.Signatures) { mb.AppendLine("⊕ " + signature.Format(_lib)); mb.AppendLine(); } BuildParameters(mb, @class.Constructor.Signatures.Last().Parameters); BuildExample(mb, @class.Constructor.Signatures.First().Comment); mb.AppendSeparateLine(); } mb.AppendLine(); var publicMethods = @class.Methods.Where(m => !m.IsStatic && !m.IsPrivate && !m.IsProtected).ToList(); var protectedMethods = @class.Methods.Where(m => m.IsProtected).ToList(); var staticMethods = @class.Methods.Where(m => m.IsStatic && !m.IsPrivate).ToList(); var publicProperties = @class.Properties.Where(p => !p.IsStatic && !p.IsPrivate && !p.IsProtected).ToList(); var protectedProperties = @class.Properties.Where(p => p.IsProtected).ToList(); var staticProperties = @class.Properties.Where(p => p.IsStatic && !p.IsPrivate).ToList(); var publicAccessors = @class.Accessors.Where(a => !a.IsPrivate && !a.IsProtected).ToList(); var protectedAccesors = @class.Accessors.Where(a => a.IsProtected).ToList(); if (publicProperties.Any()) { mb.Header(2, "Public Properties"); mb.AppendSeparateLine(); foreach (var property in publicProperties) { BuildContent(mb, property); } } if (protectedProperties.Any()) { mb.Header(2, "Protected Properties"); mb.AppendSeparateLine(); foreach (var property in protectedProperties) { BuildContent(mb, property); } } if (staticProperties.Any()) { mb.Header(2, "Static Properties"); mb.AppendSeparateLine(); foreach (var property in staticProperties) { BuildContent(mb, property); } } if (publicAccessors.Any()) { mb.Header(2, "Public Accessors"); mb.AppendSeparateLine(); foreach (var accessor in publicAccessors) { BuildContent(mb, accessor); } } if (protectedAccesors.Any()) { mb.Header(2, "Protected Accessors"); mb.AppendSeparateLine(); foreach (var accessor in protectedAccesors) { BuildContent(mb, accessor); } } if (publicMethods.Any()) { mb.Header(2, "Public Methods"); mb.AppendSeparateLine(); foreach (var method in publicMethods) { BuildContent(mb, method); } } if (protectedMethods.Any()) { mb.Header(2, "Protected Methods"); mb.AppendSeparateLine(); foreach (var method in protectedMethods) { BuildContent(mb, method); } } if (staticMethods.Any()) { mb.Header(2, "Static Methods"); mb.AppendSeparateLine(); foreach (var method in staticMethods) { BuildContent(mb, method); } } return(mb.ToString()); }