private void BuildContent(MarkdownBuilder mb, TypeScriptMethod method) { mb.Header(3, method.Name); if (!string.IsNullOrEmpty(method.Signatures.First().Comment?.ShortText)) { mb.AppendLine(method.Signatures.First().Comment.ShortText); mb.AppendLine(); } foreach (var signature in method.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, method.Signatures.First().Comment); mb.AppendSeparateLine(); }
private void LoadFromJObject(TypeScriptInterface @interface, JObject jobject) { if (jobject.TryGetValue("id", out var idTokent)) { @interface.Id = idTokent.ToObject <int>(); } if (jobject.TryGetValue("name", out var nameTokent)) { @interface.Name = nameTokent.ToString(); } if (jobject.TryGetValue("flags", out var flagsToken)) { var flagsObj = flagsToken.ToObject <JObject>(); if (flagsObj.TryGetValue("isExported", out var isExportedToken)) { @interface.IsExported = isExportedToken.ToObject <bool>(); } } if (jobject.TryGetValue("children", out var childrenToken)) { var children = childrenToken.ToObject <List <JObject> >(); foreach (var child in children) { var childKind = child["kind"].ToObject <TypeScriptTokenKind>(); if (childKind == TypeScriptTokenKind.Property) { var property = new TypeScriptProperty(); LoadFromJObject(property, child); @interface.Properties.Add(property); } else if (childKind == TypeScriptTokenKind.Method) { var method = new TypeScriptMethod(); LoadFromJObject(method, child); @interface.Methods.Add(method); } } } if (jobject.TryGetValue("comment", out var commentToken)) { @interface.Comment = new TypeScriptComment(); LoadFromJObject(@interface.Comment, commentToken.ToObject <JObject>()); } if (jobject.TryGetValue("extendedTypes", out var extendedTypesToken)) { var typeObjs = extendedTypesToken.ToObject <List <JObject> >(); foreach (var typeObj in typeObjs) { @interface.ExtendedTypes.Add(LoadTypeFromJObject(typeObj)); } } }
private void LoadFromJObject(TypeScriptMethod method, JObject jobject) { if (jobject.TryGetValue("name", out var nameTokent)) { method.Name = nameTokent.ToString(); } if (jobject.TryGetValue("flags", out var flagsToken)) { var flagsObj = flagsToken.ToObject <JObject>(); if (flagsObj.TryGetValue("isPublic", out var isPublicToken)) { method.IsPublic = isPublicToken.ToObject <bool>(); } if (flagsObj.TryGetValue("isProtected", out var isProtectedToken)) { method.IsProtected = isProtectedToken.ToObject <bool>(); } if (flagsObj.TryGetValue("isPrivate", out var isPrivateToken)) { method.IsPrivate = isPrivateToken.ToObject <bool>(); } if (flagsObj.TryGetValue("isOptional", out var isOptionalToken)) { method.IsOptional = isOptionalToken.ToObject <bool>(); } if (flagsObj.TryGetValue("isStatic", out var isStaticToken)) { method.IsStatic = isStaticToken.ToObject <bool>(); } } if (jobject.TryGetValue("signatures", out var signatureToken)) { LoadFromJObject(method.Signature, signatureToken.ToObject <List <JObject> >().First()); } }