Skip to content

Commit 9557eb6

Browse files
committed
Adjust htmlify.p6 to account for moved docs
Still needs some abstracting to deal with the hypothetical lib/Routine and lib/Module dirs, but this works fine for now
1 parent de6db9d commit 9557eb6

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

htmlify.p6

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -138,35 +138,41 @@ sub MAIN(Bool :$debug, Bool :$typegraph = False) {
138138
mkdir "html/$_" unless "html/$_".IO ~~ :e;
139139
}
140140

141-
say 'Reading lib/ ...';
142-
my @source = recursive-dir('lib').grep(*.f).grep(rx{\.pod$});
143-
@source .= map: {; .path.subst('lib/', '').subst(rx{\.pod$}, '').subst(:g, '/', '::') => $_ };
141+
my $dr = Perl6::Documentable::Registry.new;
142+
143+
say 'Reading lib/Language ...';
144+
my @lang-doc-sources =
145+
recursive-dir('lib/Language/')\
146+
.map({; .path.subst('lib/Language/', '').subst(rx{\.pod$}, '') => $_ })\
147+
.sort;
148+
149+
say 'Processing Language Pod files ...';
150+
for @lang-doc-sources.kv -> $num, (:key($podname), :value($file)) {
151+
printf "% 4d/%d: % -40s => %s\n", $num, +@lang-doc-sources, $file.path, "language/$podname";
152+
my $pod = EVAL(slurp($file.path) ~ "\n\$=pod")[0];
153+
write-language-file(:$dr, :what<language>, :$pod, :$podname);
154+
}
155+
156+
# TODO: Abstract this duplication
157+
say 'Reading lib/Type ...';
158+
my @type-doc-sources =
159+
recursive-dir('lib/Type/').grep(*.f)\
160+
.map: {; .path.subst('lib/Type/', '').subst(rx{\.pod$}, '').subst(:g, '/', '::') => $_ };
144161

145162
say 'Reading type graph ...';
146163
$tg = Perl6::TypeGraph.new-from-file('type-graph.txt');
147164
{
148165
my %h = $tg.sorted.kv.flat.reverse;
149-
@source .= sort: { %h{.key} // -1 };
166+
@type-doc-sources .= sort: { %h{.key} // -1 };
150167
}
151168

152-
my $dr = Perl6::Documentable::Registry.new;
153-
154-
say 'Processing Pod files ...';
155-
for @source.kv -> $num, $_ {
156-
my $podname = .key;
157-
my $file = .value;
158-
my $what = $podname ~~ /^<[A..Z]> | '::'/ ?? 'type' !! 'language';
159-
printf "% 4d/%d: % -40s => %s\n", $num, +@source, $file.path, "$what/$podname";
160-
169+
# TODO: Abstract this duplication as well
170+
say 'Processing Type Pod files ...';
171+
for @type-doc-sources.kv -> $num, (:key($podname), :value($file)) {
172+
printf "% 4d/%d: % -40s => %s\n", $num, +@type-doc-sources, $file.path, "type/$podname";
161173
my $pod = EVAL(slurp($file.path) ~ "\n\$=pod")[0];
162-
163-
if $what eq 'language' {
164-
write-language-file(:$dr, :$what, :$pod, :$podname);
165-
}
166-
else {
167-
say pod-gist($pod[0]) if $*DEBUG;
168-
write-type-file(:$dr, :$what, :pod($pod[0]), :$podname);
169-
}
174+
say pod-gist($pod[0]) if $*DEBUG;
175+
write-type-file(:$dr, :what<type>, :pod($pod[0]), :$podname);
170176
}
171177

172178
say 'Composing doc registry ...';
File renamed without changes.

0 commit comments

Comments
 (0)