Skip to content

Commit 0144fda

Browse files
committed
Merge branch 'master' of github.com:perl6/doc
2 parents 7fd6d67 + 85cc9db commit 0144fda

File tree

7 files changed

+156
-13
lines changed

7 files changed

+156
-13
lines changed

README

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ A: Several reasons:
4141
3. A separate repo in the perl6 Github account invites
4242
more potential contributors and editors.
4343

44+
Q: Should I include methods from superclasses or roles
45+
A: No. In time we'll develop a mechanism to extract those
46+
automatically. Including all inherited methods manually
47+
simply doesn't scale.
48+
4449
Q: Which license is this stuff under?
4550
A: Both code and documentation are available under the Artistic License 2.0
4651
as published by The Perl Foundation. See the 'LICENSE' file for the full

TODO

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Known missing stuff
2+
3+
Types:
4+
Associative
5+
Positional
6+
Callable
7+
8+
Date # probably possible to steal much from S32::Temporal
9+
DateTime # probably possible to steal much from S32::Temporal
10+
Instant
11+
Duration
12+
13+
Backtrace
14+
Backtrace::Frame
15+
16+
Bag
17+
Set
18+
KeyBag
19+
KeySet
20+
21+
Order (enum)
22+
23+
Signature
24+
Parameter
25+
26+
Junction
27+
28+
ObjAt
29+
30+
Regex
31+
Routine

htmlify.pl

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env perl6
22
use v6;
33
use Pod::To::HTML;
4+
use URI::Escape;
45

56
# this script isn't in bin/ because it's not meant
67
# to be installed.
@@ -9,18 +10,33 @@
910
my %types;
1011
my %routines;
1112

13+
sub recursive-dir($dir) {
14+
my @todo = $dir;
15+
gather while @todo {
16+
my $d = @todo.shift;
17+
for dir($d) -> $f {
18+
if $f.f {
19+
take $f;
20+
}
21+
else {
22+
@todo.push($f.path);
23+
}
24+
}
25+
}
26+
}
27+
1228
sub MAIN($out_dir = 'html') {
1329
for ('', <type language routine>) {
1430
mkdir "$out_dir/$_" unless "$out_dir/$_".IO ~~ :e;
1531
}
1632

1733
# TODO: be recursive instead
18-
my @source = dir('lib').grep(*.f).grep(rx{\.pod$});
34+
my @source := recursive-dir('lib').grep(*.f).grep(rx{\.pod$});
1935

2036
my $tempfile = join '-', "tempfile", $*PID, (1..1000).pick ~ '.temp';
2137

2238
for (@source) {
23-
my $podname = .basename.subst(rx{\.pod$}, '').subst(:g, '/', '::');
39+
my $podname = .path.subst('lib/', '').subst(rx{\.pod$}, '').subst(:g, '/', '::');
2440
my $what = $podname ~~ /^<[A..Z]> | '::'/ ?? 'type' !! 'language';
2541
say "$_.path() => $what/$podname";
2642
%names{$podname}{$what}.push: "/$what/$podname";
@@ -38,9 +54,9 @@ ($out_dir = 'html')
3854
for @chunks -> $chunk {
3955
my $name = $chunk[0].content[0].content[0];
4056
next if $name ~~ /\s/;
41-
%names{$name}<routine>.push: "/type/$podname.html#$name";
42-
%routines{$name}.push: $podname => $chunk;
43-
%types<routine>{$name} = "/routine/$name";
57+
%names{$name}<routine>.push: "/type/$podname.html#" ~ uri_escape($name);
58+
%routines{$name}.push: $podname => $chunk;
59+
%types<routine>{$name} = "/routine/" ~ uri_escape( $name );
4460
}
4561
unlink $tempfile;
4662
}
@@ -81,7 +97,7 @@ ($out_dir = 'html')
8197
)
8298
)
8399
),
84-
@blocks,
100+
@blocks.flat,
85101
]
86102
);
87103
}
@@ -142,12 +158,13 @@ ($out_dir = 'html')
142158
say "Writing $out_dir/routine/$name.html";
143159
my $pod = pod-with-title("Documentation for routine $name",
144160
pod-block("Documentation for routine $name, assembled from the
145-
following types:"));
146-
$pod.content.push: @chunks.map(-> Pair (:key($type), :value($chunk)) {
161+
following types:"),
162+
@chunks.map(-> Pair (:key($type), :value($chunk)) {
147163
pod-heading($type),
148164
pod-block("From ", pod-link($type, "/type/{$type}#$name")),
149165
@$chunk
150-
});
166+
})
167+
);
151168
my $file = open :w, "$out_dir/routine/$name.html";
152169
$file.print: pod2html($pod);
153170
$file.close;

lib/IO.pod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
sub dir Cool $path = '.', Mu :$test = none('.', '..')
1212
13-
Returns a list if L<IO::File> and L<IO::Dir> objects for the
13+
Returns a list of L<IO::File> and L<IO::Dir> objects for the
1414
files and directories found in the $path. If $path is not given
1515
in lists the entries in the current directory.
1616
@@ -30,7 +30,7 @@ To include all the entries (including . and ..) write:
3030
3131
dir(test => all())
3232
33-
To include only the files with .pl extension write
33+
To include only the entries with .pl extension write
3434
3535
dir(test => /.pl$/)
3636

lib/Mu.pod

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,31 @@ Returns C<False> on the type object, and C<True> otherwise
2828
2929
Returns C<False> on the type object, and C<True> otherwise
3030
31+
=head2 Str
32+
33+
multi method Str() returns Str
34+
35+
Returns a string representation of the invocant, inteded to be machine
36+
readable.
37+
38+
=head2 gist
39+
40+
multi sub gist(Mu) returns Str
41+
multi method gist() returns Str
42+
43+
Returns a string representation of the invocant, optimized for
44+
fast recognition by humans.
45+
46+
The default C<gist> method in C<Mu> re-dispatches to the C<perl> method,
47+
but many built-in classes override it to something more specific.
48+
49+
=head2 perl
50+
51+
multi sub perl(Mu) returns Str
52+
multi method perl() returns Str
53+
54+
Returns parsable string which generates current class.
55+
3156
=head2 clone
3257
3358
method clone(*%twiddles)
@@ -51,13 +76,15 @@ their own C<new> method to override this default.
5176
5277
multi method print() returns Bool:D
5378
54-
Prints value to C<$*OUT> without newline at end.
79+
Prints value to C<$*OUT> after stringification using C<.Str> method without
80+
newline at end.
5581
5682
=head2 say
5783
5884
multi method say() returns Bool:D
5985
60-
Prints value to C<$*OUT> with newline at end.
86+
Prints value to C<$*OUT> after stringification using C<.gist> method with
87+
newline at end.
6188
6289
=head2 ACCEPTS
6390

lib/Parcel.pod

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
=begin pod
2+
3+
=TITLE class Parcel
4+
5+
class Parcel is Cool does Positional { }
6+
7+
I<Parcel> stands for I<Par>enthesis I<cel>l, ie an expression
8+
surrounded by parenthesis. Though with the exception of the empty parcel,
9+
C<()>, it is really the comma that create a Parcel.
10+
11+
() # empty Parcel
12+
(1 + 2) # not a Parcel
13+
(1, 2) # Parcel with two elements
14+
15+
Parcels are immutable, but can contain mutable containers.
16+
17+
my $x;
18+
my $p = (0, $x, 2); # can assign to $p[1], but not
19+
# to any other element of $p
20+
21+
Word-quoting constructs such as C<< <...> >> also create parcels:
22+
23+
<a b c> # 3-element Parcel
24+
25+
In flattening list context, parcels are flattened out and disappear:
26+
27+
my @flat = <a b>, <c, d>;
28+
say @flat.elems; # 4
29+
30+
=end pod

lib/X/AdHoc.pod

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
=begin pod
2+
3+
=TITLE class X::AdHoc
4+
5+
class X::AdHoc is Exception { ... }
6+
7+
C<X::AdHoc> is the type into which objects are wrapped if they are
8+
thrown as exceptions, but don't inherit from L<Exception>.
9+
10+
Its benefit over returning non-C<Exception> objects is that it gives
11+
access to all the methods from class L<Exception>, like C<backtrace>
12+
and C<rethrow>.
13+
14+
You can obtain the original object with the C<payload> method.
15+
16+
try {
17+
die [404, 'File not found']; # throw non-exception object
18+
}
19+
say "Got HTTP code ",
20+
$!.payload[0], # 404
21+
" and backtrace ",
22+
$!.backtrace;
23+
24+
=head1 METHODS
25+
26+
=head2 payload
27+
28+
method payload(X::AdHoc:D)
29+
30+
Returns the original object which was passed to C<die>.
31+
32+
=end pod
33+

0 commit comments

Comments
 (0)