Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New pod config option: 'signature' #814

Merged
merged 1 commit into from Aug 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -97,6 +97,16 @@ To export examples from all .pod6-files use `make extract-examples`. To run
individual tests pick the right .p6-file from `examples/` as a parameter to
`perl6`.

### Signatures

Signatures are part of actual code and need to be tested too. But without the body every
signature will cause an error during the test. Use the pod-config option `signature` to
automatically add an empty body.

=begin code :signature
method new(*@codes)
=end code

### Skipping tests

Some examples fail with compile time exceptions and would interrupt the test
Expand Down
48 changes: 35 additions & 13 deletions doc/Type/Any.pod6
Expand Up @@ -20,7 +20,9 @@ List or a list-like type.

Defined as:

multi method ACCEPTS(Any:D: Mu $other) {}
=begin code :signature
multi method ACCEPTS(Any:D: Mu $other)
=end code

Usage:

Expand All @@ -36,7 +38,9 @@ Many built-in types override this for more specific comparisons

Defined as:

method any() returns Junction:D {}
=begin code :signature
method any() returns Junction:D
=end code

Usage:

Expand All @@ -54,7 +58,9 @@ C<any>-L<Junction|/type/Junction> from it.

Defined as:

method all() returns Junction:D {}
=begin code :signature
method all() returns Junction:D
=end code

Usage:

Expand All @@ -72,7 +78,9 @@ C<all>-L<Junction|/type/Junction> from it.

Defined as:

method one() returns Junction:D {}
=begin code :signature
method one() returns Junction:D
=end code

Usage:

Expand All @@ -90,7 +98,9 @@ C<one>-L<Junction|/type/Junction> from it.

Defined as:

method none() returns Junction:D {}
=begin code :signature
method none() returns Junction:D
=end code

Usage:

Expand Down Expand Up @@ -127,8 +137,10 @@ into the newly created Array.

Defined as:

multi sub reverse(*@list ) returns List:D {}
multi method reverse(List:D:) returns List:D {}
=begin code :signature
multi sub reverse(*@list ) returns List:D
multi method reverse(List:D:) returns List:D
=end code

Usage:

Expand Down Expand Up @@ -163,8 +175,10 @@ Examples:
Defined as:

proto method map(|) is nodal { * }
multi method map(\SELF: &block;; :$label, :$item) {}
multi method map(HyperIterable:D: &block;; :$label) {}
=begin code :signature
multi method map(\SELF: &block;; :$label, :$item)
multi method map(HyperIterable:D: &block;; :$label)
=end code

C<map> will iterate over the invocant and apply the number of positional
parameters of the code object from the invocant per call. The returned values
Expand All @@ -174,7 +188,9 @@ of the code object will become elements of the returned C<Seq>.

Defined as:

method deepmap(&block -->List) is nodal {}
=begin code :signature
method deepmap(&block -->List) is nodal
=end code

C<deepmap> will apply C<&block> to each element and return a new C<List> with
the return values of C<&block>, unless the element does the C<Iterable> role.
Expand All @@ -187,7 +203,9 @@ For those elements C<deepmap> will descend recursively into the sublist.

Defined as:

method duckmap(&block) is rw is nodal {}
=begin code :signature
method duckmap(&block) is rw is nodal
=end code

C<duckmap> will apply C<&block> on each element and return a new list with
defined return values of the block. For undefined return values, C<duckmap>
Expand Down Expand Up @@ -246,7 +264,9 @@ Interprets the invocant as a list, and returns the last index of that list.

=head2 method pairup

method pairup() returns List {}
=begin code :signature
method pairup() returns List
=end code

Interprets the invocant as a list, and constructs a list of
L<pairs|/type/Pair> from it, in the same way that assignment to a
Expand All @@ -259,7 +279,9 @@ list item, if any, is considered to be a key again).

=head2 sub exit

sub exit(Int() $status = 0) {}
=begin code :signature
sub exit(Int() $status = 0)
=end code

Exits the current process with return code C<$status>.

Expand Down
54 changes: 38 additions & 16 deletions doc/Type/Array.pod6
Expand Up @@ -15,8 +15,10 @@ scalar containers, which means you can assign to array elements.

Defined as:

multi sub pop(Array:D ) {}
multi method pop(Array:D:) {}
=begin code :signature
multi sub pop(Array:D )
multi method pop(Array:D:)
=end code

Usage:

Expand All @@ -40,8 +42,10 @@ Example:

Defined as:

multi sub push(Array:D, **@values) returns Array:D {}
multi method push(Array:D: **@values) returns Array:D {}
=begin code :signature
multi sub push(Array:D, **@values) returns Array:D
multi method push(Array:D: **@values) returns Array:D
=end code

Usage:

Expand Down Expand Up @@ -88,8 +92,11 @@ Defined as
=begin code :skip-test
sub append(\array, elems)
=end code
multi method append(Array:D: \values) {}
multi method append(Array:D: **@values is raw) {}
=begin code :signature
multi method append(Array:D: \values)
multi method append(Array:D: **@values is raw)
=end code


Usage:

Expand Down Expand Up @@ -117,8 +124,10 @@ Example:

Defined as:

multi sub shift(Array:D ) {}
multi method shift(Array:D:) {}
=begin code :signature
multi sub shift(Array:D )
multi method shift(Array:D:)
=end code

Usage:

Expand All @@ -142,8 +151,11 @@ Example:

Defined as:

multi sub unshift(Array:D, **@values) returns Array:D {}
multi method unshift(Array:D: **@values) returns Array:D {}
=begin code :signature
multi sub unshift(Array:D, **@values) returns Array:D
multi method unshift(Array:D: **@values) returns Array:D
=end code


Usage:

Expand Down Expand Up @@ -175,8 +187,11 @@ Defined as
=begin code :skip-test
sub prepend(\array, elems)
=end code
multi method prepend(Array:D: \values) {}
multi method prepend(Array:D: **@values is raw) {}
=begin code :signature
multi method prepend(Array:D: \values)
multi method prepend(Array:D: **@values is raw)
=end code


Usage:

Expand All @@ -198,8 +213,11 @@ Example:

Defined as:

multi sub splice(@list, $start, $elems?, *@replacement) returns Array {}
multi method splice(Array:D $start, $elems?, *@replacement) returns Array {}
=begin code :signature
multi sub splice(@list, $start, $elems?, *@replacement) returns Array
multi method splice(Array:D $start, $elems?, *@replacement) returns Array
=end code


Usage:

Expand Down Expand Up @@ -243,7 +261,9 @@ Example:

Defined as:

method default {}
=begin code :signature
method default
=end code

Usage:

Expand Down Expand Up @@ -272,7 +292,9 @@ the type object C<(Any)>.

Defined as:

method of {}
=begin code :signature
method of
=end code

Usage:

Expand Down
36 changes: 27 additions & 9 deletions doc/Type/Attribute.pod6
Expand Up @@ -36,7 +36,9 @@ The usual way to obtain an object of type C<Attribute> is by introspection:

Defined as:

method name(Attribute:D:) returns Str:D {}
=begin code :signature
method name(Attribute:D:) returns Str:D
=end code

Usage:

Expand All @@ -51,7 +53,9 @@ so if an attribute is declared as C<has $.a>, the name returned is C<$!a>.

Defined as:

method package(Attribute:D:) returns Mu:U {}
=begin code :signature
method package(Attribute:D:) returns Mu:U
=end code

Usage:

Expand All @@ -65,7 +69,9 @@ Returns the package (class/grammar/role) to which this attribute belongs.

Defined as:

method has_accessor(Attribute:D:) returns Bool:D {}
=begin code :signature
method has_accessor(Attribute:D:) returns Bool:D
=end code

Usage:

Expand All @@ -79,7 +85,9 @@ Returns C<True> if the attribute has a public accessor method.

Defined as:

method readonly(Attribute:D:) returns Bool:D {}
=begin code :signature
method readonly(Attribute:D:) returns Bool:D
=end code

Usage:

Expand All @@ -94,7 +102,9 @@ Returns C<False> for attributes marked as C<is rw>.

Defined as:

method type(Attribute:D:) returns Mu {}
=begin code :signature
method type(Attribute:D:) returns Mu
=end code

Usage:

Expand All @@ -108,7 +118,9 @@ Returns the type constraint of the attribute.

Defined as:

method get_value(Attribute:D: Mu $instance) {}
=begin code :signature
method get_value(Attribute:D: Mu $instance)
=end code

Usage:

Expand All @@ -125,7 +137,9 @@ used with care. Here be dragons.

Defined as:

method set_value(Attribute:D: Mu $instance, Mu \new_val) {}
=begin code :signature
method set_value(Attribute:D: Mu $instance, Mu \new_val)
=end code

Usage:

Expand All @@ -140,7 +154,9 @@ used with care. Here be dragons.

=head2 trait is required

multi sub trait_mod:<is> (Attribute $attr, :$required!) {}
=begin code :signature
multi sub trait_mod:<is> (Attribute $attr, :$required!)
=end code

Marks an attribute as being required. If a value is not provided
during object construction, an exception is thrown.
Expand All @@ -162,7 +178,9 @@ constructors written using L<bless>.

=head2 trait is rw

multi sub trait_mod:<is> (Attribute:D $attr, :$rw!) {}
=begin code :signature
multi sub trait_mod:<is> (Attribute:D $attr, :$rw!)
=end code

Marks an attribute as read/write as opposed to the default
C<readonly>. The default accessor for the attribute will return a
Expand Down