Skip to content

Commit fbe8525

Browse files
committed
This commit adds new pod config option: 'signature', and adapts current type documentation to it's usage instead of brackets addition.
See #794 (comment)
1 parent 5c1a6f0 commit fbe8525

File tree

18 files changed

+348
-122
lines changed

18 files changed

+348
-122
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ To export examples from all .pod6-files use `make extract-examples`. To run
9797
individual tests pick the right .p6-file from `examples/` as a parameter to
9898
`perl6`.
9999

100+
### Signatures
101+
102+
Signatures are part of actual code and need to be tested too. But without the body every
103+
signature will cause an error during the test. Use the pod-config option `signature` to
104+
automatically add an empty body.
105+
106+
=begin code :signature
107+
method new(*@codes)
108+
=end code
109+
100110
### Skipping tests
101111

102112
Some examples fail with compile time exceptions and would interrupt the test

doc/Type/Any.pod6

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ List or a list-like type.
2020
2121
Defined as:
2222
23-
multi method ACCEPTS(Any:D: Mu $other) {}
23+
=begin code :signature
24+
multi method ACCEPTS(Any:D: Mu $other)
25+
=end code
2426
2527
Usage:
2628
@@ -36,7 +38,9 @@ Many built-in types override this for more specific comparisons
3638
3739
Defined as:
3840
39-
method any() returns Junction:D {}
41+
=begin code :signature
42+
method any() returns Junction:D
43+
=end code
4044
4145
Usage:
4246
@@ -54,7 +58,9 @@ C<any>-L<Junction|/type/Junction> from it.
5458
5559
Defined as:
5660
57-
method all() returns Junction:D {}
61+
=begin code :signature
62+
method all() returns Junction:D
63+
=end code
5864
5965
Usage:
6066
@@ -72,7 +78,9 @@ C<all>-L<Junction|/type/Junction> from it.
7278
7379
Defined as:
7480
75-
method one() returns Junction:D {}
81+
=begin code :signature
82+
method one() returns Junction:D
83+
=end code
7684
7785
Usage:
7886
@@ -90,7 +98,9 @@ C<one>-L<Junction|/type/Junction> from it.
9098
9199
Defined as:
92100
93-
method none() returns Junction:D {}
101+
=begin code :signature
102+
method none() returns Junction:D
103+
=end code
94104
95105
Usage:
96106
@@ -127,8 +137,10 @@ into the newly created Array.
127137
128138
Defined as:
129139
130-
multi sub reverse(*@list ) returns List:D {}
131-
multi method reverse(List:D:) returns List:D {}
140+
=begin code :signature
141+
multi sub reverse(*@list ) returns List:D
142+
multi method reverse(List:D:) returns List:D
143+
=end code
132144
133145
Usage:
134146
@@ -163,8 +175,10 @@ Examples:
163175
Defined as:
164176
165177
proto method map(|) is nodal { * }
166-
multi method map(\SELF: &block;; :$label, :$item) {}
167-
multi method map(HyperIterable:D: &block;; :$label) {}
178+
=begin code :signature
179+
multi method map(\SELF: &block;; :$label, :$item)
180+
multi method map(HyperIterable:D: &block;; :$label)
181+
=end code
168182
169183
C<map> will iterate over the invocant and apply the number of positional
170184
parameters of the code object from the invocant per call. The returned values
@@ -174,7 +188,9 @@ of the code object will become elements of the returned C<Seq>.
174188
175189
Defined as:
176190
177-
method deepmap(&block -->List) is nodal {}
191+
=begin code :signature
192+
method deepmap(&block -->List) is nodal
193+
=end code
178194
179195
C<deepmap> will apply C<&block> to each element and return a new C<List> with
180196
the return values of C<&block>, unless the element does the C<Iterable> role.
@@ -187,7 +203,9 @@ For those elements C<deepmap> will descend recursively into the sublist.
187203
188204
Defined as:
189205
190-
method duckmap(&block) is rw is nodal {}
206+
=begin code :signature
207+
method duckmap(&block) is rw is nodal
208+
=end code
191209
192210
C<duckmap> will apply C<&block> on each element and return a new list with
193211
defined return values of the block. For undefined return values, C<duckmap>
@@ -246,7 +264,9 @@ Interprets the invocant as a list, and returns the last index of that list.
246264
247265
=head2 method pairup
248266
249-
method pairup() returns List {}
267+
=begin code :signature
268+
method pairup() returns List
269+
=end code
250270
251271
Interprets the invocant as a list, and constructs a list of
252272
L<pairs|/type/Pair> from it, in the same way that assignment to a
@@ -259,7 +279,9 @@ list item, if any, is considered to be a key again).
259279
260280
=head2 sub exit
261281
262-
sub exit(Int() $status = 0) {}
282+
=begin code :signature
283+
sub exit(Int() $status = 0)
284+
=end code
263285
264286
Exits the current process with return code C<$status>.
265287

doc/Type/Array.pod6

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ scalar containers, which means you can assign to array elements.
1515
1616
Defined as:
1717
18-
multi sub pop(Array:D ) {}
19-
multi method pop(Array:D:) {}
18+
=begin code :signature
19+
multi sub pop(Array:D )
20+
multi method pop(Array:D:)
21+
=end code
2022
2123
Usage:
2224
@@ -40,8 +42,10 @@ Example:
4042
4143
Defined as:
4244
43-
multi sub push(Array:D, **@values) returns Array:D {}
44-
multi method push(Array:D: **@values) returns Array:D {}
45+
=begin code :signature
46+
multi sub push(Array:D, **@values) returns Array:D
47+
multi method push(Array:D: **@values) returns Array:D
48+
=end code
4549
4650
Usage:
4751
@@ -88,8 +92,11 @@ Defined as
8892
=begin code :skip-test
8993
sub append(\array, elems)
9094
=end code
91-
multi method append(Array:D: \values) {}
92-
multi method append(Array:D: **@values is raw) {}
95+
=begin code :signature
96+
multi method append(Array:D: \values)
97+
multi method append(Array:D: **@values is raw)
98+
=end code
99+
93100
94101
Usage:
95102
@@ -117,8 +124,10 @@ Example:
117124
118125
Defined as:
119126
120-
multi sub shift(Array:D ) {}
121-
multi method shift(Array:D:) {}
127+
=begin code :signature
128+
multi sub shift(Array:D )
129+
multi method shift(Array:D:)
130+
=end code
122131
123132
Usage:
124133
@@ -142,8 +151,11 @@ Example:
142151
143152
Defined as:
144153
145-
multi sub unshift(Array:D, **@values) returns Array:D {}
146-
multi method unshift(Array:D: **@values) returns Array:D {}
154+
=begin code :signature
155+
multi sub unshift(Array:D, **@values) returns Array:D
156+
multi method unshift(Array:D: **@values) returns Array:D
157+
=end code
158+
147159
148160
Usage:
149161
@@ -175,8 +187,11 @@ Defined as
175187
=begin code :skip-test
176188
sub prepend(\array, elems)
177189
=end code
178-
multi method prepend(Array:D: \values) {}
179-
multi method prepend(Array:D: **@values is raw) {}
190+
=begin code :signature
191+
multi method prepend(Array:D: \values)
192+
multi method prepend(Array:D: **@values is raw)
193+
=end code
194+
180195
181196
Usage:
182197
@@ -198,8 +213,11 @@ Example:
198213
199214
Defined as:
200215
201-
multi sub splice(@list, $start, $elems?, *@replacement) returns Array {}
202-
multi method splice(Array:D $start, $elems?, *@replacement) returns Array {}
216+
=begin code :signature
217+
multi sub splice(@list, $start, $elems?, *@replacement) returns Array
218+
multi method splice(Array:D $start, $elems?, *@replacement) returns Array
219+
=end code
220+
203221
204222
Usage:
205223
@@ -243,7 +261,9 @@ Example:
243261
244262
Defined as:
245263
246-
method default {}
264+
=begin code :signature
265+
method default
266+
=end code
247267
248268
Usage:
249269
@@ -272,7 +292,9 @@ the type object C<(Any)>.
272292
273293
Defined as:
274294
275-
method of {}
295+
=begin code :signature
296+
method of
297+
=end code
276298
277299
Usage:
278300

doc/Type/Attribute.pod6

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ The usual way to obtain an object of type C<Attribute> is by introspection:
3636
3737
Defined as:
3838
39-
method name(Attribute:D:) returns Str:D {}
39+
=begin code :signature
40+
method name(Attribute:D:) returns Str:D
41+
=end code
4042
4143
Usage:
4244
@@ -51,7 +53,9 @@ so if an attribute is declared as C<has $.a>, the name returned is C<$!a>.
5153
5254
Defined as:
5355
54-
method package(Attribute:D:) returns Mu:U {}
56+
=begin code :signature
57+
method package(Attribute:D:) returns Mu:U
58+
=end code
5559
5660
Usage:
5761
@@ -65,7 +69,9 @@ Returns the package (class/grammar/role) to which this attribute belongs.
6569
6670
Defined as:
6771
68-
method has_accessor(Attribute:D:) returns Bool:D {}
72+
=begin code :signature
73+
method has_accessor(Attribute:D:) returns Bool:D
74+
=end code
6975
7076
Usage:
7177
@@ -79,7 +85,9 @@ Returns C<True> if the attribute has a public accessor method.
7985
8086
Defined as:
8187
82-
method readonly(Attribute:D:) returns Bool:D {}
88+
=begin code :signature
89+
method readonly(Attribute:D:) returns Bool:D
90+
=end code
8391
8492
Usage:
8593
@@ -94,7 +102,9 @@ Returns C<False> for attributes marked as C<is rw>.
94102
95103
Defined as:
96104
97-
method type(Attribute:D:) returns Mu {}
105+
=begin code :signature
106+
method type(Attribute:D:) returns Mu
107+
=end code
98108
99109
Usage:
100110
@@ -108,7 +118,9 @@ Returns the type constraint of the attribute.
108118
109119
Defined as:
110120
111-
method get_value(Attribute:D: Mu $instance) {}
121+
=begin code :signature
122+
method get_value(Attribute:D: Mu $instance)
123+
=end code
112124
113125
Usage:
114126
@@ -125,7 +137,9 @@ used with care. Here be dragons.
125137
126138
Defined as:
127139
128-
method set_value(Attribute:D: Mu $instance, Mu \new_val) {}
140+
=begin code :signature
141+
method set_value(Attribute:D: Mu $instance, Mu \new_val)
142+
=end code
129143
130144
Usage:
131145
@@ -140,7 +154,9 @@ used with care. Here be dragons.
140154
141155
=head2 trait is required
142156
143-
multi sub trait_mod:<is> (Attribute $attr, :$required!) {}
157+
=begin code :signature
158+
multi sub trait_mod:<is> (Attribute $attr, :$required!)
159+
=end code
144160
145161
Marks an attribute as being required. If a value is not provided
146162
during object construction, an exception is thrown.
@@ -162,7 +178,9 @@ constructors written using L<bless>.
162178
163179
=head2 trait is rw
164180
165-
multi sub trait_mod:<is> (Attribute:D $attr, :$rw!) {}
181+
=begin code :signature
182+
multi sub trait_mod:<is> (Attribute:D $attr, :$rw!)
183+
=end code
166184
167185
Marks an attribute as read/write as opposed to the default
168186
C<readonly>. The default accessor for the attribute will return a

0 commit comments

Comments
 (0)