private static bool TryDocument(string path, out RuleDocument document)
        {
            var reader = new MarkdownReader(yamlHeaderOnly: false);
            var stream = reader.Read(File.ReadAllText(path), path);
            var lexer  = new RuleLexer();

            document = lexer.Process(stream);
            return(document != null);
        }
示例#2
0
        private RuleHelpInfo GetHelpInfo(PipelineContext context, string name)
        {
            if (string.IsNullOrEmpty(context.Source.File.HelpPath))
            {
                return(null);
            }

            var culture = context.Culture;

            for (var i = 0; i < culture.Length; i++)
            {
                var path = Path.Combine(context.Source.File.HelpPath, string.Concat(culture[i], "/", name, ".md"));

                if (!File.Exists(path))
                {
                    continue;
                }

                var reader   = new MarkdownReader(yamlHeaderOnly: false);
                var stream   = reader.Read(markdown: File.ReadAllText(path: path), path: path);
                var lexer    = new RuleLexer();
                var document = lexer.Process(stream: stream);

                if (document != null)
                {
                    return(new RuleHelpInfo(name: name, displayName: document.Name ?? name, moduleName: context.Source.File.ModuleName)
                    {
                        Synopsis = document.Synopsis?.Text,
                        Description = document.Description?.Text,
                        Recommendation = document.Recommendation?.Text ?? document.Synopsis?.Text,
                        Notes = document.Notes?.Text,
                        Annotations = document.Annotations?.ToHashtable()
                    });
                }
            }
            return(null);
        }
示例#3
0
        private RuleDocument GetDocument(TokenStream stream)
        {
            var lexer = new RuleLexer();

            return(lexer.Process(stream: stream));
        }