private string GetSummary(TypeScriptInterface @interface, bool extension, string articleUrl)
        {
            var itemSummary = @interface.Comment?.ShortText;

            if (string.IsNullOrEmpty(itemSummary))
            {
                var properties = @interface.GetSignificantProperties();
                var methods    = @interface.GetSignificantMethods();

                if (!properties.Any() && !methods.Any())
                {
                    properties = @interface.Properties.Where(p => !p.IsPrivate).Take(5);
                    methods    = @interface.Methods.Where(m => !m.IsPrivate).Take(5);
                }

                if (properties.Any() || methods.Any())
                {
                    var path = (!extension)
                        ? @interface.GetPath().MakeUriFromString()
                        : string.IsNullOrEmpty(articleUrl)
                            ? @interface.Module.Module.GetPath().MakeUriFromString()
                            : @interface.Module.Module.GetPath().MakeUriFromString().CombineWithUri(articleUrl);

                    itemSummary = BuildHTMLList(path, properties, methods);
                }

                if (string.IsNullOrEmpty(itemSummary))
                {
                    //prevent autoexcerpt
                    itemSummary = " ";
                }
            }

            return(itemSummary);
        }
        private void BuildIndex(MarkdownBuilder mb, TypeScriptInterface @interface)
        {
            var path = @interface.GetPath().MakeUriFromString();

            mb.Header(2, "Index");
            if (@interface.Properties.Any())
            {
                mb.HeaderWithLink(3, "Properties", CombineWithRootUrl(path.CombineWithUri("#properties-1")));

                foreach (var property in @interface.Properties)
                {
                    mb.ListLink(property.Name, CombineWithRootUrl(path.CombineWithUri("#" + property.Name.MakeUriFromString())));
                }

                mb.AppendLine();
            }

            if (@interface.Methods.Any())
            {
                mb.HeaderWithLink(3, "Methods", CombineWithRootUrl(path.CombineWithUri("#methods-1")));
                foreach (var method in @interface.Methods)
                {
                    mb.ListLink(method.Name, CombineWithRootUrl(path.CombineWithUri("#" + method.Name.MakeUriFromString())));
                }
                mb.AppendLine();
            }

            mb.AppendLine();
            mb.AppendLine();
        }
        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 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 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>());
            }
        }