Esempio n. 1
0
        public void Run(MetadataModel yaml, ResolverContext context)
        {
            TreeIterator.Preorder(yaml.TocYamlViewModel, null,
                                  s => s.IsInvalid ? null : s.Items,
                                  (member, parent) =>
            {
                if (member.Type != MemberType.Toc)
                {
                    ApiIndexItemModel item;
                    if (yaml.Indexer.TryGetValue(member.Name, out item))
                    {
                        Logger.Log(LogLevel.Warning, $"{member.Name} already exists in {item.Href}, the duplicate one {member.Href} will be ignored.");
                    }
                    else
                    {
                        yaml.Indexer.Add(
                            member.Name,
                            new ApiIndexItemModel {
                            Name = member.Name, Href = context.ApiFolder.ForwardSlashCombine(member.Href)
                        });
                    }
                }

                return(true);
            });
        }
Esempio n. 2
0
        public void Run(MetadataModel yaml, ResolverContext context)
        {
            yaml.TocYamlViewModel = yaml.TocYamlViewModel.ShrinkToSimpleTocWithNamespaceNotEmpty();
            // Comparing to toc files, yaml files are all in api folder
            TreeIterator.Preorder(yaml.TocYamlViewModel, null,
                                  (s) =>
            {
                if (s.IsInvalid)
                {
                    return(null);
                }
                else
                {
                    return(s.Items);
                }
            }, (current, parent) =>
            {
                if (current.Type != MemberType.Toc)
                {
                    if (!string.IsNullOrEmpty(current.Href))
                    {
                        current.Href = context.ApiFolder.ForwardSlashCombine(current.Href);
                    }
                }

                return(true);
            });
        }
Esempio n. 3
0
 public void Run(MetadataModel yaml, ResolverContext context)
 {
     TreeIterator.Preorder(yaml.TocYamlViewModel, null,
                           s => s.IsInvalid ? null : s.Items,
                           (current, parent) =>
     {
         if (current.References != null)
         {
             foreach (var referenceItem in current.References.Values)
             {
                 if (referenceItem.Parts != null)
                 {
                     foreach (var links in referenceItem.Parts.Values)
                     {
                         foreach (var item in links)
                         {
                             SetHref(item, yaml.Indexer, current.Name, context);
                         }
                     }
                 }
             }
         }
         return(true);
     });
 }
Esempio n. 4
0
        public ParseResult Run(MetadataModel yaml, ResolverContext context)
        {
            TreeIterator.Preorder(yaml.TocYamlViewModel, null,
                                  s =>
            {
                if (s.IsInvalid || (s.Type != MemberType.Namespace && s.Type != MemberType.Toc))
                {
                    return(null);
                }
                else
                {
                    return(s.Items);
                }
            },
                                  (member, parent) =>
            {
                if (member.Type != MemberType.Toc)
                {
                    yaml.Members.Add(member);
                }

                return(true);
            });

            return(new ParseResult(ResultLevel.Success));
        }
Esempio n. 5
0
        public ParseResult Run(MetadataModel yaml, ResolverContext context)
        {
            TreeIterator.Preorder(yaml.TocYamlViewModel, null,
                                  s => s.IsInvalid ? null : s.Items,
                                  (current, parent) =>
            {
                current.Parent = parent;
                return(true);
            });

            return(new ParseResult(ResultLevel.Success));
        }
Esempio n. 6
0
        public ParseResult Run(MetadataModel yaml, ResolverContext context)
        {
            TreeIterator.Preorder(yaml.TocYamlViewModel, null,
                                  s => s.IsInvalid ? null : s.Items,
                                  (current, parent) =>
            {
                MetadataItem page;
                var addingReferences   = new List <ReferenceItem>();
                var documentReferences = current.References;
                if (current.Type.IsPageLevel())
                {
                    page = current;
                    current.References = new Dictionary <string, ReferenceItem>();
                }
                else
                {
                    page = parent;
                    current.References = null;
                }
                if (documentReferences != null && documentReferences.Count > 0)
                {
                    foreach (var key in documentReferences.Keys)
                    {
                        TryAddReference(context, page, addingReferences, key);
                    }
                }
                foreach (var key in GetReferenceKeys(current))
                {
                    TryAddReference(context, page, addingReferences, key);
                }
                if (current.Type == MemberType.Namespace)
                {
                    foreach (var item in current.Items)
                    {
                        TryAddReference(context, page, addingReferences, item.Name);
                    }
                }
                AddIndirectReference(context, page, addingReferences);
                return(true);
            });

            return(new ParseResult(ResultLevel.Success));
        }
Esempio n. 7
0
        public void Run(MetadataModel yaml, ResolverContext context)
        {
            TreeIterator.Preorder(yaml.TocYamlViewModel, null,
                                  s => s.IsInvalid ? null : s.Items,
                                  (member, parent) =>
            {
                // get all the possible places where link is possible
                if (member.Syntax != null && member.Syntax.Content != null)
                {
                    SyntaxLanguage[] keys = new SyntaxLanguage[member.Syntax.Content.Count];
                    member.Syntax.Content.Keys.CopyTo(keys, 0);
                    foreach (var key in keys)
                    {
                        member.Syntax.Content[key] = NormalizeLines(member.Syntax.Content[key]);
                    }
                }

                return(true);
            });
        }
        public ParseResult Run(MetadataModel yaml, ResolverContext context)
        {
            TreeIterator.Preorder(yaml.TocYamlViewModel, null,
                                  s => s.IsInvalid ? null : s.Items,
                                  (current, parent) =>
            {
                if (current.Type != MemberType.Toc)
                {
                    if (current.Type.IsPageLevel())
                    {
                        current.Href = current.Name + Constants.YamlExtension;
                    }
                    else
                    {
                        current.Href = parent.Href;
                    }
                }

                return(true);
            });

            return(new ParseResult(ResultLevel.Success));
        }
Esempio n. 9
0
 private static void AddMemberToIndexer(MetadataItem memberModel, string outputPath, ApiReferenceViewModel indexer)
 {
     if (memberModel.Type == MemberType.Namespace)
     {
         indexer.Add(memberModel.Name, outputPath);
     }
     else
     {
         TreeIterator.Preorder(memberModel, null, s => s.Items, (member, parent) =>
         {
             string path;
             if (indexer.TryGetValue(member.Name, out path))
             {
                 Logger.LogWarning($"{member.Name} already exists in {path}, the duplicate one {outputPath} will be ignored.");
             }
             else
             {
                 indexer.Add(member.Name, outputPath);
             }
             return(true);
         });
     }
 }