Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Detect multiple subkinds on routines + note if a subkind can't be found
This is useful for those routines defined as both a sub and method, of
which Perl 6 has many
  • Loading branch information
Mouq committed Jun 16, 2014
1 parent 123caf2 commit 3d00cff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions htmlify.p6
Expand Up @@ -317,16 +317,18 @@ sub write-type-file(:$dr, :$what, :$pod, :$podname) {
);
} else {
# determine whether it's a sub or method
my Str $subkind;
my Str @subkind;
{
my %counter;
for first-code-block($chunk).lines {
if ms/^ 'multi'? (sub|method)»/ {
%counter{$0}++;
}
}
if %counter == 1 {
($subkind,) = %counter.keys;
if +%counter {
@subkind = %counter.keys;
} else {
note "The subkind of routine $name in $podname.pod cannot be determined."
}
if %counter<method> {
write-qualified-method-call(
Expand All @@ -339,7 +341,7 @@ sub write-type-file(:$dr, :$what, :$pod, :$podname) {

$dr.add-new(
:kind<routine>,
:$subkind,
:@subkind,
:$name,
:pod($chunk),
:!pod-is-complete,
Expand Down
6 changes: 3 additions & 3 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 @.subkind; # class/role/enum, sub/method, prefix/infix/...

has Str $.name;
has Str $.url;
Expand All @@ -14,7 +14,7 @@ class Perl6::Documentable {

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

0 comments on commit 3d00cff

Please sign in to comment.