Skip to content

Commit

Permalink
Merge branch 'cherry-pick-3b9ae04e' into '25.0'
Browse files Browse the repository at this point in the history
Merge branch 'topic/vadim/version' into 'master'

See merge request eng/ide/gnatdoc!133
  • Loading branch information
godunko committed Oct 4, 2024
2 parents 8faf739 + 5e44621 commit 510bd42
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ SCENARIO_VARIABLES=-XGPR_UNIT_PROVIDER_LIBRARY_TYPE=static -XGPR_UNIT_PROVIDER_B

all: build-gnatdoc

build-all: build-libgnatdoc build-gnatdoc build-tests

build-libgnatdoc:
gprbuild -j0 -p -P gnat/libgnatdoc.gpr

Expand All @@ -14,8 +16,6 @@ build-gnatdoc:
clean:
rm -rf .objs bin

build_tests: build-tests # for compatibility with ANOD specs

build-tests:
gprbuild -j0 -p -P gnat/tests/test_drivers.gpr ${SCENARIO_VARIABLES}

Expand Down
24 changes: 24 additions & 0 deletions source/gnatdoc/gnatdoc-command_line.adb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ with VSS.Strings.Conversions;

with GNATdoc.Comments.Options;
with GNATdoc.Options;
with GNATdoc.Version;

with GPR2.Options;
with GPR2.Project.Registry.Exchange;
with VSS.Strings.Formatters;
with VSS.Strings.Formatters.Strings;
with VSS.Strings.Templates;

package body GNATdoc.Command_Line is

Expand All @@ -32,6 +36,11 @@ package body GNATdoc.Command_Line is
Long_Name => "help",
Description => "Display help information");

Version_Option : constant VSS.Command_Line.Binary_Option :=
(Short_Name => <>,
Long_Name => "version",
Description => "Display the program version");

Backend_Option : constant VSS.Command_Line.Value_Option :=
(Short_Name => <>,
Long_Name => "backend",
Expand Down Expand Up @@ -121,6 +130,7 @@ package body GNATdoc.Command_Line is
procedure Initialize is
begin
Parser.Add_Option (Help_Option);
Parser.Add_Option (Version_Option);
Parser.Add_Option (Print_Gpr_Registry_Option);
Parser.Add_Option (Style_Option);
Parser.Add_Option (Backend_Option);
Expand Down Expand Up @@ -173,6 +183,20 @@ package body GNATdoc.Command_Line is
VSS.Command_Line.Report_Message (Parser.Help_Text);
end if;

if Parser.Is_Specified (Version_Option) then
declare
Template : constant
VSS.Strings.Templates.Virtual_String_Template :=
"GNATdoc {}";

begin
VSS.Command_Line.Report_Error
(Template.Format
(VSS.Strings.Formatters.Strings.Image
(GNATdoc.Version.Version_String)));
end;
end if;

-- Process `--print-gpr-registry` if specified

if Parser.Is_Specified (Print_Gpr_Registry_Option) then
Expand Down
23 changes: 23 additions & 0 deletions source/gnatdoc/gnatdoc-version.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
------------------------------------------------------------------------------
-- GNAT Documentation Generation Tool --
-- --
-- Copyright (C) 2024, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
------------------------------------------------------------------------------

package GNATdoc.Version is

Version_String : VSS.Strings.Virtual_String :=
"%VERSION% (%DATE%)";

end GNATdoc.Version;

0 comments on commit 510bd42

Please sign in to comment.