Skip to content

Commit a431db6

Browse files
committed
Fix extracting of documentation for the package...
... when code block after the 'is' keyword is separated by an empty line from the line with 'is' keyword but not separated by an empty line from the entity declaration below it is processed as documentation of the entity and not documentation of the package.
1 parent 1644557 commit a431db6

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

source/gnatdoc-comments-extractor.adb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,12 @@ package body GNATdoc.Comments.Extractor is
656656
Documentation.Sections.Append (Intermediate_Upper_Section);
657657

658658
declare
659-
Token : Token_Reference := Base_Package_Decl_Node.Token_Start;
660-
Found : Boolean := False;
659+
Token : Token_Reference := Base_Package_Decl_Node.Token_Start;
660+
Found : Boolean := False;
661+
Separated : Boolean := False;
662+
-- Whether comment block is separated from the list with 'is'
663+
-- keyword by empty line. In this case comment block can belong
664+
-- to the entity declaration below.
661665

662666
begin
663667
-- Lookup 'is' in the package declaration
@@ -691,11 +695,21 @@ package body GNATdoc.Comments.Extractor is
691695
if Location.End_Line - Location.Start_Line > 1 then
692696
exit when Found;
693697

694-
Found := True;
698+
Found := True;
699+
Separated := True;
695700
end if;
696701
end;
697702

698703
when others =>
704+
if Separated then
705+
-- Comment block is separated from the line with 'is'
706+
-- keyword by an empty line, but not separated from the
707+
-- entity declaration below, thus don't include it into
708+
-- package documentation.
709+
710+
Intermediate_Upper_Section.Text.Clear;
711+
end if;
712+
699713
exit;
700714
end case;
701715
end loop;

0 commit comments

Comments
 (0)