public void DotNetCommentText_FromXml_InLine_RealExample_A() { //arrange XElement element = XElement.Parse(@"<summary><see cref='P:Test.ClassSeeAlso.PropertyA'/> or <see cref='P:Test.ClassSeeAlso.PropertyA'>Local property</see></summary>", LoadOptions.PreserveWhitespace); //act DotNetComment result = DotNetComment.FromVisualStudioXml(element); DotNetCommentGroup groupResult = result as DotNetCommentGroup; //assert Assert.AreEqual(3, groupResult.Comments.Count); Assert.AreEqual(" or ", (groupResult.Comments[1] as DotNetCommentText).Text); }
public void DotNetCommentCode_FromXml_CDATA() { //arrange string xml = "<html><body></body></html>"; XElement element = XElement.Parse("<para>Word word word <![CDATA[" + xml + "]]> word word word.</para>", LoadOptions.PreserveWhitespace); //act DotNetCommentGroup result = DotNetCommentGroup.FromVisualStudioXml(element); //assert Assert.AreEqual(3, result.Comments.Count); Assert.AreEqual(xml, result.Comments[1].ToString()); }
/// <summary> /// Returns the first line of comments produced by the group. /// Intended for groups that boil down to a single line. /// </summary> internal static MarkdownLine DotNetCommentGroupToMarkdownLine(DotNetCommentGroup group, DotNetMember parent = null) { MarkdownLine line = new MarkdownLine(); if (group == null) { return(line); } foreach (DotNetComment comment in group.Comments) { line.Concat(DotNetCommentsToLine(comment, parent)); } return(line); }
public void DotNetCommentText_FromXml_InLine_RealExample_B() { //arrange XDocument document = XDocument.Load(Utilities.GetPathTo("data/DotNetCommentText_Inline_RealExample_B.xml"), LoadOptions.PreserveWhitespace); XElement element = document.Elements().First(); string inner = String.Concat(element.Nodes().Select(node => Utilities.XNodeToString(node))); //act DotNetComment result = DotNetComment.FromVisualStudioXml(element); DotNetCommentGroup groupResult = result as DotNetCommentGroup; //assert Assert.AreEqual(7, groupResult.Comments.Count); Assert.AreEqual(" or ", (groupResult.Comments[1] as DotNetCommentText).Text); Assert.AreEqual("\n", (groupResult.Comments[3] as DotNetCommentText).Text); }
public void DotNetCommentText_FromXml_SpaceAfterParamRef() { //arrange XElement element = XElement.Parse(@"<summary> Split <paramref name='text'/> on the <paramref name='delimiter'/> but do not split if <paramref name='delimiter'/> is nested within matched braces. Supports braces: {}, [], (), and <![CDATA[<>]]>. </summary>", LoadOptions.PreserveWhitespace); //act DotNetCommentGroup result = DotNetCommentGroup.FromVisualStudioXml(element); //assert Assert.AreEqual("Split ", (result[0] as DotNetCommentText).Text); Assert.AreEqual(" on the ", (result[2] as DotNetCommentText).Text); Assert.AreEqual(" \nbut do not split if ", (result[4] as DotNetCommentText).Text); Assert.AreEqual(" is nested within matched braces.\nSupports braces: {}, [], (), and ", (result[6] as DotNetCommentText).Text); }
public void DotNetCommentTypeParameterLink_FromXml_AfterText() { //arrange string xml = "<summary>The type-parameter names are: <typeparamref name='A'/>, <typeparamref name='B'/>, and <typeparamref name='C'/>.</summary>"; XElement element = XElement.Parse(xml, LoadOptions.PreserveWhitespace); //act DotNetCommentGroup result = DotNetCommentGroup.FromVisualStudioXml(element); //assert Assert.AreEqual(7, result.Comments.Count); Assert.AreEqual("The type-parameter names are: ", (result[0] as DotNetCommentText).Text); Assert.AreEqual("A", (result[1] as DotNetCommentTypeParameterLink).Name); Assert.AreEqual(", ", (result[2] as DotNetCommentText).Text); Assert.AreEqual("B", (result[3] as DotNetCommentTypeParameterLink).Name); Assert.AreEqual(", and ", (result[4] as DotNetCommentText).Text); Assert.AreEqual("C", (result[5] as DotNetCommentTypeParameterLink).Name); Assert.AreEqual(".", (result[6] as DotNetCommentText).Text); }
public void DotNetCommentText_FromXml_RealExample_A3() { //arrange XElement element = XElement.Parse(@"<summary> Tests the display of common data types that have recognized aliases in .Net. Also common data types that have long fully-qualified names. </summary>", LoadOptions.PreserveWhitespace); string expectedResult = "Tests the display of common data types that have recognized aliases in .Net.\nAlso common data types that have long fully-qualified names."; //act DotNetComment result = DotNetComment.FromVisualStudioXml(element); DotNetCommentGroup groupResult = result as DotNetCommentGroup; result = groupResult.Comments.First(); DotNetCommentText textResult = result as DotNetCommentText; //assert Assert.AreEqual(expectedResult, textResult.Text); }
internal static IMarkdownInSection DotNetCommentGroupToMarkdown(DotNetCommentGroup group, DotNetMember parent = null) { if (group.Tag == CommentTag.See || group.Tag == CommentTag.SeeAlso) { MarkdownLine line = new MarkdownLine(); foreach (DotNetComment comment in group.Comments) { line.Concat(DotNetCommentsToLine(comment, parent)); } return(line); } else { MarkdownParagraph paragraph = new MarkdownParagraph(); foreach (DotNetComment comment in group.Comments) { DotNetCommentsFillParagraph(paragraph, comment, parent); } return(paragraph); } }