public async Task TestSendMarkdown() { //目前支持的markdown语法是如下的子集 var markdownText = new MarkdownBuilder() //1. 标题 (支持1至6级标题,注意#与文字中间要有空格) .AppendHeaderText(1, "标题一") .AppendHeaderText(2, "标题二") .AppendHeaderText(3, "标题三") .AppendHeaderText(4, "标题四") .AppendHeaderText(5, "标题五") .AppendHeaderText(6, "标题六") //2. 加粗 .AppendBoldText("bold") .AppendLine() //3. 链接 .AppendLinkText("这是一个链接", "http://work.weixin.qq.com/api/doc") .AppendLine() //4. 行内代码段(暂不支持跨行) .AppendCode("code") .AppendLine() //5. 引用 .AppendReferenceText("引用文字") .AppendLine() //6. 字体颜色(只支持3种内置颜色) .AppendColorText(TextColor.Information, "绿色") .AppendColorText(TextColor.Comment, "灰色") .AppendColorText(TextColor.Warning, "橙红色") .AppendLine() .Append("normal text") .AppendLine() .Build(); await client.SendMarkdown(markdownText); }
public static string CreateRefactoringsReadMe(IEnumerable <RefactoringDescriptor> refactorings, IComparer <string> comparer) { var mb = new MarkdownBuilder(); mb.AppendHeader2("Roslynator Refactorings"); Table table = Table("Id", "Title", TableHeader("Enabled by Default", Alignment.Center)); foreach (RefactoringDescriptor refactoring in refactorings.OrderBy(f => f.Title, comparer)) { table.AddRow( refactoring.Id, Link(refactoring.Title.TrimEnd('.'), $"../../docs/refactorings/{refactoring.Id}.md"), RawText((refactoring.IsEnabledByDefault) ? "✓" : "")); } mb.Append(table); return(mb.ToString()); }
private static Item BuildStageItem(string lobbyPath, IEnumerable <string> paths, string header) { MarkdownBuilder builder = new MarkdownBuilder(); builder.Header(header); if (string.IsNullOrEmpty(lobbyPath)) { builder.Italic("No lobby directory."); } else { builder.Link(lobbyPath, ActionBuilder.PathOpenUri(lobbyPath)); } builder.WriteLine(); builder.WritePathLists(paths, lobbyPath); return(Item.AsMarkdown(builder.ToString())); }
public static string CreateAnalyzerMarkdown(AnalyzerDescriptor analyzer) { var mb = new MarkdownBuilder(new MarkdownSettings(tableFormatting: TableFormatting.All)); mb.AppendHeader1($"{((analyzer.IsObsolete) ? "[deprecated] " : "")}{analyzer.Id}: {analyzer.Title.TrimEnd('.')}"); Table table = Table("Property", "Value") .AddRow("Id", analyzer.Id) .AddRow("Category", analyzer.Category) .AddRow("Default Severity", analyzer.DefaultSeverity) .AddRow("Enabled by Default", RawText(GetBooleanAsText(analyzer.IsEnabledByDefault))) .AddRow("Supports Fade-Out", RawText(GetBooleanAsText(analyzer.SupportsFadeOut))) .AddRow("Supports Fade-Out Analyzer", RawText(GetBooleanAsText(analyzer.SupportsFadeOutAnalyzer))); mb.Append(table); ReadOnlyCollection <SampleDescriptor> samples = analyzer.Samples; if (samples.Count > 0) { mb.AppendHeader2((samples.Count == 1) ? "Example" : "Examples"); AppendSamples(mb, samples, Header3("Code with Diagnostic"), Header3("Code with Fix")); } mb.AppendHeader2("How to Suppress"); mb.AppendHeader3("SuppressMessageAttribute"); mb.AppendCSharpCodeBlock($"[assembly: SuppressMessage(\"{analyzer.Category}\", \"{analyzer.Id}:{analyzer.Title}\", Justification = \"<Pending>\")]"); mb.AppendHeader3("#pragma"); mb.AppendCSharpCodeBlock($"#pragma warning disable {analyzer.Id} // {analyzer.Title}\r\n#pragma warning restore {analyzer.Id} // {analyzer.Title}"); mb.AppendHeader3("Ruleset"); mb.AppendListItem(Link("How to configure rule set", "../HowToConfigureAnalyzers.md")); return(mb.ToString()); }
public static string CreateRefactoringsMarkdown(IEnumerable <RefactoringDescriptor> refactorings, IComparer <string> comparer) { var mb = new MarkdownBuilder(); mb.Append(Header2("Roslynator Refactorings")); foreach (RefactoringDescriptor refactoring in refactorings.OrderBy(f => f.Title, comparer)) { mb.AppendHeader4($"{refactoring.Title} ({refactoring.Id})"); mb.AppendListItem(Bold("Syntax"), ": ", Join(", ", refactoring.Syntaxes.Select(f => f.Name))); if (!string.IsNullOrEmpty(refactoring.Span)) { mb.AppendListItem(Bold("Span"), ": ", refactoring.Span); } AppendRefactoringSamples(mb, refactoring); } return(mb.ToString()); }
public static string CreateCodeFixesReadMe(IEnumerable <CodeFixDescriptor> codeFixes, IEnumerable <CompilerDiagnosticDescriptor> diagnostics, IComparer <string> comparer) { var mb = new MarkdownBuilder(); mb.AppendHeader2("Roslynator Code Fixes"); Table table = Table("Id", "Title", "Fixable Diagnostics", TableHeader("Enabled by Default", Alignment.Center)); foreach (CodeFixDescriptor codeFix in codeFixes.OrderBy(f => f.Title, comparer)) { table.AddRow( codeFix.Id, codeFix.Title.TrimEnd('.'), Join(", ", codeFix.FixableDiagnosticIds.Join(diagnostics, f => f, f => f.Id, (f, g) => (object)Link(f, g.HelpUrl))), RawText((codeFix.IsEnabledByDefault) ? "✓" : "")); } mb.Append(table); return(mb.ToString()); }
public static string CreateAnalyzersReadMe(IEnumerable <AnalyzerDescriptor> analyzers, IComparer <string> comparer) { var mb = new MarkdownBuilder(); mb.AppendHeader2("Roslynator Analyzers"); Table table = Table("Id", "Title", "Category", TableHeader("Enabled by Default", Alignment.Center)); foreach (AnalyzerDescriptor analyzer in analyzers.OrderBy(f => f.Id, comparer)) { table.AddRow( analyzer.Id, Link(analyzer.Title.TrimEnd('.'), $"../../docs/analyzers/{analyzer.Id}.md"), analyzer.Category, RawText((analyzer.IsEnabledByDefault) ? "✓" : "")); } mb.Append(table); return(mb.ToString()); }
private Item.Markdown BuildOutputList(Result result) { MarkdownBuilder builder = new MarkdownBuilder(); if (result?.Records == null || result.Records.Count < 1) { builder.Italic("Oh snap! No results for this ridiculous search term, please try it later when someone implements it."); } else { foreach (Record record in result.Records) { builder.Bullet(); builder.Link(record.Document.Title, record.Document.Href); builder.Write(" "); builder.Italic($"({record.Document.Preview})"); } } return(builder.ToString()); }
public static void Run( [TimerTrigger("0 0 0 1 * *")] TimerInfo myTimer, TraceWriter log, [SendGrid] out Mail message) { var year = DateTime.Today.AddMonths(-1).Year; var month = DateTime.Today.AddMonths(-1).Month; var queries = new QueryService(year, month); var stringDate = $"{year}.{month.ToString("D2")}"; log.Info($"WTS: Get Application Insight data from {stringDate}"); var projectData = DataService.GetData(queries.Projects); var frameworksData = DataService.GetData(queries.Frameworks); var pagesData = DataService.GetData(queries.Pages); var featuresData = DataService.GetData(queries.Features); var servicesData = DataService.GetData(queries.Services); var testingData = DataService.GetData(queries.Testing); var entryPointData = DataService.GetData(queries.EntryPoints); var languageData = DataService.GetData(queries.Languages); log.Info($"WTS: Create Md File"); var mdText = new MarkdownBuilder() .AddHeader(year, month) .AddTable("Project Type", "Project", projectData) .AddTable("Framework", "Framework Type", frameworksData) .AddTable("Pages", "Pages", pagesData) .AddTable("Features", "Features", featuresData) .AddTable("Services", "Services", servicesData) .AddTable("Testing", "Testing", testingData) .AddTable("Windows Template Studio entry point", "Entry point", entryPointData) .AddTable("Programming languages", "Languages", languageData) .GetText(); log.Info($"WTS: send data mail"); message = MailService.CreateMail(mdText, stringDate); log.Info($"WTS: Finish"); }
/// <summary> /// Create a constructor with links and parameters /// </summary> /// <param name="currentItem">The current location to create this Constructor name with links</param> /// <param name="constructor">The constructor to clean up</param> /// <param name="useFullName">Use full name of the constructor</param> /// <param name="useParameterNames">Use parameter names if set to false only type will be shown</param> /// <returns>The markdown string</returns> public static string CreateFullConstructorsWithLinks(IMarkdownItem currentItem, MarkdownConstructor constructor, bool useFullName, bool useParameterNames) { var parameters = constructor.InternalItem.GetParameters(); MarkdownBuilder mb = new MarkdownBuilder(); string name = useFullName ? CleanFullName(constructor.ParentType.InternalType, false, false) : CleanName(constructor.ParentType.Name, false, false); if (constructor.FileName != null) { mb.Link(name, currentItem.To(constructor)); } else { mb.Append(name); } mb.Append(" ("); if (parameters.Length > 0) { StringBuilder sb = new StringBuilder(); for (var i = 0; i < parameters.Length; i++) { var type = parameters[i].ParameterType; var link = CreateFullTypeWithLinks(currentItem, type, useFullName, true); sb.Append(link); if (useParameterNames) { sb.Append($" {parameters[i].Name}"); } if (i + 1 != parameters.Length) { sb.Append(", "); } } mb.Append(sb.ToString()); } mb.Append(")"); return(mb.ToString()); }
private void BuildTable(MarkdownBuilder mb, IMarkdownItem item, string[] headers, MarkdownMethod mdType) { mb.AppendLine(); List <string[]> data = new List <string[]>(); string[] dataValues = new string[headers.Length]; Type lookUpType = null; if (item.ItemType == MarkdownItemTypes.Method) { lookUpType = item.As <MarkdownMethod>().ReturnType; } dataValues[0] = Cleaner.CreateFullTypeWithLinks(mdType, lookUpType, false, false); string name = item.FullName; if (item.ItemType == MarkdownItemTypes.Method) { name = Cleaner.CreateFullMethodWithLinks(mdType, item.As <MarkdownMethod>(), false, true, false); } else if (item.ItemType == MarkdownItemTypes.Property) { name = Cleaner.CreateFullParameterWithLinks(mdType, item.As <MarkdownProperty>(), false, _options.ShowParameterNames); } else if (item.ItemType == MarkdownItemTypes.Constructor) { name = Cleaner.CreateFullConstructorsWithLinks(mdType, item.As <MarkdownConstructor>(), false, _options.BuildConstructorPages); } dataValues[1] = name; data.Add(dataValues); mb.Table(headers, data, true); mb.AppendLine(); }
public static string CreateRefactoringMarkdown(RefactoringDescriptor refactoring) { var mb = new MarkdownBuilder(new MarkdownSettings(tableFormatting: TableFormatting.All)); mb.AppendHeader2(refactoring.Title); Table("Property", "Value") .AddRow("Id", refactoring.Id) .AddRow("Title", refactoring.Title) .AddRow("Syntax", string.Join(", ", refactoring.Syntaxes.Select(f => f.Name))) .AddRowIf(!string.IsNullOrEmpty(refactoring.Span), "Span", refactoring.Span) .AddRow("Enabled by Default", RawText(GetBooleanAsText(refactoring.IsEnabledByDefault))) .AppendTo(mb); mb.AppendHeader3("Usage"); AppendRefactoringSamples(mb, refactoring); mb.AppendLink("full list of refactorings", "Refactorings.md"); return(mb.ToString()); }
public static string CreateReadMe(IEnumerable <AnalyzerDescriptor> analyzers, IEnumerable <RefactoringDescriptor> refactorings, IComparer <string> comparer) { var mb = new MarkdownBuilder(); mb.AppendLineRaw(File.ReadAllText(@"..\text\ReadMe.txt", Encoding.UTF8)); mb.AppendHeader3("List of Analyzers"); foreach (AnalyzerDescriptor analyzer in analyzers.OrderBy(f => f.Id, comparer)) { mb.AppendListItem(analyzer.Id, " - ", Link(analyzer.Title.TrimEnd('.'), $"docs/analyzers/{analyzer.Id}.md")); } mb.AppendHeader3("List of Refactorings"); foreach (RefactoringDescriptor refactoring in refactorings.OrderBy(f => f.Title, comparer)) { mb.AppendListItem(Link(refactoring.Title.TrimEnd('.'), $"docs/refactorings/{refactoring.Id}.md")); } return(mb.ToString()); }
internal static IEnumerable <Item> BuildProjectItems(IEnumerable <IProject> projects) { List <Item> result = new List <Item>(); foreach (IProject project in projects) { MarkdownBuilder builder = new MarkdownBuilder(); builder.Header(project.Name); builder.WriteLine(project.Path); builder.Italic($"{project.Packages.Count} package(s) referenced."); builder.WriteLine(); foreach (IPackage package in project.Packages.Values) { BuildProjectItem(builder, package); } result.Add(Item.AsMarkdown(builder.ToString())); } return(result); }
/// <summary> /// Override the summary report so we can insert a link to our report and the failed tests /// </summary> /// <returns></returns> protected override string GetTestSummaryHeader() { MarkdownBuilder MB = new MarkdownBuilder(base.GetTestSummaryHeader()); string ReportLink = GetConfiguration().ReportOutputURL; if (string.IsNullOrEmpty(ReportLink) == false) { MB.Paragraph(string.Format("Report: {0}", ReportLink)); } var EditorArtifacts = SessionArtifacts.Where(A => A.SessionRole.RoleType == UnrealTargetRole.Editor).FirstOrDefault(); if (EditorArtifacts != null) { AutomationLogParser Parser = new AutomationLogParser(EditorArtifacts.LogParser); IEnumerable <AutomationTestResult> AllTests = Parser.GetResults(); IEnumerable <AutomationTestResult> FailedTests = AllTests.Where(R => !R.Passed); MB.Paragraph(string.Format("{0} of {1} tests passed", AllTests.Count() - FailedTests.Count(), AllTests.Count())); if (FailedTests.Count() > 0) { MB.H3("Test Failures"); foreach (AutomationTestResult Result in FailedTests) { MB.H4(string.Format("{0} Failed", Result.DisplayName)); MB.UnorderedList(Result.Events); } } } return(MB.ToString()); }
private static void BuildEnumTable(MarkdownBuilder mb, IEnumerable <XmlDocumentComment> comments, MarkdownEnum value) { var underlyingEnumType = Enum.GetUnderlyingType(value.InternalType); var enums = value.EnumNames .Select(x => new { Name = x, Value = (Convert.ChangeType(Enum.Parse(value.InternalType, x), underlyingEnumType)) }) .OrderBy(x => x.Value) .ToArray(); if (enums.Any()) { mb.AppendLine($"##\tEnum"); mb.AppendLine(); string[] head = new[] { "Value", "Name", "Summary" }; var data = enums.Select(item => { var summary = comments.FirstOrDefault(x => x.MemberName == item.Name || x.MemberName.StartsWith(item.Name + "`"))?.Summary ?? ""; return(new[] { item.Value.ToString(), item.Name, summary }); }); mb.Table(head, data, true); mb.AppendLine(); } }
/// <summary> /// Create a full parameter name with links /// </summary> /// <param name="currentItem">The current markdown item with the property to be rendered</param> /// <param name="property">The markdown property</param> /// <param name="useFullName">Determines if the fullName of Markdown property should be used</param> /// <param name="useParameterNames">Determines if parameter names should be shown on property</param> /// <returns>Returns the full parameter name with links rendered in markdown</returns> public static string CreateFullParameterWithLinks(IMarkdownItem currentItem, MarkdownProperty property, bool useFullName, bool useParameterNames) { var fullParameterName = property.InternalItem.ToString(); MarkdownBuilder mb = new MarkdownBuilder(); if (property.FileName != null) { mb.Link(property.Name, currentItem.To(property)); } else { mb.Append(property.Name); } var parts = fullParameterName.Split('[', ']'); var index = property.InternalItem.GetPropertyKeyType(); if (index.Key != null) { mb.Append(" [ "); var link = CreateFullTypeWithLinks(currentItem, index.Key, useFullName, true); mb.Append(link); if (useParameterNames) { mb.Append($" {index.Name}"); } mb.Append(" ]"); } return(mb.ToString()); }
/// <summary> /// Cleans a method and adds the appropiate links /// </summary> /// <param name="currentItem">The current markdown item containing the method to be cleaned</param> /// <param name="method">The method to be cleaned</param> /// <param name="useFullName">Determine if full name of method should be shown</param> /// <param name="useParameterNames">Determines if parameter names should be shown</param> /// <param name="parameterList">Determines if parameter names should be listed vertically</param> /// <returns>The cleaned string</returns> public static string CreateFullMethodWithLinks(IMarkdownItem currentItem, MarkdownMethod method, bool useFullName, bool useParameterNames, bool parameterList) { var parameters = method.InternalItem.GetParameters(); MarkdownBuilder mb = new MarkdownBuilder(); if (!parameterList) { if (method.FileName != null) { mb.Link(method.Name, currentItem.To(method)); } else { mb.Append(method.Name); } mb.Append(" ("); } if (parameters.Length > 0) { StringBuilder sb = new StringBuilder(); for (var i = 0; i < parameters.Length; i++) { var type = parameters[i].ParameterType; var link = CreateFullTypeWithLinks(currentItem, type, useFullName, true); if (link.IndexOf('&') > 0) { link = link.Replace("&", ""); sb.Append("out "); } if (!parameterList) { sb.Append(link); if (useParameterNames) { sb.Append($" {parameters[i].Name}"); } } else { if (useParameterNames) { sb.Append($" {parameters[i].Name}"); } sb.Append(link); } if (!parameterList) { if (i + 1 != parameters.Length) { sb.Append(", "); } } else { if (i + 1 != parameters.Length) { sb.Append("<br>"); } } } mb.Append(sb.ToString()); } if (!parameterList) { mb.Append(")"); } return(mb.ToString()); }
public async Task TestMarkdownBuilder() { var md = new MarkdownBuilder(); md.AppendBold("Hello, Markdown").AppendLine().AppendFormat("12{0}4", 3); md.AppendParagraphSeparater(); md.Append("Hi ").AppendMentionToPerson("xyz_person_id", "Person").Append(", How are you?"); Assert.AreEqual("**Hello, Markdown** \n1234\n\nHi <@personId:xyz_person_id|Person>, How are you?", md.ToString()); md.Clear(); md.Append("Hi ").AppendMentionToPerson("*****@*****.**", "Name<>&#'Person").Append(", How are you?"); Assert.AreEqual("Hi <@personEmail:[email protected]|Name<>&#'Person>, How are you?", md.ToString()); md.Clear(); md.AppendBold("Hello, Bold"); md.AppendLine(); int a = 411522630; int b = 3; md.AppendBoldFormat("{0} * {1} = {2}", a, b, a * b); md.AppendLine(); md.AppendItalic("Hello, Italic"); md.AppendParagraphSeparater(); md.Append("Hello, New Paragraph!!").AppendLine().AppendBold("Hello, Bold again!").AppendLine(); md.Append("Link: ").AppendLink("this is link", new Uri("https://www.example.com/path?p1=v1&p2=v2")).AppendLine(); md.AppendBold("Ordered List:").AppendLine(); md.AppendOrderedList("item-1").AppendOrderedList("item-2").AppendOrderedListFormat("item-{0}", 3).AppendParagraphSeparater(); md.AppendBold("Unordered List:").AppendLine(); md.AppendUnorderedList("item-1").AppendUnorderedList("item-2").AppendUnorderedListFormat("item-{0}", 3).AppendParagraphSeparater(); md.AppendBlockQuote("This is block quote.").AppendLine(); md.Append("Code: ").AppendInLineCode("printf(\"Hello, World!\");").Append("is very famous!").AppendLine(); md.BeginCodeBlock() .Append("#include <stdio.h>\n") .Append("\n") .Append("int main(void)\n") .Append("{\n") .Append(" printf(\"Hello, World!!\\n\");\n") .Append("\n") .Append(" return 0;\n") .Append("}\n") .EndCodeBlock(); md.Append("OK!"); var r = await teams.CreateMessageAsync(unitTestSpace.Id, md.ToString()); Assert.AreEqual(HttpStatusCode.OK, r.HttpStatusCode); Assert.IsTrue(r.IsSuccessStatus); md.Clear(); md.AppendMentionToGroup(MentionedGroup.All).Append(", Hello All!"); r = await teams.CreateMessageAsync(unitTestSpace.Id, md.ToString()); Assert.AreEqual(HttpStatusCode.OK, r.HttpStatusCode); Assert.IsTrue(r.IsSuccessStatus); md.Clear(); md.AppendMentionToAll().Append(", Hello All again!!"); r = await teams.CreateMessageAsync(unitTestSpace.Id, md.ToString()); Assert.AreEqual(HttpStatusCode.OK, r.HttpStatusCode); Assert.IsTrue(r.IsSuccessStatus); }
/// <summary> /// Entry point. /// </summary> /// <param name="args">args of this app.</param> /// <returns>Task for async.</returns> static async Task MainAsync(string[] args) { /* ******************************************************** * NOTE: THIS IS ONLY A SAMPLE. * I will put most codes in this Main() on purpose. * So, you will be able to understand the sample * after you read it from top to bottom. * You do not need to care about 'SampleUtil' in this code. * The 'SampleUtil' does something tedious. * Only you need to do to understand the sample * is reading this code in Main() from top to bottom. * *********************************************************/ SampleUtil.ShowTitle("[S1030] Markdown Builder", "How to use markdown builder."); // Load encrypted token that is encrypted by 'S0010SetupSamples'. ProtectedString token = SampleUtil.LoadEncryptedToken(); if (token != null) { //////////////////////////////////////////////////////////////////////////// // Create an instance for Webex Teams API. // As best practice, the instance should be re-used as long as possible. // For bots, the lifetime of the instance typically is almost the same as the lifetime of the app process. var teams = TeamsAPI.CreateVersion1Client(token); // Try to find Sample space. var space = await SampleUtil.FindSampleSpaceAsync(teams); if (space != null) { //////////////////////////////////////////////////////////////// // You can build markdown that can be used in Webex Teams API. var md = new MarkdownBuilder(); // Bold md.Append("Hello, Bold ").AppendBold("WebexTeams").Append("!!").AppendLine(); // Italic md.Append("Hello, Italic ").AppendItalic("WebexTeams").Append("!!").AppendLine(); // Link md.AppendParagraphSeparater(); md.AppendBlockQuote("Hi!").AppendLink("This is Link", new Uri("https://www.google.com/")).Append("."); // Block Quote md.AppendParagraphSeparater(); md.AppendBlockQuote("Hi! This is Block Quote."); // Ordered List md.AppendParagraphSeparater(); md.AppendBold("This is Ordered list:").AppendLine(); md.AppendOrderedList("list item 01"); md.AppendOrderedList("list item 02"); md.AppendOrderedList("list item 03"); // Unordered List md.AppendParagraphSeparater(); md.AppendBold("This is Unordered list:").AppendLine(); md.AppendUnorderedList("list item 01"); md.AppendUnorderedList("list item 02"); md.AppendUnorderedList("list item 03"); // Inline Code. md.AppendParagraphSeparater(); md.Append("The ").AppendInLineCode("print(\"Hello, World!!\")").Append(" is inline code."); // Code Block. md.AppendParagraphSeparater(); md.Append("This is Code Block:").AppendLine(); md.BeginCodeBlock() .Append("#include <stdio.h>\n") .Append("\n") .Append("int main(void)\n") .Append("{\n") .Append(" printf(\"Hello, World!!\\n\");\n") .Append("\n") .Append(" return 0;\n") .Append("}\n") .EndCodeBlock(); var r = await teams.CreateMessageAsync(space, md.ToString()); if (r.IsSuccessStatus) { SampleUtil.ShowMessage("Succeeded to post a message: Id = {0}", r.Data.Id); } else { SampleUtil.ShowMessage("Failed to post a message: StatusCode = {0}", r.HttpStatusCode); } // Mentioned to All. md.Clear(); md.Append("Hi ").AppendMentionToAll().Append(", this message is mentioned to all in the space."); r = await teams.CreateMessageAsync(space, md.ToString()); if (r.IsSuccessStatus) { SampleUtil.ShowMessage("Succeeded to post a message: Id = {0}", r.Data.Id); } else { SampleUtil.ShowMessage("Failed to post a message: StatusCode = {0}", r.HttpStatusCode); } } } }
public abstract void WriteToMarkdown(MarkdownBuilder builder, int intent);
public MarkdownBuilder AppendTo(MarkdownBuilder mb) { return(mb.AppendQuoteBlock(Text)); }
public override string ToMarkdown() { var markdownBuilder = new MarkdownBuilder(this); return(markdownBuilder.Build()); }
public static void BuildNamespaceLinks(this IMarkdownItem item, string namespaceValue, MarkdownBuilder mb) { var namespaceItems = namespaceValue.Split('.'); string globalNamespace = ""; mb.Append("Namespace: "); foreach (var namespaceItem in namespaceItems) { if (!String.IsNullOrEmpty(globalNamespace)) { globalNamespace += "."; mb.Append(" > "); } globalNamespace = globalNamespace + namespaceItem; if (item.Project.TryGetValue(new TypeWrapper(globalNamespace), out IMarkdownItem foundItem)) { mb.Link(namespaceItem, item.To(foundItem)); } else { mb.Link(namespaceItem, ""); } } mb.AppendLine().AppendLine(); }
public MarkdownBuilder AppendTo(MarkdownBuilder mb) { return(mb.AppendHeader(Level, Text)); }
public override void WriteToMarkdown(MarkdownBuilder builder, int intent) { builder.Bullet(intent); builder.Link(Name, GetLinkUrl()); }
public MarkdownBuilder AppendTo(MarkdownBuilder mb) { return(mb.AppendOrderedListItem(Number, Text)); }
public MarkdownBuilder AppendTo(MarkdownBuilder mb) { return(mb.AppendListItem(Text)); }
public override string ToMarkdown() { var markdownBuilder = new MarkdownBuilder(this); return markdownBuilder.Build(); }
/// <summary> /// Builds the markdown method page content /// </summary> /// <param name="item">The markdown method item</param> /// <returns>The markdown content</returns> public string BuildPage(MarkdownMethod item) { Dictionary <string, string> parameterPairs = new Dictionary <string, string>(); Dictionary <string, string> returnPairs = new Dictionary <string, string>(); XmlDocumentComment[] comments = new XmlDocumentComment[0]; MarkdownBuilder mb = new MarkdownBuilder(); var name = Cleaner.CreateFullMethodWithLinks(item, item.As <MarkdownMethod>(), false, true, true); // method name + params name with type var FullName = item.Name + name; var typeZeroHeaders = new[] { "Return", "Name" }; mb.HeaderWithLink(1, item.FullName, item.To(item)); mb.AppendLine(); mb.AppendLine(item.Summary); BuildTable(mb, item, typeZeroHeaders, item); mb.Append("#### Parameters"); mb.AppendLine(); if (File.Exists(MarkdownItemBuilder.xmlPath)) { comments = VSDocParser.ParseXmlParameterComment(XDocument.Parse(File.ReadAllText(MarkdownItemBuilder.xmlPath)), ""); foreach (var comment in comments) { foreach (var param in item.Parameters) { var foundParameterComment = comment.Parameters.FirstOrDefault(x => x.Key == param.Name).Value; if (foundParameterComment != null) { foundParameterComment = foundParameterComment.Substring(0, foundParameterComment.LastIndexOf('<')); foundParameterComment = foundParameterComment.Substring(foundParameterComment.IndexOf('>') + 1); var MethodName = Cleaner.CleanName(comment.MemberName, false, false); // method name + param name + parameter summary if (!parameterPairs.ContainsKey(MethodName + " " + param.Name)) { parameterPairs.Add(MethodName + " " + param.Name, foundParameterComment); } } } } } var numberOfParameters = item.Parameters.Length; for (int i = 1; i <= numberOfParameters; i++) { if (i == numberOfParameters) { ConstructParameter(mb, FullName, parameterPairs, false, i); } else { ConstructParameter(mb, FullName, parameterPairs, true, i); } } mb.AppendLine(); mb.Append("#### Returns"); mb.AppendLine(); Type lookUpType = null; if (item.ItemType == MarkdownItemTypes.Method) { lookUpType = item.As <MarkdownMethod>().ReturnType; } var returned = Cleaner.CreateFullTypeWithLinks(item, lookUpType, false, false); string foundReturnComment = string.Empty; if (File.Exists(MarkdownItemBuilder.xmlPath)) { comments = VSDocParser.ParseXmlComment(XDocument.Parse(File.ReadAllText(MarkdownItemBuilder.xmlPath)), ""); if (comments != null) { foreach (var k in comments) { k.MemberName = Cleaner.CleanName(k.MemberName, false, false); returnPairs[k.MemberName] = k.Returns; } foundReturnComment = returnPairs.FirstOrDefault(x => x.Key == item.Name).Value; } } foundReturnComment = Regex.Replace(foundReturnComment, @"<see cref=""\w:([^\""]*)""\s*\/>", m => VSDocParser.ResolveSeeElement(m, "")); Console.WriteLine(returned); Console.WriteLine(foundReturnComment); mb.Append(returned); mb.AppendLine("<br>"); mb.Append(foundReturnComment); return(mb.ToString()); }
public static StringBuilder AppendMarkdown(this StringBuilder builder, string value, Markdown markdown = 0) { return(builder.Append(MarkdownBuilder.Format(value, markdown))); }