private string GetSummary(ITypeScriptModule module, VariableStore varStore)
        {
            //prevent autoexcerpt
            var itemSummary = " ";

            var varibales = varStore.GetSignificantVariables();

            if (!varibales.Any())
            {
                varibales = varStore.Where(v => v.IsExported).Take(10);
            }

            if (varibales.Any())
            {
                itemSummary = BuildHTMLList(module.GetPath().MakeUriFromString().CombineWithUri("variables"), varibales);
            }

            return(itemSummary);
        }
        private string GetSummary(ITypeScriptModule module, FunctionStore funcStore)
        {
            //prevent autoexcerpt
            var itemSummary = " ";

            var functions = funcStore.GetSignificantFunctions();

            if (!functions.Any())
            {
                functions = funcStore.Where(f => f.IsExported == true).Take(10).ToList();
            }

            if (functions.Any())
            {
                itemSummary = BuildHTMLList(module.GetPath().MakeUriFromString().CombineWithUri("functions"), functions);
            }

            return(itemSummary);
        }
 public TypeScriptNamespace(ITypeScriptModule module)
 {
     Module = module;
 }
 public TypeScriptVariable(ITypeScriptModule module)
 {
     Module = module;
 }
 public TypeScriptEnumeration(ITypeScriptModule module)
 {
     Module = module;
 }
 public TypeScriptFunction(ITypeScriptModule module)
 {
     Module = module;
 }
 public TypeScriptClass(ITypeScriptModule module)
 {
     Module = module;
 }
 public TypeScriptInterface(ITypeScriptModule module)
 {
     Module = module;
 }
        private int ProcessModule(ITypeScriptModule module, IArticlePublisher saver, string parentSectionUrl = null)
        {
            var articleCount   = 0;
            var sectionName    = module.BeautifulName;
            var sectionUrl     = sectionName.MakeUriFromString();
            var fullSectionUrl = (parentSectionUrl != null) ? parentSectionUrl.CombineWithUri(sectionUrl) : sectionUrl;

            var enums      = module.Enumerations.Where(e => e.IsExported).ToList();
            var classes    = module.Classes.Where(c => c.IsExported).ToList();
            var interfaces = module.Interfaces.Where(i => i.IsExported).ToList();
            var functions  = module.Functions.Where(f => f.IsExported).ToList();
            var variables  = module.Variables.Where(v => v.IsExported).ToList();
            var nspaces    = module.Namespaces.Where(n => n.IsExported).ToList();

            //support extention interfaces
            var extensionInterfaces = module.Namespaces.Where(n => _lib.Packages.Any(p => n.Name.Contains(p.Name)))
                                      .SelectMany(n => n.Interfaces)
                                      .ToList();

            extensionInterfaces = extensionInterfaces.Where(i => ContainsClassOrInterface(i.Name))
                                  .ToList();

            if (enums.Any() || classes.Any() || interfaces.Any() || functions.Any() || variables.Any() || extensionInterfaces.Any())
            {
                var parentSection = new ArticlePublishModel
                {
                    SectionUri     = parentSectionUrl,
                    ArticleTitle   = sectionName,
                    ArticleUri     = sectionUrl,
                    ArticleExcerpt = module.Comment?.ShortText ?? " ",
                    ArticleBody    = module.Comment?.ShortText ?? "",
                    IsSection      = true
                };

                //Create section for package/namespace
                if (saver.PublishArticle(parentSection))
                {
                    articleCount++;
                }

                foreach (var nspace in nspaces)
                {
                    articleCount += ProcessModule(nspace, saver, fullSectionUrl);
                }

                if (enums.Any())
                {
                    var section = new ArticlePublishModel
                    {
                        SectionTitle = sectionName,
                        SectionUri   = fullSectionUrl,
                        ArticleTitle = "Enumerations",
                        ArticleUri   = "enumerations",
                        IsSection    = true
                    };

                    //Create section for package/namespace
                    if (saver.PublishArticle(section))
                    {
                        articleCount++;
                    }

                    //Processing Enumerations
                    foreach (var @enum in enums)
                    {
                        var itemName    = @enum.BeautifulName;
                        var itemSummary = @enum.Comment?.ShortText;
                        var itemContent = BuildContent(@enum);

                        var articleSaveModel = new ArticlePublishModel
                        {
                            SectionTitle   = section.ArticleTitle,
                            SectionUri     = fullSectionUrl.CombineWithUri(section.ArticleUri),
                            ArticleTitle   = itemName,
                            ArticleUri     = itemName.MakeUriFromString(),
                            ArticleExcerpt = itemSummary,
                            ArticleBody    = itemContent
                        };

                        if (saver.PublishArticle(articleSaveModel))
                        {
                            articleCount++;
                        }
                    }
                }

                if (interfaces.Any())
                {
                    var section = new ArticlePublishModel
                    {
                        SectionTitle = sectionName,
                        SectionUri   = fullSectionUrl,
                        ArticleTitle = "Interfaces",
                        ArticleUri   = "interfaces",
                        IsSection    = true
                    };

                    //Create section for interfaces
                    if (saver.PublishArticle(section))
                    {
                        articleCount++;
                    }


                    //Processing Interfaces
                    foreach (var @interface in interfaces)
                    {
                        var itemName    = @interface.BeautifulName;
                        var itemSummary = GetSummary(@interface, extension: false, articleUrl: null);
                        var itemContent = BuildContent(@interface);

                        var articleSaveModel = new ArticlePublishModel
                        {
                            SectionTitle   = section.ArticleTitle,
                            SectionUri     = fullSectionUrl.CombineWithUri(section.ArticleUri),
                            ArticleTitle   = itemName,
                            ArticleUri     = itemName.MakeUriFromString(),
                            ArticleExcerpt = itemSummary,
                            ArticleBody    = itemContent
                        };

                        if (saver.PublishArticle(articleSaveModel))
                        {
                            articleCount++;
                        }
                    }
                }


                if (classes.Any())
                {
                    var section = new ArticlePublishModel
                    {
                        SectionTitle = sectionName,
                        SectionUri   = fullSectionUrl,
                        ArticleTitle = "Classes",
                        ArticleUri   = "classes",
                        IsSection    = true
                    };

                    //Create section for interfaces
                    if (saver.PublishArticle(section))
                    {
                        articleCount++;
                    }

                    //Processing Classes
                    foreach (var @class in classes)
                    {
                        var itemName    = @class.BeautifulName;
                        var itemSummary = GetSummary(@class);

                        var itemContent = BuildContent(@class);

                        var articleSaveModel = new ArticlePublishModel
                        {
                            SectionTitle   = section.ArticleTitle,
                            SectionUri     = fullSectionUrl.CombineWithUri(section.ArticleUri),
                            ArticleTitle   = itemName,
                            ArticleUri     = itemName.MakeUriFromString(),
                            ArticleExcerpt = itemSummary,
                            ArticleBody    = itemContent
                        };

                        if (saver.PublishArticle(articleSaveModel))
                        {
                            articleCount++;
                        }
                    }
                }

                if (extensionInterfaces.Any())
                {
                    var section = new ArticlePublishModel
                    {
                        SectionTitle = sectionName,
                        SectionUri   = fullSectionUrl,
                        ArticleTitle = "Extensions",
                        ArticleUri   = "extensions",
                        IsSection    = true
                    };

                    //Create section for extensions
                    if (saver.PublishArticle(section))
                    {
                        articleCount++;
                    }


                    //Processing extensions
                    foreach (var extensionInterface in extensionInterfaces)
                    {
                        var itemName   = extensionInterface.Name + " extensions";
                        var articleUrl = section.ArticleUri.CombineWithUri(itemName.MakeUriFromString());

                        var itemSummary = GetSummary(extensionInterface, extension: true, articleUrl: articleUrl);

                        var itemContent = BuildContent(extensionInterface, extension: true, articleUrl: articleUrl);

                        var articleSaveModel = new ArticlePublishModel
                        {
                            SectionTitle   = section.ArticleTitle,
                            SectionUri     = fullSectionUrl.CombineWithUri(section.ArticleUri),
                            ArticleTitle   = itemName,
                            ArticleUri     = itemName.MakeUriFromString(),
                            ArticleExcerpt = itemSummary,
                            ArticleBody    = itemContent
                        };

                        if (saver.PublishArticle(articleSaveModel))
                        {
                            articleCount++;
                        }
                    }
                }


                if (functions.Any())
                {
                    var itemSummary = GetSummary(module, module.Functions);

                    var articleSaveModel = new ArticlePublishModel
                    {
                        SectionTitle   = sectionName,
                        SectionUri     = fullSectionUrl,
                        ArticleTitle   = "Functions",
                        ArticleUri     = "functions",
                        ArticleBody    = BuildContent(functions),
                        ArticleExcerpt = itemSummary
                    };

                    if (saver.PublishArticle(articleSaveModel))
                    {
                        articleCount++;
                    }
                }

                if (variables.Any())
                {
                    var itemSummary = GetSummary(module, module.Variables);

                    var articleSaveModel = new ArticlePublishModel
                    {
                        SectionTitle   = sectionName,
                        SectionUri     = fullSectionUrl,
                        ArticleTitle   = "Variables",
                        ArticleUri     = "Variables",
                        ArticleBody    = BuildContent(variables),
                        ArticleExcerpt = itemSummary
                    };

                    if (saver.PublishArticle(articleSaveModel))
                    {
                        articleCount++;
                    }
                }
            }

            return(articleCount);
        }