Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rename .subkind to .subkinds
  • Loading branch information
Mouq committed Jun 16, 2014
1 parent f019036 commit 3b8e741
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
26 changes: 13 additions & 13 deletions htmlify.p6
Expand Up @@ -211,7 +211,7 @@ sub write-language-file(:$dr, :$what, :$pod, :$podname) {
my $operator = $heading.split(' ', 2)[1];
$dr.add-new(
:kind<operator>,
:subkind($what),
:subkinds($what),
:name($operator),
:pod($chunk),
:!pod-is-complete,
Expand Down Expand Up @@ -292,7 +292,7 @@ sub write-type-file(:$dr, :$what, :$pod, :$podname) {
}
my $d = $dr.add-new(
:kind<type>,
:$subkind,
:subkinds($subkind),
:$pod,
:pod-is-complete,
:name($podname),
Expand All @@ -309,15 +309,15 @@ sub write-type-file(:$dr, :$what, :$pod, :$podname) {
my $operator = $name.split(' ', 2)[1];
$dr.add-new(
:kind<routine>,
:subkind($what),
:subkinds($what),
:name($operator),
:pod($chunk),
:!pod-is-complete,
:origin($d),
);
} else {
# determine whether it's a sub or method
my Str @subkind;
my Str @subkinds;
{
my %counter;
for first-code-block($chunk).lines {
Expand All @@ -326,9 +326,9 @@ sub write-type-file(:$dr, :$what, :$pod, :$podname) {
}
}
if +%counter {
@subkind = %counter.keys;
@subkinds = %counter.keys;
} else {
note "The subkind of routine $name in $podname.pod cannot be determined."
note "The subkinds of routine $name in $podname.pod cannot be determined."
}
if %counter<method> {
write-qualified-method-call(
Expand All @@ -341,7 +341,7 @@ sub write-type-file(:$dr, :$what, :$pod, :$podname) {

$dr.add-new(
:kind<routine>,
:@subkind,
:@subkinds,
:$name,
:pod($chunk),
:!pod-is-complete,
Expand Down Expand Up @@ -512,7 +512,7 @@ sub write-search-file($dr) {
});
my %seen;
@items.push: $dr.lookup('routine', :by<kind>).grep({!%seen{.name}++}).sort(*.name).map({
do for .subkind // 'Routine' -> $subkind {
do for .subkinds // 'Routine' -> $subkind {
qq[\{ label: "{ $subkind.tclc }: {escape .name}", value: "{escape .name}", url: "{ fix-url(.url) }" \}]
}
});
Expand Down Expand Up @@ -621,7 +621,7 @@ sub write-op-disambiguation-files($dr) {
sub write-operator-files($dr) {
say 'Writing operator files ...';
for $dr.lookup('operator', :by<kind>).list -> $doc {
my $what = $doc.subkind;
my $what = $doc.subkinds;
my $op = $doc.name;
my $pod = pod-with-title(
"$what.tclc() $op operator",
Expand Down Expand Up @@ -660,7 +660,7 @@ sub write-index-files($dr) {
'Perl 6 Types',
list-of-all('types'),
pod-table($dr.lookup('type', :by<kind>).sort(*.name).map({
[.subkind, pod-link(.name, .url), .summary]
[.subkinds, pod-link(.name, .url), .summary]
}))
), 'type');

Expand All @@ -669,7 +669,7 @@ sub write-index-files($dr) {
'Perl 6 Routines',
list-of-all('routines'),
pod-table($dr.lookup('routine', :by<kind>).categorize(*.name).sort(*.key)>>.value.map({
[set(.map: {.subkind // Nil}).list.join(', '), pod-link(.[0].name, .[0].url), .[0].summary]
[set(.map: {.subkinds // Nil}).list.join(', '), pod-link(.[0].name, .[0].url), .[0].summary]
}))
), 'routine');
}
Expand All @@ -679,15 +679,15 @@ sub write-routine-file($dr, $name) {
my @docs = $dr.lookup($name, :by<name>).grep(*.kind eq 'routine');
my $subkind = 'routine';
{
my @subkinds = @docs>>.subkind;
my @subkinds = @docs>>.subkinds;
$subkind = @subkinds[0] if all(@subkinds>>.defined) && [eq] @subkinds;
}
my $pod = pod-with-title("Documentation for $subkind $name",
pod-block("Documentation for $subkind $name, assembled from the
following types:"),
@docs.map({
pod-heading(.origin.name ~ '.' ~ .name), # TODO: better way to get link to origin
pod-block("From ", pod-link(.origin.name, .origin.url ~ '#' ~ (.subkind ~~ /fix/ ?? .subkind~'_' !! '') ~ .name)),
pod-block("From ", pod-link(.origin.name, .origin.url ~ '#' ~ (.subkinds ~~ /fix/ ?? .subkinds~'_' !! '') ~ .name)),
.pod.list,
})
);
Expand Down
8 changes: 4 additions & 4 deletions lib/Perl6/Documentable.pm
@@ -1,7 +1,7 @@
use URI::Escape;
class Perl6::Documentable {
has Str $.kind; # type, language doc, routine, operator
has Str @.subkind; # class/role/enum, sub/method, prefix/infix/...
has Str @.subkinds; # class/role/enum, sub/method, prefix/infix/...

has Str $.name;
has Str $.url;
Expand All @@ -19,10 +19,10 @@ class Perl6::Documentable {
}
method human-kind() { # SCNR
$.kind eq 'operator'
?? "@.subkind[] operator"
?? "@.subkinds[] operator"
!! $.kind eq 'language'
?? 'language documentation'
!! english-list @.subkind // $.kind;
!! english-list @.subkinds // $.kind;
}

method filename() {
Expand All @@ -33,7 +33,7 @@ class Perl6::Documentable {
}
method url() {
$!url //= $.kind eq 'operator'
?? "/language/operators#" ~ uri_escape("@.subkind[] $.name".subst(/\s+/, '_', :g))
?? "/language/operators#" ~ uri_escape("@.subkinds[] $.name".subst(/\s+/, '_', :g))
!! "/$.kind/$.name"
;
}
Expand Down

0 comments on commit 3b8e741

Please sign in to comment.