@@ -22,7 +22,8 @@ A very simple Perl 6 Pod document
22
22
= head1 Block Structure
23
23
24
24
A Pod document may consist of multiple Pod blocks.
25
- There are three ways to define a block; all of which yield the same result.
25
+ There are four ways to define a block (delimited, paragraph, abbreviated, declarator);
26
+ the first three yield the same result but the fourth differs.
26
27
You can use whichever form is most convenient for your particular documentation task.
27
28
28
29
= head2 Delimited blocks
@@ -57,6 +58,42 @@ first blank line.
57
58
= head1 Top Level Heading
58
59
= end code
59
60
61
+ = head2 Declarator blocks
62
+
63
+ Declarator blocks differ from the others by not having a specific type,
64
+ instead they are attached to some source code.
65
+
66
+ Declarator blocks are introduced by a special comment: either C < #= > or C < #| > ,
67
+ which must be immediately followed by either a space or an opening bracket.
68
+ If followed by a space, the block is terminated by the end of line;
69
+ if followed by one or more opening brackets, the block is terminated by the matching
70
+ sequence of closing brackets.
71
+
72
+ Blocks starting with C < #| > are attached to the code after them,
73
+ and blocks starting with C < #= > are attached to the code before them.
74
+
75
+ Since declarator blocks are attached to source code, they can be used to document
76
+ classes, roles, subroutines etc.
77
+
78
+ The C < WHY > method can be used on these classes, roles, subroutines etc. to return the attached Pod value.
79
+
80
+ = begin code :skip-test
81
+ #| Base class for magicians
82
+ class Magician {
83
+ has Int $.level;
84
+ has Str @.spells;
85
+ }
86
+
87
+ #| Fight mecanics
88
+ sub duel(Magician $a, Magician $b) {
89
+ }
90
+ #= Magicians only, no mortals.
91
+
92
+ say Magician.WHY; # OUTPUT: «Base class for magicians»
93
+ say &duel.WHY.leading; # OUTPUT: «Fight mecanics»
94
+ say &duel.WHY.trailing; # OUTPUT: «Magicians only, no mortals.»
95
+ = end code
96
+
60
97
= head1 Block types
61
98
62
99
Pod offers a wide range of standard block types.
0 commit comments