Skip to content

Commit

Permalink
per kind logic added #32
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniogamiz committed Jul 10, 2019
1 parent f6ec569 commit abc7c09
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Perl6/Documentable/Registry.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use Pod::Utilities::Build;
use Perl6::TypeGraph;
use Pod::To::Cached;
use URI::Escape;
unit class Perl6::Documentable::Registry:ver<0.0.1>;

unit class Perl6::Documentable::Registry:ver<0.0.1>;

=begin pod
Expand Down
40 changes: 40 additions & 0 deletions lib/Perl6/Documentable/To/HTML.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,46 @@ sub source-html($kind, $doc) is export {
p2h($doc.pod, $kind, :pod-path($pod-path));
}

# =================================================================================
# per kind file logic
# =================================================================================

sub generate-kind-files($registry, $kind) is export {
[
$registry.lookup($kind, :by<kind>)
.categorize({.name})
.kv.map: -> $name, @docs {

my @subkinds = @docs.map({slip .subkinds}).unique;
my $subkind = @subkinds == 1 ?? @subkinds[0] !! $kind;
my $pod = pod-with-title(
"$subkind $name",
pod-block("Documentation for $subkind ", pod-code($name), " assembled from the following types:"),
@docs.map({
pod-heading("{.origin.human-kind} {.origin.name}"),
pod-block("From ",
pod-link(.origin.name,
.origin.url ~ '#' ~ (.subkinds~'_' if .subkinds ~~ /fix/) ~
(
if .subkinds ~~ /fix/ { '' }
# It looks really weird, but in reality, it checks the pod content,
# then extracts a link(e.g. '(Type) routine foo'), then this string
# splits by space character and we take a correct category name.
# It works with sub/method/term/routine/*fix types, so all our links
# here are correct.
else {
.pod[0].contents[0].contents.Str.split(' ')[1] ~ '_';
}
) ~ .name.subst(' ', '_')),
),
.pod.list,
})
);
[$name, p2h($pod, $kind)];
}
]
}

# =================================================================================
# Indexing logic
# =================================================================================
Expand Down

0 comments on commit abc7c09

Please sign in to comment.