Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Generate operator index
  • Loading branch information
Mouq committed Jun 16, 2014
1 parent ec0abda commit ee92b0b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
14 changes: 8 additions & 6 deletions htmlify.p6
Expand Up @@ -220,6 +220,7 @@ sub write-language-file(:$dr, :$what, :$pod, :$podname) {
$dr.add-new(
:kind<routine>,
:subkinds($what),
:categories<operator>,
:name($operator),
:pod($chunk),
:origin($d)
Expand Down Expand Up @@ -309,6 +310,7 @@ sub write-type-file(:$dr, :$what, :$pod, :$podname) {
$dr.add-new(
:kind<routine>,
:subkinds($what),
:category<operator>,
:name($operator),
:pod($chunk),
:!pod-is-complete,
Expand Down Expand Up @@ -602,12 +604,12 @@ sub write-index-files($dr) {
}

# XXX: Only handles normal routines, not types nor operators
sub write-sub-index($kind, $subkind) {
say "Writing html/$kind-$subkind.html ...";
spurt "html/$kind-$subkind.html", p2h(pod-with-title(
"Perl 6 {$subkind.tc} {$kind.tc}s",
sub write-sub-index($kind, $category) {
say "Writing html/$kind-$category.html ...";
spurt "html/$kind-$category.html", p2h(pod-with-title(
"Perl 6 {$category.tc} {$kind.tc}s",
pod-table($dr.lookup($kind, :by<kind>)\
.grep({$subkind .subkinds})\ # XXX
.grep({$category .categories})\ # XXX
.categorize(*.name).sort(*.key)>>.value\
.map({
[set(.map: {.subkinds // Nil}).list.join(', '), pod-link(.[0].name, .[0].url), .[0].summary]
Expand All @@ -617,7 +619,7 @@ sub write-index-files($dr) {
}

.&write-main-index for <type routine>;
write-sub-index 'routine', $_ for <sub method term>;
write-sub-index 'routine', $_ for <sub method term operator>;
}

sub write-routine-file($dr, $name) {
Expand Down
8 changes: 6 additions & 2 deletions lib/Perl6/Documentable.pm
@@ -1,7 +1,8 @@
use URI::Escape;
class Perl6::Documentable {
has Str $.kind; # type, language doc, routine, operator
has Str @.subkinds; # class/role/enum, sub/method, prefix/infix/...
has Str $.kind; # type, language doc, routine, module
has Str @.subkinds; # class/role/enum, sub/method, prefix/infix/...
has Str @.categories; # basic type, exception, operator...

has Str $.name;
has Str $.url;
Expand Down Expand Up @@ -37,4 +38,7 @@ class Perl6::Documentable {
!! "/$.kind/$.name"
;
}
method categories() {
@!categories //= @.subkinds
}
}

0 comments on commit ee92b0b

Please sign in to comment.