Permalink
Browse files

make disambiguations more awesome

  • Loading branch information...
1 parent df46991 commit e6d28fd1fa60874e7bf838a078240972adfc8c75 @moritz moritz committed Aug 14, 2012
Showing with 51 additions and 24 deletions.
  1. +46 −22 htmlify.pl
  2. +3 −0 lib/Perl6/Documentable.pm
  3. +2 −2 lib/Perl6/Documentable/Registry.pm
View
@@ -142,22 +142,7 @@ (Bool :$debug, Bool :$typegraph = False)
:from({ $_ ~~ Pod::Heading and .level == 2}),
:to({ $^b ~~ Pod::Heading and $^b.level <= $^a.level}),
);
- for @chunks -> $chunk {
- my $name = $chunk[0].content[0].content[0];
- say "$podname.$name" if $*DEBUG;
- next if $name ~~ /\s/;
- %methods-by-type{$podname}.push: $chunk;
- %names{$name}<routine>.push: "/type/$podname.html#" ~ uri_escape($name);
- %routines{$name}.push: $podname => $chunk;
- %types<routine>{$name} = "/routine/" ~ uri_escape( $name );
- $dr.add-new(
- :kind<routine>,
- # TODO: determine subkind, ie method/sub
- :name($name),
- :pod($chunk),
- :!pod-is-complete,
- );
- }
+
if $tg.types{$podname} -> $t {
$pod.content.push: Pod::Block::Named.new(
name => 'Image',
@@ -208,13 +193,31 @@ (Bool :$debug, Bool :$typegraph = False)
}
}
}
- $dr.add-new(
+ my $d = $dr.add-new(
:kind<type>,
# TODO: subkind
:$pod,
:pod-is-complete,
:name($podname),
);
+
+ for @chunks -> $chunk {
+ my $name = $chunk[0].content[0].content[0];
+ say "$podname.$name" if $*DEBUG;
+ next if $name ~~ /\s/;
+ %methods-by-type{$podname}.push: $chunk;
+ %names{$name}<routine>.push: "/type/$podname.html#" ~ uri_escape($name);
+ %routines{$name}.push: $podname => $chunk;
+ %types<routine>{$name} = "/routine/" ~ uri_escape( $name );
+ $dr.add-new(
+ :kind<routine>,
+ # TODO: determine subkind, ie method/sub
+ :name($name),
+ :pod($chunk),
+ :!pod-is-complete,
+ :origin($d),
+ );
+ }
spurt "html/$what/$podname.html", p2h($pod);
}
@@ -395,16 +398,35 @@ (Bool :$debug, Bool :$typegraph = False)
my $pod = pod-with-title("Disambiguation for '$name'");
if $p.elems == 1 {
$p.=[0] if $p ~~ Array;
- $pod.content.push:
- pod-block(
- pod-link("'$name' is a $p.human-kind()", $p.url)
- );
+ 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"),
$p.map({
- pod-item( pod-link(.human-kind, .url) )
+ 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) )
+ }
});
}
spurt "html/$name.html", p2h($pod);
@@ -431,6 +453,7 @@ (Bool :$debug, Bool :$typegraph = False)
sub write-index-file($dr) {
say "Writing html/index.html";
+ my %routine-seen;
my $pod = pod-with-title('Perl 6 Documentation',
Pod::Block::Para.new(
content => ['Official Perl 6 documentation'],
@@ -446,6 +469,7 @@ (Bool :$debug, Bool :$typegraph = False)
}),
pod-heading('Routines'),
$dr.lookup('routine', :by<kind>).sort(*.name).map({
+ next if %routine-seen{.name}++;
pod-item(pod-link(.name, .url))
}),
);
@@ -7,6 +7,9 @@ class Perl6::Documentable {
has $.pod;
has Bool $.pod-is-complete;
+ # the Documentable that this one was extracted from, if any
+ has $.origin;
+
method human-kind() { # SCNR
$.kind eq 'operator'
?? "$.subkind operator"
@@ -8,8 +8,8 @@ class Perl6::Documentable::Registry {
has %!grouped-by;
method add-new(*%args) {
die "Cannot add something to a composed registry" if $.composed;
- @!documentables.push: Perl6::Documentable.new(|%args);
- 1;
+ @!documentables.push: my $d = Perl6::Documentable.new(|%args);
+ $d;
}
method compose() {
$!composed = True;

0 comments on commit e6d28fd

Please sign in to comment.