Skip to content

Commit b8eb9cc

Browse files
committed
Merge branch 'topic/warnings' into 'master'
Report undocumented entities Closes #17 See merge request eng/ide/gnatdoc!36
2 parents 79cfa3c + 9fdbcf1 commit b8eb9cc

17 files changed

+1235
-35
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ check_extractor:
1919
(cd testsuite/extractor && ../../.objs/test_extractor gnat.json tasks.ads | diff -u --strip-trailing-cr tasks.out -)
2020
(cd testsuite/extractor && ../../.objs/test_extractor gnat.json protecteds.ads | diff -u --strip-trailing-cr protecteds.ads.out -)
2121
(cd testsuite/extractor && ../../.objs/test_extractor gnat.json protecteds.adb | diff -u --strip-trailing-cr protecteds.adb.out -)
22+
(cd testsuite/extractor && ../../.objs/test_extractor gnat.json subprograms_gnat.ads | diff -u --strip-trailing-cr subprograms_gnat.ads.out -)
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
------------------------------------------------------------------------------
2+
-- GNAT Documentation Generation Tool --
3+
-- --
4+
-- Copyright (C) 2023, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it under --
7+
-- terms of the GNU General Public License as published by the Free Soft- --
8+
-- ware Foundation; either version 3, or (at your option) any later ver- --
9+
-- sion. This software is distributed in the hope that it will be useful, --
10+
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11+
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
12+
-- License for more details. You should have received a copy of the GNU --
13+
-- General Public License distributed with this software; see file --
14+
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
15+
-- of the license. --
16+
------------------------------------------------------------------------------
17+
18+
with GNATdoc.Messages;
19+
20+
package body GNATdoc.Comments.Undocumented_Checker is
21+
22+
------------------------
23+
-- Check_Undocumented --
24+
------------------------
25+
26+
procedure Check_Undocumented
27+
(Location : GNATdoc.Entities.Entity_Location;
28+
Name : VSS.Strings.Virtual_String;
29+
Documentation : GNATdoc.Comments.Structured_Comment)
30+
is
31+
use type VSS.Strings.Virtual_String;
32+
33+
begin
34+
for Section of Documentation.Sections loop
35+
if Section.Kind in Description then
36+
if Section.Text.Is_Empty then
37+
GNATdoc.Messages.Report_Warning
38+
(Location, "entity " & Name & " is not documented");
39+
end if;
40+
41+
exit;
42+
end if;
43+
end loop;
44+
45+
for Section of Documentation.Sections loop
46+
if Section.Kind in Component
47+
and then Section.Text.Is_Empty
48+
then
49+
GNATdoc.Messages.Report_Warning
50+
(Location,
51+
VSS.Strings.To_Virtual_String
52+
(case Section.Kind is
53+
when Formal => "generic formal",
54+
when Enumeration_Literal => "enumeration literal",
55+
when Field => "component",
56+
when Parameter => "parameter",
57+
when Returns => "return value",
58+
when Raised_Exception => "raised exception",
59+
when others => raise Program_Error)
60+
& (if Section.Kind /= Returns
61+
then " " & Section.Name else "")
62+
& VSS.Strings.To_Virtual_String (" is not documented"));
63+
end if;
64+
end loop;
65+
end Check_Undocumented;
66+
67+
end GNATdoc.Comments.Undocumented_Checker;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
------------------------------------------------------------------------------
2+
-- GNAT Documentation Generation Tool --
3+
-- --
4+
-- Copyright (C) 2023, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it under --
7+
-- terms of the GNU General Public License as published by the Free Soft- --
8+
-- ware Foundation; either version 3, or (at your option) any later ver- --
9+
-- sion. This software is distributed in the hope that it will be useful, --
10+
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
11+
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
12+
-- License for more details. You should have received a copy of the GNU --
13+
-- General Public License distributed with this software; see file --
14+
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
15+
-- of the license. --
16+
------------------------------------------------------------------------------
17+
18+
with VSS.Strings;
19+
20+
with GNATdoc.Entities;
21+
22+
package GNATdoc.Comments.Undocumented_Checker is
23+
24+
procedure Check_Undocumented
25+
(Location : GNATdoc.Entities.Entity_Location;
26+
Name : VSS.Strings.Virtual_String;
27+
Documentation : GNATdoc.Comments.Structured_Comment);
28+
-- Check presense of the documentation for all components and report
29+
-- warnings when necessary.
30+
31+
end GNATdoc.Comments.Undocumented_Checker;

source/frontend/gnatdoc-entities.ads

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- GNAT Documentation Generation Tool --
33
-- --
4-
-- Copyright (C) 2022, AdaCore --
4+
-- Copyright (C) 2022-2023, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -24,6 +24,12 @@ with GNATdoc.Comments;
2424

2525
package GNATdoc.Entities is
2626

27+
type Entity_Location is record
28+
File : VSS.Strings.Virtual_String;
29+
Line : VSS.Strings.Line_Count := 0;
30+
Column : VSS.Strings.Character_Count := 0;
31+
end record;
32+
2733
type Entity_Information;
2834

2935
type Entity_Information_Access is access all Entity_Information;
@@ -43,6 +49,7 @@ package GNATdoc.Entities is
4349
VSS.Strings."=");
4450

4551
type Entity_Information is record
52+
Location : Entity_Location;
4653
Name : VSS.Strings.Virtual_String;
4754
Qualified_Name : VSS.Strings.Virtual_String;
4855
Signature : VSS.Strings.Virtual_String;

0 commit comments

Comments
 (0)