Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rename @c -> @all-pod-elements in find-definitions()
  • Loading branch information
Paul Cochrane committed Feb 14, 2015
1 parent 36c35e2 commit 1139ae9
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions htmlify.p6
Expand Up @@ -308,12 +308,12 @@ sub find-definitions (:$pod, :$origin, :$min-level = -1) {
# If a heading is a definition, like "class FooBar", process
# the class and give the rest of the pod to find-definitions,
# which will return how far the definition of "class FooBar" extends.
my @c := $pod ~~ Positional ?? @$pod !! $pod.contents;
my @all-pod-elements := $pod ~~ Positional ?? @$pod !! $pod.contents;
my int $i = 0;
my int $len = +@c;
my int $len = +@all-pod-elements;
while $i < $len {
NEXT {$i = $i + 1}
my $pod-element := @c[$i];
my $pod-element := @all-pod-elements[$i];
next unless $pod-element ~~ Pod::Heading;
return $i if $pod-element.level <= $min-level;

Expand Down Expand Up @@ -367,8 +367,8 @@ sub find-definitions (:$pod, :$origin, :$min-level = -1) {
}
when 'class'|'role'|'enum' {
my $summary = '';
if @c[$i+1] ~~ {$_ ~~ Pod::Block::Named and .name eq "SUBTITLE"} {
$summary = @c[$i+1].contents[0].contents[0];
if @all-pod-elements[$i+1] ~~ {$_ ~~ Pod::Block::Named and .name eq "SUBTITLE"} {
$summary = @all-pod-elements[$i+1].contents[0].contents[0];
} else {
note "$name does not have an =SUBTITLE";
}
Expand Down Expand Up @@ -406,16 +406,18 @@ sub find-definitions (:$pod, :$origin, :$min-level = -1) {
# And updating $i to be after the places we've already searched
once {
$new-i = $i + find-definitions
:pod(@c[$i+1..*]), :origin($created), :min-level(@c[$i].level);
:pod(@all-pod-elements[$i+1..*]),
:origin($created),
:min-level(@all-pod-elements[$i].level);
}

my $new-head = Pod::Heading.new(
:level(@c[$i].level),
:level(@all-pod-elements[$i].level),
:contents[pod-link "$subkinds $name",
$created.url ~ "#$origin.human-kind() $origin.name()".subst(:g, /\s+/, '_')
]
);
my @orig-chunk = $new-head, @c[$i ^.. $new-i];
my @orig-chunk = $new-head, @all-pod-elements[$i ^.. $new-i];
my $chunk = $created.pod.push: pod-lower-headings(@orig-chunk, :to(%attr<kind> eq 'type' ?? 0 !! 2));

if $subkinds eq 'routine' {
Expand Down

0 comments on commit 1139ae9

Please sign in to comment.