public void DocumentType(Class type) { var node = this.classNodes.Find( c => c.Location == type.TranslationUnit.FileName && c.Name == type.OriginalName); if (node != null) { var file = node.HRef; if (this.typesDocumentation.ContainsKey(file)) { var docs = this.typesDocumentation[file]; var briefText = StripTags(docs[0].InnerHtml); var text = StripTags(ConstructDocumentText(docs.Skip(1).Select(d => d.OuterHtml))); type.Comment = new RawComment { BriefText = briefText, // TODO: create links in the "See Also" section; in general, convert all links Text = text, FullComment = new FullComment() }; var summary = new ParagraphComment(); summary.Content.Add(new TextComment { Text = briefText }); type.Comment.FullComment.Blocks.Add(summary); var remarks = new ParagraphComment(); remarks.Content.AddRange(text.Split('\n').Select(t => new TextComment { Text = t, HasTrailingNewline = true })); type.Comment.FullComment.Blocks.Add(remarks); } } }
public bool VisitParagraphCommand(ParagraphComment comment) { for (int i = 0; i < comment.Content.Count; i++) { if (comment.Content[i].Kind == DocumentationCommentKind.InlineCommandComment && i + 1 < comment.Content.Count && comment.Content[i + 1].Kind == DocumentationCommentKind.TextComment) { var textComment = (TextComment)comment.Content[i + 1]; textComment.Text = Helpers.RegexCommentCommandLeftover.Replace( textComment.Text, string.Empty); } } foreach (var item in comment.Content.Where(c => c.Kind == DocumentationCommentKind.TextComment)) { var textComment = (TextComment)item; if (textComment.Text.StartsWith("<", StringComparison.Ordinal)) { textComment.Text = $"{textComment.Text}>"; } else if (textComment.Text.StartsWith(">", StringComparison.Ordinal)) { textComment.Text = textComment.Text.Substring(1); } } return(true); }
public bool VisitParagraphCommand(ParagraphComment comment) { bool tag = false; foreach (var item in comment.Content.Where(c => c.Kind == DocumentationCommentKind.TextComment)) { TextComment com = (TextComment)item; if (Generators.Helpers.RegexTag.IsMatch(com.Text)) { tag = true; } else if (tag) { com.Text = com.Text.Substring(1); } if (com.Text.StartsWith("<", StringComparison.Ordinal)) { com.Text = $"{com.Text}{">"}"; } else if (com.Text.StartsWith(">", StringComparison.Ordinal)) { com.Text = com.Text.Substring(1); } } return(true); }
public static IEnumerable <InlineContentComment> GetContent(this ParagraphComment comment) { for (var x = 0; x < comment.ContentCount; x++) { var content = comment.getContent((uint)x); yield return(content); } }
public bool VisitParagraphCommand(ParagraphComment comment) { for (int i = 0; i < comment.Content.Count; i++) { if (comment.Content[i].Kind == DocumentationCommentKind.InlineCommandComment) { if (i + 1 < comment.Content.Count && comment.Content[i + 1].Kind == DocumentationCommentKind.TextComment) { TextComment com = (TextComment)comment.Content[i + 1]; com.Text = Helpers.RegexCommentCommandLeftover.Replace(com.Text, string.Empty); } } } bool tag = false; foreach (var item in comment.Content.Where(c => c.Kind == DocumentationCommentKind.TextComment)) { TextComment com = (TextComment)item; if (Helpers.RegexTag.IsMatch(com.Text)) { tag = true; } else if (tag) { com.Text = com.Text.Substring(1); } if (com.Text.StartsWith("<", StringComparison.Ordinal)) { com.Text = $"{com.Text}{">"}"; } else if (com.Text.StartsWith(">", StringComparison.Ordinal)) { com.Text = com.Text.Substring(1); } } return(true); }
protected ParagraphComment(ParagraphComment.Internal* native, bool isInternalImpl = false) : base((CppSharp.Parser.AST.BlockContentComment.Internal*) native) { }
private ParagraphComment(ParagraphComment.Internal native) : this(__CopyValue(native)) { __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; }
private static ParagraphComment.Internal* __CopyValue(ParagraphComment.Internal native) { var ret = Marshal.AllocHGlobal(32); CppSharp.Parser.AST.ParagraphComment.Internal.cctor_2(ret, new global::System.IntPtr(&native)); return (ParagraphComment.Internal*) ret; }
public static ParagraphComment __CreateInstance(ParagraphComment.Internal native) { return new ParagraphComment(native); }
protected ParagraphComment(ParagraphComment.Internal* native, bool skipVTables = false) : base((CppSharp.Parser.AST.BlockContentComment.Internal*) null) { __PointerAdjustment = 0; if (native == null) return; __Instance = new global::System.IntPtr(native); }
private ParagraphComment(ParagraphComment.Internal native, bool skipVTables = false) : this(__CopyValue(native), skipVTables) { __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; }
public static ParagraphComment __CreateInstance(ParagraphComment.Internal native, bool skipVTables = false) { return new ParagraphComment(native, skipVTables); }
private static void* __CopyValue(ParagraphComment.__Internal native) { var ret = Marshal.AllocHGlobal(20); global::CppSharp.Parser.AST.ParagraphComment.__Internal.cctor_1(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); }
public bool VisitParagraphCommand(ParagraphComment comment) { return(true); }
public override bool VisitDeclaration(Declaration declaration) { if (AlreadyVisited(declaration)) { return(false); } //if (declaration.TranslationUnit == null || !declaration.TranslationUnit.FileName.StartsWith("Chakra")) // return false; if (declaration.Comment != null) { var xDoc = GetOriginalDocumentationDocument(declaration.Comment.Text); var xRoot = xDoc.Root; declaration.Comment.Kind = CommentKind.BCPLSlash; var fullComment = declaration.Comment.FullComment; fullComment.Blocks.Clear(); var summaryPara = new ParagraphComment(); var summaryElement = xRoot.Element("summary"); summaryPara.Content.Add(new TextComment { Text = summaryElement == null ? "" : summaryElement.Value.ReplaceLineBreaks("").Trim() }); fullComment.Blocks.Add(summaryPara); var remarksElement = xRoot.Element("remarks"); if (remarksElement != null) { foreach (var remarksLine in remarksElement.Value.Split('\n')) { var remarksPara = new ParagraphComment(); remarksPara.Content.Add(new TextComment { Text = remarksLine.ReplaceLineBreaks("").Trim() }); fullComment.Blocks.Add(remarksPara); } } var paramElements = xRoot.Elements("param"); foreach (var paramElement in paramElements) { var paramComment = new ParamCommandComment(); paramComment.Arguments.Add(new BlockCommandComment.Argument { Text = paramElement.Attribute("name").Value }); paramComment.ParagraphComment = new ParagraphComment(); StringBuilder paramTextCommentBuilder = new StringBuilder(); foreach (var paramLine in paramElement.Value.Split('\n')) { paramTextCommentBuilder.Append(paramLine.ReplaceLineBreaks("").Trim() + " "); } paramComment.ParagraphComment.Content.Add(new TextComment { Text = paramTextCommentBuilder.ToString() }); fullComment.Blocks.Add(paramComment); } } //Fix Enum comments if (declaration is Enumeration enumDecl) { foreach (var item in enumDecl.Items.Where(i => i.Comment != null)) { item.Comment.BriefText = item.Comment.BriefText.Replace("<summary>", "").Replace("</summary>", "").Trim(); } } return(true); }
public void DocumentType(Class type) { var node = this.classNodes.Find( c => c.Attribute("location").Value == type.TranslationUnit.FileName && c.Attribute("name").Value == type.OriginalName); if (node != null) { var file = node.Attribute("href").Value; if (this.typesDocumentation.ContainsKey(file)) { var docs = this.typesDocumentation[file]; var briefText = StripTags(docs[0].InnerHtml); var text = StripTags(ConstructDocumentText(docs.Skip(1))); type.Comment = new RawComment { BriefText = briefText, // TODO: create links in the "See Also" section; in general, convert all links Text = text, FullComment = new FullComment() }; var paragraphComment = new ParagraphComment(); paragraphComment.Content.Add(new TextComment { Text = briefText }); paragraphComment.Content.AddRange(text.Split('\n').Select(t => new TextComment { Text = t })); type.Comment.FullComment.Blocks.Add(paragraphComment); } } }