public virtual void GenerateComment(RawComment comment) { if (comment.FullComment != null) { PushBlock(BlockKind.BlockComment); WriteLine(comment.FullComment.CommentToString(DocumentationCommentKind)); PopBlock(); return; } if (string.IsNullOrWhiteSpace(comment.BriefText)) { return; } var lines = new List <string>(); if (comment.BriefText.Contains("\n")) { lines.Add("<summary>"); foreach (string line in HtmlEncoder.HtmlEncode(comment.BriefText).Split( Environment.NewLine.ToCharArray())) { lines.Add($"<para>{line}</para>"); } lines.Add("</summary>"); } else { lines.Add($"<summary>{comment.BriefText}</summary>"); } GenerateMultiLineComment(lines, CommentKind); }
private static void CombineComments(Property property) { Method getter = property.GetMethod; if (getter.Comment == null) { return; } var comment = new RawComment { Kind = getter.Comment.Kind, BriefText = getter.Comment.BriefText, Text = getter.Comment.Text }; if (getter.Comment.FullComment != null) { comment.FullComment = new FullComment(); comment.FullComment.Blocks.AddRange(getter.Comment.FullComment.Blocks); Method setter = property.SetMethod; if (getter != setter && setter?.Comment != null) { comment.BriefText += Environment.NewLine + setter.Comment.BriefText; comment.Text += Environment.NewLine + setter.Comment.Text; comment.FullComment.Blocks.AddRange(setter.Comment.FullComment.Blocks); } } property.Comment = comment; }
private static void GenerateProperty(DeclarationContext context, Method getter, Method setter = null) { Class type = (Class)context; if (type.Properties.All(p => getter.Name != p.Name || p.ExplicitInterfaceImpl != getter.ExplicitInterfaceImpl)) { Property property = new Property(); property.Name = GetPropertyName(getter.Name); property.Namespace = type; property.QualifiedType = getter.OriginalReturnType; if (getter.IsOverride || (setter != null && setter.IsOverride)) { Property baseVirtualProperty = type.GetRootBaseProperty(property); if (baseVirtualProperty.SetMethod == null) { setter = null; } } property.GetMethod = getter; property.SetMethod = setter; property.ExplicitInterfaceImpl = getter.ExplicitInterfaceImpl; if (property.ExplicitInterfaceImpl == null && setter != null) { property.ExplicitInterfaceImpl = setter.ExplicitInterfaceImpl; } if (getter.Comment != null) { var comment = new RawComment(); comment.Kind = getter.Comment.Kind; comment.BriefText = getter.Comment.BriefText; comment.Text = getter.Comment.Text; if (getter.Comment.FullComment != null) { comment.FullComment = new FullComment(); comment.FullComment.Blocks.AddRange(getter.Comment.FullComment.Blocks); if (setter != null && setter.Comment != null) { comment.BriefText += Environment.NewLine + setter.Comment.BriefText; comment.Text += Environment.NewLine + setter.Comment.Text; comment.FullComment.Blocks.AddRange(setter.Comment.FullComment.Blocks); } } property.Comment = comment; } type.Properties.Add(property); getter.GenerationKind = GenerationKind.Internal; if (setter != null) { setter.GenerationKind = GenerationKind.Internal; } } }
public override bool VisitProperty(Property property) { if (!base.VisitProperty(property) || property.TranslationUnit.IsSystemHeader) { return(false); } if (!property.IsSynthetized && property.IsGenerated) { foreach (var @class in from m in new[] { property.GetMethod, property.SetMethod } where m != null let @class = m.OriginalNamespace as Class where @class != null && @class.IsInterface select @class) { RawComment comment = null; if (property.GetMethod != null && functionsComments.ContainsKey(property.GetMethod.Mangled)) { comment = new RawComment { BriefText = functionsComments[property.GetMethod.Mangled] }; } if (comment == null && property.SetMethod != null && functionsComments.ContainsKey(property.SetMethod.Mangled)) { comment = new RawComment { BriefText = functionsComments[property.SetMethod.Mangled] }; } property.Comment = comment; if (property.Comment != null) { return(true); } } this.documentation.DocumentProperty(property); if (property.Comment != null) { if (property.GetMethod != null) { functionsComments[property.GetMethod.Mangled] = property.Comment.BriefText; } else { if (property.SetMethod != null) { functionsComments[property.SetMethod.Mangled] = property.Comment.BriefText; } } } return(true); } return(false); }
public void DocumentProperty(Property property) { var expansions = property.Namespace.PreprocessedEntities.OfType <MacroExpansion>(); var properties = expansions.Where(e => e.Text.Contains("Q_PROPERTY") || e.Text.Contains("QDOC_PROPERTY")); string alternativeName = property.Name.Length == 1 ? property.Name : "is" + StringHelpers.UppercaseFirst(property.Name); foreach (string name in from macroExpansion in properties let name = macroExpansion.Text.Split(new[] { ' ' })[1] where name == property.Name || name == alternativeName select name) { property.Name = name; this.DocumentQtProperty(property); return; } if (property.Field == null) { Method getter = property.GetMethod; if (getter.Comment == null) { this.DocumentFunction(getter); } var comment = new RawComment(); if (getter.Comment != null) { comment.BriefText = getter.Comment.BriefText; } Method setter = property.SetMethod; if (setter != null) { if (setter.Comment == null) { this.DocumentFunction(setter); } if (setter.Comment != null) { if (!string.IsNullOrEmpty(comment.BriefText)) { comment.BriefText += Environment.NewLine; } comment.BriefText += setter.Comment.BriefText; } } if (!string.IsNullOrEmpty(comment.BriefText)) { property.Comment = comment; } } }
public void GenerateInlineSummary(RawComment comment) { if (comment == null) { return; } if (String.IsNullOrWhiteSpace(comment.BriefText)) { return; } PushBlock(BlockKind.InlineComment); WriteLine("/// <summary> {0} </summary>", comment.BriefText); PopBlock(); }
AST.RawComment VisitRawComment(RawComment rawComment) { var _rawComment = new AST.RawComment { Kind = ConvertRawCommentKind(rawComment.RawCommentKind), BriefText = rawComment.BriefText, Text = rawComment.Text, }; if (rawComment.FullComment != null) { _rawComment.FullComment = commentConverter.Visit(rawComment.FullComment) as AST.FullComment; } return(_rawComment); }
private static RawComment CombineComments(Declaration getter, Declaration setter) { var comment = new RawComment { Kind = getter.Comment.Kind, BriefText = getter.Comment.BriefText, Text = getter.Comment.Text }; if (getter.Comment.FullComment != null) { comment.FullComment = new FullComment(); comment.FullComment.Blocks.AddRange(getter.Comment.FullComment.Blocks); if (setter != null && setter.Comment != null) { comment.BriefText += Environment.NewLine + setter.Comment.BriefText; comment.Text += Environment.NewLine + setter.Comment.Text; comment.FullComment.Blocks.AddRange(setter.Comment.FullComment.Blocks); } } return(comment); }
protected RawComment(RawComment.Internal* native, bool skipVTables = false) { if (native == null) return; __Instance = new global::System.IntPtr(native); }
public static RawComment __CreateInstance(RawComment.Internal native, bool skipVTables = false) { return new RawComment(native, skipVTables); }
private RawComment(RawComment.Internal native, bool skipVTables = false) : this(__CopyValue(native), skipVTables) { __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; }
private static void GenerateProperty(DeclarationContext context, Method getter, Method setter = null) { Class type = (Class) context; if (type.Properties.All(p => getter.Name != p.Name || p.ExplicitInterfaceImpl != getter.ExplicitInterfaceImpl)) { Property property = new Property(); property.Name = GetPropertyName(getter.Name); property.Namespace = type; property.QualifiedType = getter.OriginalReturnType; if (getter.IsOverride || (setter != null && setter.IsOverride)) { Property baseVirtualProperty = type.GetRootBaseProperty(property); if (baseVirtualProperty.SetMethod == null) setter = null; } property.GetMethod = getter; property.SetMethod = setter; property.ExplicitInterfaceImpl = getter.ExplicitInterfaceImpl; if (property.ExplicitInterfaceImpl == null && setter != null) { property.ExplicitInterfaceImpl = setter.ExplicitInterfaceImpl; } if (getter.Comment != null) { var comment = new RawComment(); comment.Kind = getter.Comment.Kind; comment.BriefText = getter.Comment.BriefText; comment.Text = getter.Comment.Text; comment.FullComment = new FullComment(); comment.FullComment.Blocks.AddRange(getter.Comment.FullComment.Blocks); if (setter != null && setter.Comment != null) { comment.BriefText += Environment.NewLine + setter.Comment.BriefText; comment.Text += Environment.NewLine + setter.Comment.Text; comment.FullComment.Blocks.AddRange(setter.Comment.FullComment.Blocks); } property.Comment = comment; } type.Properties.Add(property); getter.IsGenerated = false; if (setter != null) setter.IsGenerated = false; } }
private static void* __CopyValue(RawComment.__Internal native) { var ret = Marshal.AllocHGlobal(56); global::CppSharp.Parser.AST.RawComment.__Internal.cctor_1(ret, new global::System.IntPtr(&native)); return ret.ToPointer(); }
public async Task <IEnumerable <RawComment> > GatherData(int fromNewsId, int toNewsId) { var comments = new List <RawComment>(); var parser = new HtmlParser(); var client = new HttpClient(); for (var newsId = toNewsId; newsId >= fromNewsId; newsId--) { Console.Write($"{newsId} => "); var url = $"https://www.kaldata.com/category/news-{newsId}.html"; string htmlContent = null; for (var i = 0; i < 10; i++) { try { var response = await client.GetAsync(url); if (!response.Content.Headers.GetValues("Content-Type").Contains("text/html; charset=UTF-8")) { Console.WriteLine("Skip. Not HTML."); break; } htmlContent = await response.Content.ReadAsStringAsync(); break; } catch { Console.Write("!"); Thread.Sleep(500); } } if (htmlContent == null) { continue; } var document = await parser.ParseDocumentAsync(htmlContent); var commentSection = document.GetElementById("wcThreadWrapper"); if (commentSection == null) { Console.WriteLine("Skip. Comments section not found."); continue; } var htmlComments = commentSection.GetElementsByClassName("wc-comment-right"); foreach (var htmlComment in htmlComments) { var content = htmlComment.QuerySelector(".wc-comment-text")?.TextContent; var positiveVotes = int.Parse(htmlComment.QuerySelector(".wc-vote-result-like")?.TextContent); var downVotes = -int.Parse(htmlComment.QuerySelector(".wc-vote-result-dislike")?.TextContent); var createdOn = DateTime.ParseExact( htmlComment.QuerySelector(".wc-comment-date")?.TextContent, "dd.MM.yyyy, H:mm", CultureInfo.InvariantCulture); var comment = new RawComment { Content = content, UpVotes = positiveVotes, DownVotes = downVotes, NewsId = newsId, CreatedOn = createdOn, }; comments.Add(comment); } Console.WriteLine($"OK. {htmlComments.Length} comment(s)."); } return(comments); }
public void GenerateInlineSummary(RawComment comment) { if (comment == null) return; if (String.IsNullOrWhiteSpace(comment.BriefText)) return; PushBlock(BlockKind.InlineComment); WriteLine("/// <summary> {0} </summary>", comment.BriefText); PopBlock(); }
private static RawComment CombineComments(Declaration getter, Declaration setter) { var comment = new RawComment { Kind = getter.Comment.Kind, BriefText = getter.Comment.BriefText, Text = getter.Comment.Text }; if (getter.Comment.FullComment != null) { comment.FullComment = new FullComment(); comment.FullComment.Blocks.AddRange(getter.Comment.FullComment.Blocks); if (setter != null && setter.Comment != null) { comment.BriefText += Environment.NewLine + setter.Comment.BriefText; comment.Text += Environment.NewLine + setter.Comment.Text; comment.FullComment.Blocks.AddRange(setter.Comment.FullComment.Blocks); } } return comment; }
internal RawComment(RawComment.Internal native) : this(&native) { }
public static RawComment __CreateInstance(RawComment.Internal native) { return new RawComment(native); }
private RawComment(RawComment.Internal native) : this(__CopyValue(native)) { __ownsNativeInstance = true; NativeToManagedMap[__Instance] = this; }
public void DocumentProperty(Property property) { var expansions = property.Namespace.PreprocessedEntities.OfType<MacroExpansion>(); var properties = expansions.Where(e => e.Text.Contains("Q_PROPERTY") || e.Text.Contains("QDOC_PROPERTY")); string alternativeName = property.Name.Length == 1 ? property.Name : "is" + StringHelpers.UppercaseFirst(property.Name); foreach (var macroExpansion in properties) { var name = macroExpansion.Text.Split(' ')[1]; if (name == property.Name || name == alternativeName) { property.LineNumberStart = macroExpansion.LineNumberStart; property.LineNumberEnd = macroExpansion.LineNumberEnd; property.Name = name; this.DocumentQtProperty(property); return; } } if (property.Field == null) { var comment = new RawComment(); var getter = property.GetMethod; if (getter.Comment == null && getter.Namespace.OriginalName == property.Namespace.OriginalName) { this.DocumentFunction(getter); } if (getter.Comment != null) { comment.BriefText = getter.Comment.BriefText; } var setter = property.SetMethod; if (setter != null) { if (setter.Comment == null && setter.Namespace.OriginalName == property.Namespace.OriginalName) { this.DocumentFunction(setter); } if (setter.Comment != null) { if (property.IsOverride) { comment.BriefText = ((Class) property.Namespace).GetBaseProperty(property).Comment.BriefText; } if (!string.IsNullOrEmpty(comment.BriefText)) { comment.BriefText += Environment.NewLine; } comment.BriefText += setter.Comment.BriefText; } } if (!string.IsNullOrEmpty(comment.BriefText)) { property.Comment = comment; } } else { property.LineNumberStart = property.Field.LineNumberStart; property.LineNumberEnd = property.Field.LineNumberEnd; this.DocumentVariable(property); } }
public override bool VisitProperty(Property property) { if (!base.VisitProperty(property) || property.TranslationUnit.IsSystemHeader) { return false; } if (!property.IsSynthetized && property.IsGenerated) { foreach (var @class in from m in new[] { property.GetMethod, property.SetMethod } where m != null let @class = m.OriginalNamespace as Class where @class != null && @class.IsInterface select @class) { RawComment comment = null; if (property.GetMethod != null && functionsComments.ContainsKey(property.GetMethod.Mangled)) { comment = new RawComment { BriefText = functionsComments[property.GetMethod.Mangled] }; } if (comment == null && property.SetMethod != null && functionsComments.ContainsKey(property.SetMethod.Mangled)) { comment = new RawComment { BriefText = functionsComments[property.SetMethod.Mangled] }; } property.Comment = comment; if (property.Comment != null) { return true; } } this.documentation.DocumentProperty(property); if (property.Comment != null) { if (property.GetMethod != null) { functionsComments[property.GetMethod.Mangled] = property.Comment.BriefText; } else { if (property.SetMethod != null) { functionsComments[property.SetMethod.Mangled] = property.Comment.BriefText; } } } return true; } return false; }
public void DocumentProperty(Property property) { var expansions = property.Namespace.PreprocessedEntities.OfType <MacroExpansion>(); var properties = expansions.Where(e => e.Text.Contains("Q_PROPERTY") || e.Text.Contains("QDOC_PROPERTY")); string alternativeName = property.OriginalName.Length == 1 ? property.OriginalName : "is" + StringHelpers.Capitalize(property.OriginalName); foreach (var macroExpansion in properties) { var name = macroExpansion.Text.Split(' ')[1]; if (name == property.OriginalName || name == alternativeName) { property.OriginalName = name; this.DocumentQtProperty(property); return; } } if (property.Field == null) { var comment = new RawComment(); var getter = property.GetMethod; if (getter.Comment == null && getter.Namespace.OriginalName == property.Namespace.OriginalName) { this.DocumentFunction(getter); } if (getter.Comment != null) { comment.BriefText = getter.Comment.BriefText; } var setter = property.SetMethod; if (setter != null) { if (setter.Comment == null && setter.Namespace.OriginalName == property.Namespace.OriginalName) { this.DocumentFunction(setter); } if (setter.Comment != null) { if (property.IsOverride) { Property baseProperty = ((Class)property.Namespace).GetBaseProperty(property); if (baseProperty.Comment != null) { comment.BriefText = baseProperty.Comment.BriefText; } } if (string.IsNullOrEmpty(comment.BriefText)) { comment.BriefText += setter.Comment.BriefText; } else { comment.BriefText += Environment.NewLine + setter.Comment.BriefText; } } } if (!string.IsNullOrEmpty(comment.BriefText)) { property.Comment = comment; } } else { property.LineNumberStart = property.Field.LineNumberStart; property.LineNumberEnd = property.Field.LineNumberEnd; this.DocumentVariable(property); } }
public async Task <IEnumerable <RawComment> > GatherData(int fromNewsId, int toNewsId) { var comments = new List <RawComment>(); var parser = new HtmlParser(); var client = new HttpClient(); for (var newsId = 415500; newsId >= 1; newsId--) { Console.Write($"{newsId} => "); for (var page = 1; page <= 1000; page++) { Console.Write('^'); var url = $"https://www.dnes.bg/category/2010/01/01/news.{newsId},{page}"; string htmlContent = null; for (var i = 0; i < 10; i++) { try { var response = await client.GetAsync(url); htmlContent = await response.Content.ReadAsStringAsync(); break; } catch { Console.Write('!'); Thread.Sleep(500); } } if (string.IsNullOrWhiteSpace(htmlContent)) { break; } var document = await parser.ParseDocumentAsync(htmlContent); var commentSection = document.GetElementById("comments-cont"); if (commentSection == null) { Console.Write("Skip. Comments section not found."); break; } var htmlComments = commentSection.GetElementsByClassName("comment-box"); if (htmlComments.Length == 0) { break; } foreach (var htmlComment in htmlComments) { var contentElement = htmlComment.QuerySelector(".comment_text"); if (contentElement == null) { continue; } var divToRemove = contentElement.QuerySelector(".feedback_comment"); contentElement.RemoveChild(divToRemove); var positiveVotes = int.Parse(htmlComment.QuerySelector(".comments-grades-up")?.TextContent); var downVotes = int.Parse(htmlComment.QuerySelector(".comments-grades-down")?.TextContent); var comment = new RawComment { Content = contentElement.TextContent.Trim(), UpVotes = positiveVotes, DownVotes = downVotes, NewsId = newsId, }; comments.Add(comment); } } Console.WriteLine($"OK. {comments.Count} total comment(s)."); } return(comments); }
public void DocumentProperty(Property property) { var expansions = property.Namespace.PreprocessedEntities.OfType<MacroExpansion>(); var properties = expansions.Where(e => e.Text.Contains("Q_PROPERTY") || e.Text.Contains("QDOC_PROPERTY")); string alternativeName = property.Name.Length == 1 ? property.Name : "is" + StringHelpers.UppercaseFirst(property.Name); foreach (string name in from macroExpansion in properties let name = macroExpansion.Text.Split(new[] { ' ' })[1] where name == property.Name || name == alternativeName select name) { property.Name = name; this.DocumentQtProperty(property); return; } if (property.Field == null) { Method getter = property.GetMethod; if (getter.Comment == null) { this.DocumentFunction(getter); } var comment = new RawComment(); if (getter.Comment != null) { comment.BriefText = getter.Comment.BriefText; } Method setter = property.SetMethod; if (setter != null) { if (setter.Comment == null) { this.DocumentFunction(setter); } if (setter.Comment != null) { if (!string.IsNullOrEmpty(comment.BriefText)) { comment.BriefText += Environment.NewLine; } comment.BriefText += setter.Comment.BriefText; } } if (!string.IsNullOrEmpty(comment.BriefText)) { property.Comment = comment; } } }
public virtual void GenerateInlineSummary(RawComment comment) { GenerateComment(comment); }
internal RawComment(RawComment.Internal native) : this(__CopyValue(native)) { }
private static RawComment.Internal* __CopyValue(RawComment.Internal native) { var ret = Marshal.AllocHGlobal(64); CppSharp.Parser.AST.RawComment.Internal.cctor_2(ret, new global::System.IntPtr(&native)); return (RawComment.Internal*) ret; }
private RawComment(RawComment.Internal native) : this(__CopyValue(native)) { __ownsNativeInstance = true; }
protected RawComment(RawComment.Internal* native, bool isInternalImpl = false) { __Instance = new global::System.IntPtr(native); }
internal RawComment(RawComment.Internal* native) : this(new global::System.IntPtr(native)) { }