Exemple #1
0
        public ParseResult Run(MetadataModel yaml, ResolverContext context)
        {
            var index = yaml.Indexer;

            TreeIterator.PreorderAsync <MetadataItem>(yaml.TocYamlViewModel, null,
                                                      (s) =>
            {
                if (s.IsInvalid)
                {
                    return(null);
                }
                else
                {
                    return(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(Task.FromResult(true));
            }
                                                      ).Wait();
            return(new ParseResult(ResultLevel.Success));
        }
Exemple #2
0
        public ParseResult Run(MetadataModel yaml, ResolverContext context)
        {
            yaml.TocYamlViewModel = yaml.TocYamlViewModel.ShrinkToSimpleTocWithNamespaceNotEmpty();
            // Comparing to toc files, yaml files are all in api folder
            TreeIterator.PreorderAsync <MetadataItem>(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(Task.FromResult(true));
            }
                                                      ).Wait();
            return(new ParseResult(ResultLevel.Success));
        }
Exemple #3
0
        public ParseResult Run(MetadataModel yaml, ResolverContext context)
        {
            TreeIterator.PreorderAsync <MetadataItem>(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(Task.FromResult(true));
            }
                                                      ).Wait();

            return(new ParseResult(ResultLevel.Success));
        }
Exemple #4
0
        public ParseResult Run(MetadataModel yaml, ResolverContext context)
        {
            TreeIterator.PreorderAsync <MetadataItem>(yaml.TocYamlViewModel, null,
                                                      (s) =>
            {
                if (s.IsInvalid)
                {
                    return(null);
                }
                else
                {
                    return(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(Task.FromResult(true));
            }
                                                      ).Wait();

            return(new ParseResult(ResultLevel.Success));
        }
Exemple #5
0
        public ParseResult Run(MetadataModel yaml, ResolverContext context)
        {
            TreeIterator.PreorderAsync <MetadataItem>(yaml.TocYamlViewModel, null,
                                                      (s) =>
            {
                if (s.IsInvalid)
                {
                    return(null);
                }
                else
                {
                    return(s.Items);
                }
            }, (current, parent) =>
            {
                if (current.Inheritance != null && current.Inheritance.Count > 0)
                {
                    current.Inheritance.ForEach(s =>
                    {
                        if (!s.IsExternalPath)
                        {
                            s.Href = ResolveInternalLink(yaml.Indexer, s.Name);
                        }
                    });
                }

                if (current.Syntax != null && current.Syntax.Parameters != null)
                {
                    current.Syntax.Parameters.ForEach(s =>
                    {
                        Debug.Assert(s.Type != null);
                        if (s.Type != null && !s.Type.IsExternalPath)
                        {
                            s.Type.Href = ResolveInternalLink(yaml.Indexer, s.Type.Name);
                        }
                    });
                }

                if (current.Syntax != null && current.Syntax.Return != null && current.Syntax.Return.Type != null)
                {
                    current.Syntax.Return.Type.Href = ResolveInternalLink(yaml.Indexer, current.Syntax.Return.Type.Name);
                }

                return(Task.FromResult(true));
            }
                                                      ).Wait();

            return(new ParseResult(ResultLevel.Success));
        }
        /// <summary>
        /// The yaml layout should be
        /// namespace -- class level -- method level
        /// </summary>
        /// <param name="allMembers"></param>
        /// <returns></returns>
        public ParseResult Run(MetadataModel yaml, ResolverContext context)
        {
            ParseResult   overall = new ParseResult(ResultLevel.Success);
            StringBuilder message = new StringBuilder();

            foreach (var member in yaml.TocYamlViewModel.Items)
            {
                CheckNamespaces(member);
            }

            if (message.Length > 0)
            {
                overall.ResultLevel = ResultLevel.Warn;
                overall.Message     = message.ToString();
            }

            return(overall);
        }
Exemple #7
0
        /// <summary>
        /// TODO: input Namespace list instead;
        /// TODO: Save to ...yml.map
        /// </summary>
        /// <param name="allMembers"></param>
        /// <returns></returns>
        public static MetadataModel ResolveMetadata(Dictionary <string, MetadataItem> allMembers, string apiFolder)
        {
            MetadataModel viewModel = new MetadataModel();

            viewModel.Indexer          = new Dictionary <string, MetadataItem>();
            viewModel.TocYamlViewModel = new MetadataItem()
            {
                Type  = MemberType.Toc,
                Items = allMembers.Where(s => s.Value.Type == MemberType.Namespace).Select(s => s.Value).ToList(),
            };
            viewModel.Members = new List <MetadataItem>();
            ResolverContext context = new ResolverContext {
                ApiFolder = apiFolder
            };
            var result = ExecutePipeline(viewModel, context);

            result.WriteToConsole();
            return(viewModel);
        }
Exemple #8
0
        public static ParseResult ExecutePipeline(MetadataModel yaml, ResolverContext context)
        {
            ParseResult result = new ParseResult(ResultLevel.Success);

            foreach (var pipeline in pipelines)
            {
                result = pipeline.Run(yaml, context);
                if (result.ResultLevel == ResultLevel.Error)
                {
                    return(result);
                }

                if (!string.IsNullOrEmpty(result.Message))
                {
                    result.WriteToConsole();
                }
            }

            return(result);
        }
Exemple #9
0
        public ParseResult Run(MetadataModel yaml, ResolverContext context)
        {
            var index = yaml.Indexer;

            TreeIterator.PreorderAsync <MetadataItem>(yaml.TocYamlViewModel, null,
                                                      (s) =>
            {
                if (s.IsInvalid)
                {
                    return(null);
                }
                else
                {
                    return(s.Items);
                }
            }, (member, parent) =>
            {
                // get all the possible places where link is possible
                member.Remarks = ResolveText(index, member.Remarks);
                member.Summary = ResolveText(index, member.Summary);
                if (member.Syntax != null && member.Syntax.Parameters != null)
                {
                    member.Syntax.Parameters.ForEach(s =>
                    {
                        s.Description = ResolveText(index, s.Description);
                    });
                }
                if (member.Syntax != null && member.Syntax.Return != null)
                {
                    member.Syntax.Return.Description = ResolveText(index, member.Syntax.Return.Description);
                }

                // resolve parameter's Type


                return(Task.FromResult(true));
            }
                                                      ).Wait();

            return(new ParseResult(ResultLevel.Success));
        }
Exemple #10
0
        public ParseResult Run(MetadataModel yaml, ResolverContext context)
        {
            TreeIterator.PreorderAsync <MetadataItem>(yaml.TocYamlViewModel, null,
                                                      (s) =>
            {
                if (s.IsInvalid)
                {
                    return(null);
                }
                else
                {
                    return(s.Items);
                }
            }, (member, parent) =>
            {
                if (member.Type != MemberType.Toc)
                {
                    MetadataItem item;
                    if (yaml.Indexer.TryGetValue(member.Name, out item))
                    {
                        ParseResult.WriteToConsole(ResultLevel.Error, "{0} already exists in {1}, the duplicate one {2} will be ignored", member.Name, item.Href, member.Href);
                    }
                    else
                    {
                        yaml.Indexer.Add(
                            member.Name,
                            new MetadataItem {
                            Name = member.Name, Href = context.ApiFolder.ForwardSlashCombine(member.Href)
                        });
                    }
                }

                return(Task.FromResult(true));
            }
                                                      ).Wait();

            return(new ParseResult(ResultLevel.Success));
        }
Exemple #11
0
 public ParseResult Run(MetadataModel yaml, ResolverContext context)
 {
     // Moved to Metadata Visitor
     return(new ParseResult(ResultLevel.Success));
 }