|
| 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; |
0 commit comments