Skip to content

Commit 509e652

Browse files
committed
Merge branch 'topic/vadim/example' into 'master'
Features example See merge request eng/ide/gnatdoc!182
2 parents af62729 + 64f9863 commit 509e652

File tree

7 files changed

+227
-0
lines changed

7 files changed

+227
-0
lines changed

examples/features/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
GNATDOC=gnatdoc
3+
#GNATDOC_FLAGS=--style=leading
4+
GNATDOC_FLAGS=--style=gnat
5+
6+
all: clean
7+
$(GNATDOC) $(GNATDOC_FLAGS) default.gpr
8+
$(GNATDOC) $(GNATDOC_FLAGS) default.gpr --backend=odf
9+
$(GNATDOC) $(GNATDOC_FLAGS) default.gpr --backend=rst
10+
11+
clean:
12+
rm -rf docs html odf

examples/features/default.gpr

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
project Default is
3+
for Object_Dir use ".objs";
4+
5+
package Documentation is
6+
for Output_Dir ("html") use "html";
7+
for Image_Dirs ("html") use ("images");
8+
9+
for Output_Dir ("odf") use "odf";
10+
for Image_Dirs ("odf") use ("images");
11+
12+
for Output_Dir ("rst") use "rst";
13+
for Image_Dirs ("rst") use ("images");
14+
15+
-- for Output_Dir (others) use "docs";
16+
-- for Image_Dirs (others) use "images";
17+
-- `others` can be used to set attributes for all backends, but it is
18+
-- not supported by some tools yet.
19+
end Documentation;
20+
end Default;
606 Bytes
Loading
1.34 KB
Loading

examples/features/markdown.ads

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
-- GNATdoc understands a markup language based on
3+
-- [CommonMark](https://commonmark.org/), which can be used to format
4+
-- elements in the generated documentation.
5+
--
6+
-- The following features are supported:
7+
-- * paragraphs
8+
-- * ordered and unordered lists
9+
-- * indented code blocks
10+
-- * inline formatting, including **strong emphasis** (**bold text**),
11+
-- *emphasis* (*italicized text*), and `code spans` (`monospace text`)
12+
-- * images
13+
--
14+
-- To have a block recognized as code, indent it with at least three spaces:
15+
--
16+
-- with Ada.Text_IO;
17+
--
18+
-- procedure Hello_World is
19+
-- begin
20+
-- Ada.Text_IO.Put_Line ("Hello, worlds!");
21+
-- end Hello_World;
22+
--
23+
-- Some backends require the size of images to be specified. When an image is
24+
-- declared without a size, the image might be invisible or shown with the
25+
-- wrong size, like this one ![Ada Inside](ada_logo_32x32.png). GNATdoc
26+
-- supports the following syntax to provide an image size. This guarantees
27+
-- this image will be represented properly on all backends
28+
-- ![Ada Inside](ada_logo_64x64.png){width=14pt height=14pt}.
29+
30+
package Markdown is
31+
32+
end Markdown;
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
2+
-- GNATdoc supports two styles of locations for documentation comments
3+
-- * leading: the documentation comments are placed before entities
4+
-- * GNAT (trailing): the documentation comments are placed after the
5+
-- entities
6+
--
7+
-- In all styles, documentation comments must not be separated from the entity
8+
-- declaration by an empty line.
9+
--
10+
-- This package shows how comments should be written when the GNAT (trailing)
11+
-- style is used.
12+
--
13+
-- The documentation for composite entities should contain the documentation
14+
-- for the entity, and the documentation for elements composing the entity.
15+
--
16+
-- The documentation for an entity should have same indentation as the
17+
-- entity declaration. Any comments with deeper indentation are processed as
18+
-- documentation of elements composing the entity.
19+
--
20+
-- These elements can be documented in few ways:
21+
-- * a comment on the line of the element's identifier - in this case,
22+
-- comments on the following lines are considered as continuation of the
23+
-- documentation
24+
-- * a comment on the line immediately below the element's declaration, in
25+
-- which case comments on the following lines are considered as
26+
-- continuation of the documentation
27+
-- * using the corresponding GNATdoc tags in the documentation of the entity
28+
-- itself
29+
--
30+
-- All comments preceding a declaration are considered part of the documentation,
31+
-- stopping at the first blank or non-comment line.
32+
33+
package Style_GNAT_Composite is
34+
35+
type Enumeration_Type is
36+
(Item_1, -- Enumeration literal's description at the declaration line
37+
Item_2,
38+
-- Enumeration literal's description below declaration line
39+
Item_3);
40+
-- Enumeration type has description of the type and description of
41+
-- individual enumeration literals.
42+
--
43+
-- @enum Item_3 Enumeration literal's description using GNATdoc's tag in
44+
-- the documentation of the enumeration type.
45+
46+
type Record_Type is record
47+
Component_1 : Integer; -- Record component's description at the
48+
-- declaration line.
49+
Component_2 : Integer;
50+
-- Record component's description below the line of declaration.
51+
Component_3 : Integer;
52+
end record;
53+
-- Record type has description of the type and description of individual
54+
-- components.
55+
--
56+
-- @field Component_3 Record component's description using GNATdoc's tag in
57+
-- the documentation of the record type.
58+
59+
procedure Do_Something
60+
(X : Integer; -- Subprogram parameter's description at the line of
61+
-- declration.
62+
Y : Integer;
63+
-- Subprogram parameter's description below declaration line
64+
Z : Integer);
65+
-- All subprograms, including procedures, has description of the subprogram,
66+
-- description of parameters, and description of raised exceptions.
67+
--
68+
-- @param Z Subprogram parameter's description using GNATdoc's tag in the
69+
-- documentation of the subprogram.
70+
-- @exception Constraint_Error Description of conditions when an exception
71+
-- can be raised by the subprogram.
72+
73+
function Compute_Something_1 (X : Integer) return Integer;
74+
-- In addition to procedures, function has description of the return
75+
-- value.
76+
--
77+
-- @return Description of return value of the function with GNATdoc's tag.
78+
79+
function Compute_Something_2
80+
return Integer; -- Description of the return value at the line of
81+
-- `return`.
82+
-- Just another way to describe return value.
83+
84+
end Style_GNAT_Composite;
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
2+
-- GNATdoc supports two styles of locations for documentation comments
3+
-- * leading: the documentation comments are placed before entities
4+
-- * GNAT (trailing): the documentation comments are placed after the
5+
-- entities
6+
--
7+
-- In all styles, documentation comments must not be separated from the entity
8+
-- declaration by an empty line.
9+
--
10+
-- This package shows how comments should be written when the leading style
11+
-- is used.
12+
--
13+
-- The documentation for composite entities should contain the documentation
14+
-- for the entity, and the documentation for elements composing the entity.
15+
--
16+
-- The documentation for an entity should have same indentation as the
17+
-- entity declaration. Any comments with deeper indentation are processed as
18+
-- documentation of elements composing the entity.
19+
--
20+
-- These elements can be documented in few ways:
21+
-- * a comment on the line of the element's identifier
22+
-- * a comment on the line immediately below the element's declaration, in
23+
-- which case comments on the following lines are considered as
24+
-- continuation of the documentation
25+
-- * using the corresponding GNATdoc tags in the documentation of the entity
26+
-- itself
27+
--
28+
-- All comments preceding a declaration are considered part of the
29+
-- documentation, stopping at the first blank or non-comment line.
30+
31+
package Style_Leading_Composite is
32+
33+
-- Enumeration type has description of the type and description of
34+
-- individual enumeration literals.
35+
--
36+
-- @enum Item_3 Enumeration literal's description using GNATdoc's tag in
37+
-- the documentation of the enumeration type.
38+
type Enumeration_Type is
39+
(Item_1, -- Enumeration literal's description at the declaration line
40+
-- Enumeration literal's description below declaration line
41+
Item_2,
42+
Item_3);
43+
44+
-- Record type has description of the type and description of individual
45+
-- components.
46+
--
47+
-- @field Component_3 Record component's description using GNATdoc's tag in
48+
-- the documentation of the record type.
49+
type Record_Type is record
50+
Component_1 : Integer; -- Record component's description.
51+
-- Record component's description below the line of declaration.
52+
Component_2 : Integer;
53+
Component_3 : Integer;
54+
end record;
55+
56+
-- All subprograms, including procedures, has description of the subprogram,
57+
-- description of parameters, and description of raised exceptions.
58+
--
59+
-- @param Z Subprogram parameter's description using GNATdoc's tag in the
60+
-- documentation of the subprogram.
61+
-- @exception Constraint_Error Description of conditions when an exception
62+
-- can be raised by the subprogram.
63+
procedure Do_Something
64+
(X : Integer; -- Subprogram parameter's description at the line.
65+
-- Subprogram parameter's description below declaration line.
66+
Y : Integer;
67+
Z : Integer);
68+
69+
-- In addition to procedures, function has description of the return
70+
-- value.
71+
--
72+
-- @return Description of return value of the function with GNATdoc's tag.
73+
function Compute_Something_1 (X : Integer) return Integer;
74+
75+
-- Just another way to describe return value.
76+
function Compute_Something_2
77+
return Integer; -- Description of the return value at the line of return.
78+
79+
end Style_Leading_Composite;

0 commit comments

Comments
 (0)