Пример #1
0
        public static string CreateAnalyzersByCategoryMarkdown(IEnumerable <AnalyzerDescriptor> analyzers, IComparer <string> comparer)
        {
            MDocument document = Document(
                Heading2("Roslynator Analyzers by Category"),
                Table(
                    TableRow("Category", "Title", "Id", TableColumn(HorizontalAlignment.Center, "Enabled by Default")),
                    GetRows()));

            document.AddFootnote();

            return(document.ToString());

            IEnumerable <MTableRow> GetRows()
            {
                foreach (IGrouping <string, AnalyzerDescriptor> grouping in analyzers
                         .GroupBy(f => MarkdownEscaper.Escape(f.Category))
                         .OrderBy(f => f.Key, comparer))
                {
                    foreach (AnalyzerDescriptor analyzer in grouping.OrderBy(f => f.Title, comparer))
                    {
                        yield return(TableRow(
                                         grouping.Key,
                                         Link(analyzer.Title.TrimEnd('.'), $"../../docs/analyzers/{analyzer.Id}.md"),
                                         analyzer.Id,
                                         CheckboxOrHyphen(analyzer.IsEnabledByDefault)));
                    }
                }
            }
        }
Пример #2
0
        public static string CreateAnalyzersByCategoryMarkdown(IEnumerable <AnalyzerDescriptor> analyzers, IComparer <string> comparer)
        {
            var mb = new MarkdownBuilder();

            mb.AppendHeader2("Roslynator Analyzers by Category");

            Table table = Table("Category", "Title", "Id", TableHeader("Enabled by Default", Alignment.Center));

            foreach (IGrouping <string, AnalyzerDescriptor> grouping in analyzers
                     .GroupBy(f => MarkdownEscaper.Escape(f.Category, mb.Settings.ShouldBeEscaped))
                     .OrderBy(f => f.Key, comparer))
            {
                foreach (AnalyzerDescriptor analyzer in grouping.OrderBy(f => f.Title, comparer))
                {
                    table.AddRow(
                        grouping.Key,
                        Link(analyzer.Title.TrimEnd('.'), $"../../docs/analyzers/{analyzer.Id}.md"),
                        analyzer.Id,
                        RawText((analyzer.IsEnabledByDefault) ? "&#x2713;" : ""));
                }
            }

            mb.Append(table);

            return(mb.ToString());
        }
Пример #3
0
 public static void MarkdownEscaper_Escape_NoEscape(string value, bool shouldBeEscaped)
 {
     Assert.Equal(
         (shouldBeEscaped) ? "\\" + value : value,
         MarkdownEscaper.Escape(value, shouldBeEscaped: ch => false, escapingChar: '\\'));
 }
Пример #4
0
 public static void MarkdownEscaper_Escape_SingleChar(string value, bool shouldBeEscaped)
 {
     Assert.Equal((shouldBeEscaped) ? "\\" + value : value, MarkdownEscaper.Escape(value));
 }
Пример #5
0
 public static void MarkdownEscaper_Escape_Chars()
 {
     Assert.Equal(CharsEscaped, MarkdownEscaper.Escape(Chars));
     Assert.Equal(CharsEscaped + NewLine + CharsEscaped, MarkdownEscaper.Escape(Chars + NewLine + Chars));
 }