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 LoadFromJObject(TypeScriptVariable variable, JObject jobject)
        {
            if (jobject.TryGetValue("name", out var nameTokent))
            {
                variable.Name = nameTokent.ToString();
            }

            if (jobject.TryGetValue("flags", out var flagsToken))
            {
                var flagsObj = flagsToken.ToObject <JObject>();

                if (flagsObj.TryGetValue("isExported", out var isExportedToken))
                {
                    variable.IsExported = isExportedToken.ToObject <bool>();
                }

                if (flagsObj.TryGetValue("isLet", out var isLetToken))
                {
                    variable.IsLet = isLetToken.ToObject <bool>();
                }

                if (flagsObj.TryGetValue("isConst", out var isConstToken))
                {
                    variable.IsConst = isConstToken.ToObject <bool>();
                }
            }

            if (jobject.TryGetValue("type", out var typeToken))
            {
                variable.Type = LoadTypeFromJObject(typeToken.ToObject <JObject>());
            }

            if (jobject.TryGetValue("defaultValue", out var defValToken))
            {
                variable.DefaultValue = defValToken.ToString();
            }

            if (jobject.TryGetValue("comment", out var commentToken))
            {
                variable.Comment = new TypeScriptComment();
                LoadFromJObject(variable.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>());
            }
        }