Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Include any routines from superclasses/roles
Previously only methods were added. This fails to include those methods
that are under a "routine" heading. Also, we shouldn't assume that
users of a class are only interested in inherited/supplied methods;
subs, traits and operators from a super type are equally interesting
to users of a subclass.
  • Loading branch information
moritz committed Mar 11, 2015
1 parent e721247 commit 197d042
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions htmlify.p6
Expand Up @@ -32,7 +32,7 @@ use Pod::Htmlify;
my $*DEBUG = False;

my $type-graph;
my %methods-by-type;
my %routines-by-type;
my %*POD2HTML-CALLBACKS;

# TODO: Generate menulist automatically
Expand Down Expand Up @@ -263,32 +263,32 @@ multi write-type-source($doc) {
my @roles-todo = $type.roles;
my %roles-seen;
while @roles-todo.shift -> $role {
next unless %methods-by-type{$role};
next unless %routines-by-type{$role};
next if %roles-seen{$role}++;
@roles-todo.push: $role.roles;
$pod.contents.push:
pod-heading("Methods supplied by role $role"),
pod-heading("Routines supplied by role $role"),
pod-block(
"$podname does role ",
pod-link($role.name, "/type/{uri_escape ~$role}"),
", which provides the following methods:",
),
%methods-by-type{$role}.list,
%routines-by-type{$role}.list,
;
}
for @mro -> $class {
next unless %methods-by-type{$class};
next unless %routines-by-type{$class};
$pod.contents.push:
pod-heading("Methods supplied by class $class"),
pod-heading("Routines supplied by class $class"),
pod-block(
"$podname inherits from class ",
pod-link($class.name, "/type/{uri_escape ~$class}"),
", which provides the following methods:",
),
%methods-by-type{$class}.list,
%routines-by-type{$class}.list,
;
for $class.roles -> $role {
next unless %methods-by-type{$role};
next unless %routines-by-type{$role};
$pod.contents.push:
pod-heading("Methods supplied by role $role"),
pod-block(
Expand All @@ -298,7 +298,7 @@ multi write-type-source($doc) {
pod-link($role.name, "/type/{uri_escape ~$role}"),
", which provides the following methods:",
),
%methods-by-type{$role}.list,
%routines-by-type{$role}.list,
;
}
}
Expand Down Expand Up @@ -444,8 +444,8 @@ sub find-definitions (:$pod, :$origin, :$min-level = -1) {
$created.subkinds = @subkinds;
$created.categories = @subkinds;
}
if $subkinds 'method' {
%methods-by-type{$origin.name}.push: $chunk;
if %attr<kind> eq 'routine' {
%routines-by-type{$origin.name}.push: $chunk;
write-qualified-method-call(
:$name,
:pod($chunk),
Expand Down Expand Up @@ -698,6 +698,7 @@ sub write-qualified-method-call(:$name!, :$pod!, :$type!) {
pod-block('From ', pod-link($type, "/type/{$type}#$name")),
@$pod,
);
return if $name ~~ / '/' /;
spurt "html/routine/{$type}.{$name}.html", p2h($p, 'routine');
}

Expand Down

0 comments on commit 197d042

Please sign in to comment.