|
15 | 15 | -- of the license. -- |
16 | 16 | ------------------------------------------------------------------------------ |
17 | 17 |
|
18 | | -with VSS.Strings; use VSS.Strings; |
19 | | -with VSS.Strings.Conversions; use VSS.Strings.Conversions; |
| 18 | +with VSS.Strings; use VSS.Strings; |
| 19 | +with VSS.Strings.Conversions; use VSS.Strings.Conversions; |
20 | 20 |
|
21 | | -with Langkit_Support.Slocs; use Langkit_Support.Slocs; |
22 | | -with Langkit_Support.Text; use Langkit_Support.Text; |
23 | | -with Libadalang.Analysis; use Libadalang.Analysis; |
24 | | -with Libadalang.Common; use Libadalang.Common; |
| 21 | +with Langkit_Support.Slocs; use Langkit_Support.Slocs; |
| 22 | +with Langkit_Support.Text; use Langkit_Support.Text; |
| 23 | +with Libadalang.Analysis; use Libadalang.Analysis; |
| 24 | +with Libadalang.Common; use Libadalang.Common; |
| 25 | + |
| 26 | +with GNATdoc.Comments.Utilities; use GNATdoc.Comments.Utilities; |
25 | 27 |
|
26 | 28 | package body GNATdoc.Comments.Builders is |
27 | 29 |
|
28 | 30 | use all type GNATdoc.Comments.Options.Documentation_Style; |
29 | 31 |
|
| 32 | + ----------------------------- |
| 33 | + -- Fill_Structured_Comment -- |
| 34 | + ----------------------------- |
| 35 | + |
| 36 | + procedure Fill_Structured_Comment |
| 37 | + (Self : in out Abstract_Components_Builder'Class; |
| 38 | + Node : Basic_Decl'Class; |
| 39 | + Pattern : VSS.Regular_Expressions.Regular_Expression) |
| 40 | + is |
| 41 | + Node_Location : constant Source_Location_Range := Node.Sloc_Range; |
| 42 | + Location : Source_Location_Range; |
| 43 | + |
| 44 | + begin |
| 45 | + -- Extract comments inside the declaration and fill text of raw, |
| 46 | + -- parameters, returns, and literals sections. |
| 47 | + |
| 48 | + declare |
| 49 | + Token : Token_Reference := Node.Token_Start; |
| 50 | + |
| 51 | + begin |
| 52 | + while Token /= No_Token and Token /= Node.Token_End loop |
| 53 | + Location := Sloc_Range (Data (Token)); |
| 54 | + |
| 55 | + if Kind (Data (Token)) = Ada_Comment then |
| 56 | + for Section of Self.Documentation.Sections loop |
| 57 | + if Section.Kind |
| 58 | + in Raw | Enumeration_Literal | Field |
| 59 | + | Parameter | Returns | Formal |
| 60 | + and then |
| 61 | + (Location.Start_Line |
| 62 | + in Section.Exact_Start_Line |
| 63 | + .. Section.Exact_End_Line |
| 64 | + or Location.Start_Line |
| 65 | + in Section.Group_Start_Line |
| 66 | + .. Section.Group_End_Line) |
| 67 | + |
| 68 | + then |
| 69 | + if Self.Advanced_Groups |
| 70 | + and Location.Start_Line = Section.Group_Start_Line |
| 71 | + and not Section.Text.Is_Empty |
| 72 | + then |
| 73 | + Section.Text.Append (Empty_Virtual_String); |
| 74 | + end if; |
| 75 | + |
| 76 | + Append_Documentation_Line |
| 77 | + (Section.Text, Text (Token), Pattern); |
| 78 | + end if; |
| 79 | + end loop; |
| 80 | + end if; |
| 81 | + |
| 82 | + Token := Next (Token); |
| 83 | + end loop; |
| 84 | + end; |
| 85 | + end Fill_Structured_Comment; |
| 86 | + |
30 | 87 | ---------------- |
31 | 88 | -- Initialize -- |
32 | 89 | ---------------- |
|
0 commit comments