Skip to content

Commit

Permalink
Update handling of the now listy Documentable.subkind
Browse files Browse the repository at this point in the history
  • Loading branch information
Mouq committed Jun 16, 2014
1 parent 3d00cff commit f019036
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 0 additions & 2 deletions TODO
Expand Up @@ -7,8 +7,6 @@ Definites:
will allow for disambiguation pages to point to better, more
contextful docs, and for less redundancy in the docs
overall.
* Update gathering of info on routines so that things defined as
both subs and methods will be displayed as such.
* Emit a warning when formatting is bad. E.g., a routine that
doesn't have a defining code block, or a page that lacks a
proper title.
Expand Down
4 changes: 3 additions & 1 deletion htmlify.p6
Expand Up @@ -512,7 +512,9 @@ sub write-search-file($dr) {
});
my %seen;
@items.push: $dr.lookup('routine', :by<kind>).grep({!%seen{.name}++}).sort(*.name).map({
qq[\{ label: "{ (.subkind // 'Routine').tclc }: {escape .name}", value: "{escape .name}", url: "{ fix-url(.url) }" \}]
do for .subkind // 'Routine' -> $subkind {
qq[\{ label: "{ $subkind.tclc }: {escape .name}", value: "{escape .name}", url: "{ fix-url(.url) }" \}]
}
});
@items.push: $dr.lookup('operator', :by<kind>).map({
qq[\{ label: "$_.human-kind() {escape .name}", value: "{escape .name}", url: "{ fix-url .url }"\}]
Expand Down
7 changes: 6 additions & 1 deletion lib/Perl6/Documentable.pm
Expand Up @@ -12,12 +12,17 @@ class Perl6::Documentable {
# the Documentable that this one was extracted from, if any
has $.origin;

my sub english-list (*@l) {
@l > 1
?? @l[0..*-2].join(', ') ~ " and @l[*-1]"
!! ~@l[0]
}
method human-kind() { # SCNR
$.kind eq 'operator'
?? "@.subkind[] operator"
!! $.kind eq 'language'
?? 'language documentation'
!! $.subkind // $.kind;
!! english-list @.subkind // $.kind;
}

method filename() {
Expand Down

0 comments on commit f019036

Please sign in to comment.