Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
document X::Method::Private::Permission
  • Loading branch information
moritz committed Aug 21, 2012
1 parent e7f00c9 commit 6fc732a
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 1 deletion.
54 changes: 53 additions & 1 deletion htmlify.pl
Expand Up @@ -235,6 +235,7 @@ (Bool :$debug, Bool :$typegraph = False)
$dr.compose;

write-disambiguation-files($dr);
write-op-disambiguation-files($dr);
write-operator-files($dr);
write-type-graph-images(:force($typegraph));
write-search-file($dr);
Expand Down Expand Up @@ -410,6 +411,8 @@ (Bool :$debug, Bool :$typegraph = False)
spurt("html/search.html", $template.subst("ITEMS", $items));
}

my %operator_disambiguation_file_written;

sub write-disambiguation-files($dr) {
say "Writing disambiguation files";
for $dr.grouped-by('name').kv -> $name, $p is copy {
Expand Down Expand Up @@ -448,11 +451,60 @@ (Bool :$debug, Bool :$typegraph = False)
}
});
}
spurt "html/$name.html", p2h($pod);
my $html = p2h($pod);
spurt "html/$name.html", $html;
if all($p>>.kind) eq 'operator' {
spurt "html/op/$name.html", $html;
%operator_disambiguation_file_written{$p[0].name} = 1;
}
}
say "... done writing disambiguation files";
}

sub write-op-disambiguation-files($dr) {
say "Writing operator disambiguation files";
for $dr.lookup('operator', :by<kind>).classify(*.name).kv -> $name, @ops {
next unless %operator_disambiguation_file_written{$name};
my $pod = pod-with-title("Disambiguation for '$name'");
if @ops == 1 {
my $p = @ops[0];
if $p.origin -> $o {
$pod.content.push:
pod-block(
pod-link("'$name' is a $p.human-kind()", $p.url),
' from ',
pod-link($o.human-kind() ~ ' ' ~ $o.name, $o.url),
);
}
else {
$pod.content.push:
pod-block(
pod-link("'$name' is a $p.human-kind()", $p.url)
);
}
}
else {
$pod.content.push:
pod-block("'$name' can be anything of the following"),
@ops.map({
if .origin -> $o {
pod-item(
pod-link(.human-kind, .url),
' from ',
pod-link($o.human-kind() ~ ' ' ~ $o.name, $o.url),
)
}
else {
pod-item( pod-link(.human-kind, .url) )
}
});
}
my $html = p2h($pod);
spurt "html/$name.html", $html;
}

}

sub write-operator-files($dr) {
say "Writing operator files";
for $dr.lookup('operator', :by<kind>).list -> $doc {
Expand Down
41 changes: 41 additions & 0 deletions lib/X/Method/Private/Permission.pod
@@ -0,0 +1,41 @@
=begin pod
=TITLE class X::Method::Private::Permission
class X::Method::Private::Permission does X::Comp { }
Compile time error thrown when the code contains a call to a private method
that isn't defined in the current class, and when no appropriate trusts
relation is defined that permits the private method call.
For example the code
1!Int::foo
dies with
===SORRY!===
Cannot call private method 'foo' on package Int because it does not trust GLOBAL
=head1 Methods
=head2 method
method method() returns Str:D
The name of the private method
=head2 source-package
method source-package() returns Mu:D
Returns the type object that (supposedly) contains the private method.
=head2 calling-package
method calling-package() returns Mu:D
Returns the package in which the calling code is, and which the source package
does not trust.
=end pod

0 comments on commit 6fc732a

Please sign in to comment.