protected override void FillLanguageSpecificMetadata(ArticleItemYaml yaml, ArticleContext context, XElement node)
        {
            HierarchyChange curChange    = context.CurrentChange;
            HierarchyChange parentChange = context.ParentChange;

            yaml.PackageName = parentChange?.Uid;
        }
        protected void FillReferences(PageModel page, XDocument document, ArticleContext context)
        {
            var referenceIds = (from node in document.XPathSelectElements("//node()[@refid and not(parent::listofallmembers) and not(ancestor::inheritancegraph) and not(ancestor::collaborationgraph) and not(self::innerclass)]")
                                select node.NullableAttribute("refid").NullableValue()).Where(r => r != null).Distinct();

            // add nested children for namespace api
            var curChange = context.CurrentChange;

            if (curChange.Type == HierarchyType.Namespace)
            {
                referenceIds = referenceIds.Union(curChange.Children);
            }

            _references.AddRange(referenceIds.Select(refid => new ReferenceViewModel {
                Uid = refid
            }));

            page.References = _references.Distinct(new ReferenceEqualComparer()).ToList();
        }
        public Task <PageModel> GenerateArticleAsync(BuildContext context, XDocument document)
        {
            PageModel page = new PageModel()
            {
                Items = new List <ArticleItemYaml>()
            };
            ArticleItemYaml mainYaml = new ArticleItemYaml();

            page.Items.Add(mainYaml);

            var             articleContext = new ArticleContext(context);
            HierarchyChange curChange      = articleContext.CurrentChange;
            HierarchyChange parentChange   = articleContext.ParentChange;
            var             nameContext    = new NameGeneratorContext {
                CurrentChange = curChange, ParentChange = parentChange
            };
            var main = document.Root.NullableElement("compounddef");

            mainYaml.Uid = curChange.Uid;
            mainYaml.Id  = _nameGenerator.GenerateId(nameContext, main);
            mainYaml.SupportedLanguages = new string[] { Language };
            mainYaml.FullName           = _nameGenerator.GenerateTypeFullName(nameContext, main, true);
            mainYaml.Name         = _nameGenerator.GenerateTypeName(nameContext, main, true);
            mainYaml.NameWithType = mainYaml.Name;
            mainYaml.FullNameWithoutTypeParameter = _nameGenerator.GenerateTypeFullName(nameContext, main, false);
            mainYaml.NameWithoutTypeParameter     = _nameGenerator.GenerateTypeName(nameContext, main, false);
            mainYaml.Href     = YamlUtility.ParseHrefFromChangeFile(curChange.File);
            mainYaml.Type     = YamlUtility.ParseType(curChange.Type.ToString());
            mainYaml.Parent   = curChange.Parent;
            mainYaml.Children = curChange.Children != null ? new List <string>(curChange.Children.OrderBy(c => c)) : new List <string>();
            FillSummary(mainYaml, main);
            FillRemarks(mainYaml, main);
            FillSource(mainYaml, main);
            FillSees(mainYaml, main);
            FillException(mainYaml, main);
            FillInheritance(nameContext, mainYaml, main);
            FillSyntax(mainYaml, main, isMain: true);
            FillImplementsOrInherits(mainYaml, main);
            FillLanguageSpecificMetadata(mainYaml, articleContext, main);

            var members = new Dictionary <string, ArticleItemYaml>();

            foreach (var section in main.Elements("sectiondef"))
            {
                string kind  = section.NullableAttribute("kind").NullableValue();
                var    tuple = KindMapToType(kind);
                if (tuple.Item1.HasValue && ((tuple.Item2 & AccessLevel.NotAccessible) == AccessLevel.None))
                {
                    foreach (var member in section.Elements("memberdef"))
                    {
                        var memberYaml = new ArticleItemYaml();
                        memberYaml.Uid = member.NullableAttribute("id").NullableValue();
                        memberYaml.Id  = _nameGenerator.GenerateId(nameContext, member);
                        memberYaml.SupportedLanguages = new string[] { Language };
                        memberYaml.FullName           = _nameGenerator.GenerateMemberFullName(nameContext, member);
                        memberYaml.Name         = _nameGenerator.GenerateMemberName(nameContext, member);
                        memberYaml.NameWithType = _nameGenerator.GenerateMemberNameWithType(memberYaml.Name, mainYaml.Name);
                        memberYaml.Href         = mainYaml.Href;
                        memberYaml.Type         = string.IsNullOrEmpty(member.NullableElement("type").NullableValue()) && tuple.Item1.Value == MemberType.Method ? MemberType.Constructor : tuple.Item1.Value;
                        memberYaml.Parent       = mainYaml.Uid;
                        FillSummary(memberYaml, member);
                        FillRemarks(memberYaml, member);
                        FillSource(memberYaml, member);
                        FillSees(memberYaml, member);
                        FillException(memberYaml, member);
                        FillOverridden(memberYaml, member);
                        FillSyntax(memberYaml, member, isMain: false);
                        FillLanguageSpecificMetadata(memberYaml, articleContext, member);
                        FillOverload(memberYaml, member);

                        if (members.ContainsKey(memberYaml.Uid))
                        {
                            ConsoleLogger.WriteLine(
                                new LogEntry
                            {
                                Phase   = "GenerateArticles",
                                Level   = LogLevel.Warning,
                                Message = $"Duplicate items {memberYaml.Uid} found in {curChange.File}.",
                            });
                            continue;
                        }
                        members[memberYaml.Uid] = memberYaml;
                        EmptyToNull(memberYaml);
                    }
                }
            }

            mainYaml.Children.AddRange(from p in members
                                       orderby p.Value.Name.ToLower()
                                       select p.Key);
            page.Items.AddRange(from i in members.Values
                                orderby i.Name.ToLower()
                                select i);

            // after children are filled, fill inherited members
            FillInheritedMembers(mainYaml, main);
            FillReferences(page, document, articleContext);

            EmptyToNull(mainYaml);
            return(Task.FromResult(page));
        }
 protected abstract void FillLanguageSpecificMetadata(ArticleItemYaml yaml, ArticleContext context, XElement node);