Skip to content

Commit c5609cc

Browse files
committed
Merge write-routine-file and write-syntax-file
1 parent d0f3d01 commit c5609cc

File tree

1 file changed

+26
-51
lines changed

1 file changed

+26
-51
lines changed

htmlify.p6

Lines changed: 26 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,9 @@ sub MAIN(
128128
say 'Reading type graph ...';
129129
$tg = Perl6::TypeGraph.new-from-file('type-graph.txt');
130130
my %h = $tg.sorted.kv.flat.reverse;
131+
write-type-graph-images(:force($typegraph));
131132

132133
process-pod-dir 'Language', :$sparse;
133-
write-type-graph-images(:force($typegraph));
134-
# XXX: Generalize
135134
process-pod-dir 'Type', :sorted-by{ %h{.key} // -1 }, :$sparse;
136135
for $*DR.lookup("type", :by<kind>).list {
137136
write-type-source $_;
@@ -144,19 +143,9 @@ sub MAIN(
144143
write-search-file if $search-file;
145144
write-index-files;
146145

147-
say 'Writing per-routine files ...';
148-
for $*DR.lookup('routine', :by<kind>).unique(:as{.name}) -> $d {
149-
write-routine-file($d.name);
150-
print '.'
146+
for <routine syntax> -> $kind {
147+
write-kind $kind;
151148
}
152-
say '';
153-
154-
say 'Writing per-syntactic-feature files ...';
155-
for $*DR.lookup('syntax', :by<kind>).unique(:as{.name}).list -> $d {
156-
write-syntax-file($d.name);
157-
print '.'
158-
}
159-
say '';
160149

161150
say 'Processing complete.';
162151
if $sparse || !$search-file || !$disambiguation {
@@ -673,43 +662,29 @@ sub write-sub-index(:$kind, :$category, :&summary = {Nil}) {
673662
), $kind);
674663
}
675664

676-
sub write-routine-file($name) {
677-
say 'Writing html/routine/$name.html ...' if $*DEBUG;
678-
my @docs = $*DR.lookup($name, :by<name>).grep(*.kind eq 'routine');
679-
my $subkind = 'routine';
680-
{
681-
my @subkinds = @docs>>.subkinds;
682-
$subkind = @subkinds[0] if all(@subkinds>>.defined) && [eq] @subkinds;
683-
}
684-
my $pod = pod-with-title("Documentation for $subkind $name",
685-
pod-block("Documentation for $subkind $name, assembled from the
686-
following types:"),
687-
@docs.map({
688-
pod-heading("{.origin.human-kind} {.origin.name}"),
689-
pod-block("From ", pod-link(.origin.name, .origin.url ~ '#' ~ (.subkinds~'_' if .subkinds ~~ /fix/) ~ .name)),
690-
.pod.list,
691-
})
692-
);
693-
spurt "html/routine/$name.html", p2h($pod, 'routine');
694-
}
695-
696-
sub write-syntax-file($name) {
697-
say 'Writing html/syntax/$name.html ...' if $*DEBUG;
698-
my @docs = $*DR.lookup($name, :by<name>).grep(*.kind eq 'syntax');
699-
my $subkind = 'syntactic feature';
700-
{
701-
my @subkinds = @docs>>.subkinds;
702-
$subkind = @subkinds[0] if all(@subkinds>>.defined) && [eq] @subkinds;
703-
}
704-
my $pod = pod-with-title("Documentation for $subkind $name",
705-
pod-block("Documentation for $subkind $name"),
706-
@docs.map({
707-
pod-heading("{.origin.human-kind} {.origin.name}"),
708-
pod-block("From ", pod-link(.origin.name, .origin.url ~ '#' ~ (.subkinds~'_' if .subkinds ~~ /fix/) ~ .name)),
709-
.pod.list,
710-
})
711-
);
712-
spurt "html/syntax/$name.subst(/<[/\\]>/,'_',:g).html", p2h($pod, 'syntax');
665+
sub write-kind($kind) {
666+
say "Writing per-$kind files ...";
667+
$*DR.lookup($kind, :by<kind>)\
668+
.categorize({.name})\
669+
.kv.map: -> $name, @docs {
670+
my @subkinds = @docs.map({.subkinds}).unique;
671+
my $subkind = @subkinds.elems == 1 ?? @subkinds.list[0] !! $kind;
672+
my $pod = pod-with-title(
673+
"Documentation for $subkind $name",
674+
pod-block("Documentation for $subkind $name, assembled from the following types:"),
675+
@docs.map({
676+
pod-heading("{.origin.human-kind} {.origin.name}"),
677+
pod-block("From ",
678+
pod-link(.origin.name,
679+
.origin.url ~ '#' ~ (.subkinds~'_' if .subkinds ~~ /fix/) ~ .name),
680+
),
681+
.pod.list,
682+
})
683+
);
684+
print '.';
685+
spurt "html/$kind/$name.subst(/<[/\\]>/,'_',:g).html", p2h($pod, $kind);
686+
}
687+
say '';
713688
}
714689

715690
sub write-qualified-method-call(:$name!, :$pod!, :$type!) {

0 commit comments

Comments
 (0)