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 LoadFromJObject(TypeScriptFunction function, JObject jobject) { if (jobject.TryGetValue("name", out var nameToken)) { function.Name = nameToken.ToString();; } if (jobject.TryGetValue("flags", out var flagsToken)) { var flagsObj = flagsToken.ToObject <JObject>(); if (flagsObj.TryGetValue("isExported", out var isExportedToken)) { function.IsExported = isExportedToken.ToObject <bool>(); } } if (jobject.TryGetValue("signatures", out var signatureToken)) { LoadFromJObject(function.Signature, signatureToken.ToObject <List <JObject> >().First()); } if (jobject.TryGetValue("comment", out var commentToken)) { function.Comment = new TypeScriptComment(); LoadFromJObject(function.Comment, commentToken.ToObject <JObject>()); } }
private void LoadFromJObject(TypeScriptPackage package, JObject jobject) { if (jobject.TryGetValue("name", out var nameToken)) { package.Name = nameToken.ToString(); } if (jobject.TryGetValue("children", out var childrenToken)) { //expects here extenral modules var children = childrenToken.ToObject <List <JObject> >(); foreach (var child in children) { var childKind = child["kind"].ToObject <TypeScriptTokenKind>(); if (childKind == TypeScriptTokenKind.Class) { var @class = new TypeScriptClass(package); LoadFromJObject(@class, child); package.Classes.Add(@class); } else if (childKind == TypeScriptTokenKind.Interface) { var @interface = new TypeScriptInterface(package); LoadFromJObject(@interface, child); package.Interfaces.Add(@interface); } else if (childKind == TypeScriptTokenKind.Function) { var function = new TypeScriptFunction(package); LoadFromJObject(function, child); package.Functions.Add(function); } else if (childKind == TypeScriptTokenKind.Namespace) { var @namespace = new TypeScriptNamespace(package); LoadFromJObject(@namespace, child); package.Namespaces.Add(@namespace); } else if (childKind == TypeScriptTokenKind.Enumeration) { var @enum = new TypeScriptEnumeration(package); LoadFromJObject(@enum, child); package.Enumerations.Add(@enum); } else if (childKind == TypeScriptTokenKind.Varialbe) { var @var = new TypeScriptVariable(package); LoadFromJObject(var, child); package.Variables.Add(@var); } } if (jobject.TryGetValue("comment", out var commentToken)) { package.Comment = new TypeScriptComment(); LoadFromJObject(package.Comment, commentToken.ToObject <JObject>()); } } }
private void LoadFromJObject(TypeScriptNamespace @namespace, JObject jobject) { if (jobject.TryGetValue("name", out var nameToken)) { @namespace.Name = nameToken.ToString();; } if (jobject.TryGetValue("flags", out var flagsToken)) { var flagsObj = flagsToken.ToObject <JObject>(); if (flagsObj.TryGetValue("isExported", out var isExportedToken)) { @namespace.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.Class) { var @class = new TypeScriptClass(@namespace); LoadFromJObject(@class, child); @namespace.Classes.Add(@class); } else if (childKind == TypeScriptTokenKind.Interface) { var @interface = new TypeScriptInterface(@namespace); LoadFromJObject(@interface, child); @namespace.Interfaces.Add(@interface); } else if (childKind == TypeScriptTokenKind.Function) { var function = new TypeScriptFunction(@namespace); LoadFromJObject(function, child); @namespace.Functions.Add(function); } else if (childKind == TypeScriptTokenKind.Namespace) { var nspace = new TypeScriptNamespace(@namespace); LoadFromJObject(nspace, child); @namespace.Namespaces.Add(nspace); } else if (childKind == TypeScriptTokenKind.Enumeration) { var @enum = new TypeScriptEnumeration(@namespace); LoadFromJObject(@enum, child); @namespace.Enumerations.Add(@enum); } else if (childKind == TypeScriptTokenKind.Varialbe) { var @var = new TypeScriptVariable(@namespace); LoadFromJObject(var, child); @namespace.Variables.Add(@var); } } } if (jobject.TryGetValue("comment", out var commentToken)) { @namespace.Comment = new TypeScriptComment(); LoadFromJObject(@namespace.Comment, commentToken.ToObject <JObject>()); } }