Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Last "Usage" sections were re-formatted, two examples for Label were …
…added
  • Loading branch information
Altai-man committed Aug 14, 2016
1 parent edbad25 commit 3029fc1
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 83 deletions.
19 changes: 7 additions & 12 deletions doc/Type/Backtrace.pod6
Expand Up @@ -24,40 +24,35 @@ proto method new(*@, *%) {*}
multi method new()
=end code
Usage:
my $backtrace = Backtrace.new;
Creates a new backtrace, using its calling location as the origin of the
backtrace.
my $backtrace = Backtrace.new;
=head2 method Str
Defined as:
multi method Str(Backtrace:D:)
Usage:
my $backtrace = Backtrace.new;
say $backtrace.Str;
Returns a concise string representation of the backtrace, omitting
routines marked as C<is hidden-from-backtrace>, and at the discretion of
the implementor, also some routines from the setting.
my $backtrace = Backtrace.new;
say $backtrace.Str;
=head2 method full
Defined as:
multi method full(Backtrace:D:)
Usage:
Returns a full string representation of the backtrace, including hidden
frames, compiler-specific frames and those from the setting.
my $backtrace = Backtrace.new;
say $backtrace.full;
Returns a full string representation of the backtrace, including hidden
frames, compiler-specific frames and those from the setting.
=end pod
32 changes: 9 additions & 23 deletions doc/Type/Backtrace/Frame.pod6
Expand Up @@ -16,98 +16,84 @@ Defined as:
method file(Backtrace::Frame:D) returns Str
Usage:
Returns the file name.
my $bt = Backtrace.new;
my $btf = $bt[0];
say $btf.file;
Returns the file name.
=head2 method line
Defined as:
method line(Backtrace::Frame:D) returns Int
Usage:
Returns the line number (line numbers start to count from 1).
my $bt = Backtrace.new;
my $btf = $bt[0];
say $btf.line;
Returns the line number (line numbers start to count from 1).
=head2 method code
Defined as:
method code(Backtrace::Frame:D)
Usage:
Returns the code object into which C<.file> and C<.line> point, if available.
my $bt = Backtrace.new;
my $btf = $bt[0];
say $btf.code;
Returns the code object into which C<.file> and C<.line> point, if available.
=head2 method subname
Defined as:
method subname(Backtrace::Frame:D) returns Str
Usage:
Returns the name of the enclosing subroutine.
my $bt = Backtrace.new;
my $btf = $bt[0];
say $btf.subname;
Returns the name of the enclosing subroutine.
=head2 method is-hidden
Defined as:
method is-hidden(Backtrace::Frame:D) returns Bool:D
Usage:
Returns C<True> if the frame is marked as hidden with the
C<is hidden-from-backtrace> trait.
my $bt = Backtrace.new;
my $btf = $bt[0];
say $btf.is-hidden;
Returns C<True> if the frame is marked as hidden with the
C<is hidden-from-backtrace> trait.
=head2 method is-routine
Defined as:
method is-routine(Backtrace::Frame:D) returns Bool:D
Usage:
Return C<True> if the frame point into a routine (and not
into a mere L<Block>).
my $bt = Backtrace.new;
my $btf = $bt[0];
say $btf.is-routine;
Return C<True> if the frame point into a routine (and not
into a mere L<Block>).
=head2 method is-setting
Defined as:
method is-setting(Backtrace::Frame:D) returns Bool:D
Usage:
Returns C<True> if the frame is part of a setting.
my $bt = Backtrace.new;
my $btf = $bt[0];
say $btf.is-setting; # True
Returns C<True> if the frame is part of a setting.
=end pod
28 changes: 10 additions & 18 deletions doc/Type/Blob.pod6
Expand Up @@ -17,53 +17,45 @@ Defined as:
method new(*@codes)
Usage:
Creates a C<Blob> from a list of integers.
my $blob = Blob.new([1, 2, 3]);
Creates a C<Blob> from a list of integers.
=head2 method Bool
Defined as:
multi method Bool(Blob:D:)
Usage:
Returns C<False> if and only if the buffer is empty.
my $blob = Blob.new();
say $blob.Bool; # OUTPUT: «False␤»
$blob = Blob.new([1, 2, 3]);
say $blob.Bool; # OUTPUT: «True␤»
Returns C<False> if and only if the buffer is empty.
=head2 method elems
Defined as:
multi method elems(Blob:D:) returns Int:D
Usage:
Returns the number of elements of the buffer.
my $blob = Blob.new([1, 2, 3]);
say $blob.elems; # OUTPUT: «3␤»
Returns the number of elements of the buffer.
=head2 method decode
Defined as:
multi method decode(Blob:D: Str:D $encoding = 'UTF-8') returns Str:D
Usage:
Applies an encoding to turn the blob into a L<Str|/type/Str>.
my Blob $blob = "string".encode('utf-8');
say $blob.decode('utf-8'); # OUTPUT: «string␤»
Applies an encoding to turn the blob into a L<Str|/type/Str>.
=head2 method subbuf
Defined as:
Expand Down Expand Up @@ -95,12 +87,6 @@ Defined as:
method unpack(Blob:D: $template) returns List:D
Usage:
use experimental :pack;
say Blob.new(1..10).unpack("C*");
# OUTPUT: «(1 2 3 4 5 6 7 8 9 10)␤»
Extracts features from the blob according to the template string, and
returns them as a list.
Expand Down Expand Up @@ -134,6 +120,12 @@ The following letters are recognized:
=end table
Example:
use experimental :pack;
say Blob.new(1..10).unpack("C*");
# OUTPUT: «(1 2 3 4 5 6 7 8 9 10)␤»
=head2 sub pack
This subroutine is considered B<experimental>, in order to use it you will need to do:
Expand Down
22 changes: 6 additions & 16 deletions doc/Type/Cool.pod6
Expand Up @@ -836,7 +836,8 @@ Defined as:
sub uniname(Str(Cool)) returns Str
method uniname() returns Str
Usage:
Interprets the invocant / first argument as a L<Str|/type/Str>, and returns the
Unicode codepoint name of the first character. To convert a whole string use L<uninames|#routine_uninames>.
# Camelia in Unicode
say ‘»ö«’.comb».uniname;
Expand All @@ -847,25 +848,20 @@ Usage:
say (0..0x1FFFF).sort(*.uniname.chars)[*-1].chr.uniname;
# «ARABIC LIGATURE UIGHUR KIRGHIZ YEH WITH HAMZA ABOVE WITH ALEF MAKSURA INITIAL FORM␤»
Interprets the invocant / first argument as a L<Str|/type/Str>, and returns the
Unicode codepoint name of the first character. To convert a whole string use L<uninames|#routine_uninames>.
=head2 routine uninames
Defined as:
sub uninames(Str:D)
method uninames()
Usage:
Returns of a Seq of unicode names for the Str provided.
dd ‘»ö«’.comb».uniname;
# «("RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK",
# "LATIN SMALL LETTER O WITH DIAERESIS",
# "LEFT-POINTING DOUBLE ANGLE QUOTATION MARK").Seq␤»
Returns of a Seq of unicode names for the Str provided.
=head2 routine chop
Defined as:
Expand Down Expand Up @@ -1167,10 +1163,6 @@ Defined as:
sub EVAL(Cool $code, :$lang = { ... })
Usage:
EVAL "say 'hello'";
Coerces the invocant to L<Str>.
This works as-is with a literal string parameter. If you have a more complex
Expand Down Expand Up @@ -1223,15 +1215,13 @@ Defined as:
sub EVALFILE(Cool $filename, :$lang = { ... })
Usage:
=for code :skip-test
EVALFILE "foo.p6";
Slurps the specified file and evaluates it. Behaves the same way as C<EVAL>
with regard to both scoping and the C<$lang> parameter. Evaluates to the value
produced by the final statement in the file.
=for code :skip-test
EVALFILE "foo.p6";
=begin comment
TODO:
Expand Down
24 changes: 12 additions & 12 deletions doc/Type/Label.pod6
Expand Up @@ -31,26 +31,26 @@ Defined as:
method next(Label:)
Usage:
=begin code :skip-test
next LABEL
=end code
Begin the next iteration of the loop associated with the label.
MY-LABEL:
for 1..10 {
next MY-LABEL if $_ > 5; # does 5 iteration and then 5 empty iteration
say $_;
}
=head2 method last
Defined as:
method last(Label:)
Usage:
=begin code :skip-test
last LABEL
=end code
Terminate the execution of the loop associated with the label.
MY-LABEL:
for 1..10 {
last MY-LABEL if $_ > 5; # does only 5 iteration
say $_;
}
=end pod
2 changes: 0 additions & 2 deletions doc/Type/List.pod6
Expand Up @@ -325,8 +325,6 @@ Defined as:
multi method tail(List:D: Int(Cool) $number = 1) returns Seq:D
Usage:
Returns a L<Seq> containing the B<last> NUMBER items of the list. Returns an empty Seq if
NUMBER <= 0. Defaults to the last element if no NUMBER is specified.
Throws an exception if the list is lazy.
Expand Down

0 comments on commit 3029fc1

Please sign in to comment.