Skip to content

Commit ea1ce1f

Browse files
committed
Merge process-pod-source subs
1 parent c5609cc commit ea1ce1f

File tree

2 files changed

+38
-40
lines changed

2 files changed

+38
-40
lines changed

htmlify.p6

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,18 @@ sub MAIN(
132132

133133
process-pod-dir 'Language', :$sparse;
134134
process-pod-dir 'Type', :sorted-by{ %h{.key} // -1 }, :$sparse;
135-
for $*DR.lookup("type", :by<kind>).list {
136-
write-type-source $_;
137-
}
138135

139136
say 'Composing doc registry ...';
140137
$*DR.compose;
141138

139+
for $*DR.lookup("language", :by<kind>).list {
140+
say "Writing language document for {.name} ...";
141+
spurt "html/language/{.filename}.html", p2h(.pod, 'language');
142+
}
143+
for $*DR.lookup("type", :by<kind>).list {
144+
write-type-source $_;
145+
}
146+
142147
write-disambiguation-files if $disambiguation;
143148
write-search-file if $search-file;
144149
write-index-files;
@@ -170,55 +175,48 @@ sub process-pod-dir($dir, :&sorted-by = &[cmp], :$sparse) {
170175

171176
say "Processing $dir Pod files ...";
172177
my $total = +@pod-sources;
173-
my $what = $dir.lc;
174-
for @pod-sources.kv -> $num, (:key($podname), :value($file)) {
175-
printf "% 4d/%d: % -40s => %s\n", $num+1, $total, $file.path, "$what/$podname";
178+
my $kind = $dir.lc;
179+
for @pod-sources.kv -> $num, (:key($filename), :value($file)) {
180+
printf "% 4d/%d: % -40s => %s\n", $num+1, $total, $file.path, "$kind/$filename";
176181
my $pod = EVAL(slurp($file.path) ~ "\n\$=pod")[0];
177-
process-pod-source :$what, :$pod, :$podname, :pod-is-complete;
182+
process-pod-source :$kind, :$pod, :$filename, :pod-is-complete;
178183
}
179184
}
180185

181-
multi process-pod-source(:$what where "language", :$pod, :$podname, :$pod-is-complete) {
182-
my $name = $podname;
186+
sub process-pod-source(:$kind, :$pod, :$filename, :$pod-is-complete) {
183187
my $summary = '';
184-
if $pod.contents[0] ~~ {$_ ~~ Pod::Block::Named and .name eq "TITLE"} {
185-
$name = $pod.contents[0].contents[0].contents[0]
186-
} else {
187-
note "$podname does not have an =TITLE";
188+
my $name = $filename;
189+
if $kind eq "language" {
190+
if $pod.contents[0] ~~ {$_ ~~ Pod::Block::Named and .name eq "TITLE"} {
191+
$name = $pod.contents[0].contents[0].contents[0]
192+
}
193+
else {
194+
note "$filename does not have an =TITLE";
195+
}
188196
}
189197
if $pod.contents[1] ~~ {$_ ~~ Pod::Block::Named and .name eq "SUBTITLE"} {
190198
$summary = $pod.contents[1].contents[0].contents[0];
191199
} else {
192-
note "$podname does not have an =SUBTITLE";
200+
note "$filename does not have an =SUBTITLE";
193201
}
194-
my $origin = $*DR.add-new(
195-
:kind<language>,
196-
:name($name),
197-
:url("/language/$podname"),
198-
:$summary,
199-
:$pod,
200-
:pod-is-complete,
201-
);
202-
find-definitions :$pod, :$origin;
203-
spurt "html/$what/$podname.html", p2h($pod, $what);
204-
}
205202

206-
multi process-pod-source(:$what where "type", :$pod, :$podname, :$pod-is-complete) {
207-
my $type = $tg.types{$podname};
208-
my $summary = '';
209-
if $pod.contents[1] ~~ {$_ ~~ Pod::Block::Named and .name eq "SUBTITLE"} {
210-
$summary = $pod.contents[1].contents[0].contents[0];
211-
} else {
212-
note "$podname does not have an =SUBTITLE";
203+
my %type-info;
204+
if $kind eq "type" {
205+
if $tg.types{$name} -> $type {
206+
%type-info = :subkinds($type.packagetype), :categories($type.categories);
207+
} else {
208+
%type-info = :subkinds<class>;
209+
}
213210
}
214211
my $origin = $*DR.add-new(
215-
:kind<type>,
216-
:subkinds($type ?? $type.packagetype !! 'class'),
217-
:categories($type ?? $type.categories !! Nil),
218-
:$summary,
212+
:$kind,
213+
:$name,
219214
:$pod,
215+
:url("/$kind/$filename"),
216+
:$filename,
217+
:$summary,
220218
:$pod-is-complete,
221-
:name($podname),
219+
|%type-info,
222220
);
223221

224222
find-definitions :$pod, :$origin;

lib/Perl6/Documentable.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Perl6::Documentable {
66

77
has Str $.name;
88
has Str $.url;
9+
has Str $.filename;
910
has $.pod;
1011
has Bool $.pod-is-complete;
1112
has Str $.summary = '';
@@ -27,10 +28,9 @@ class Perl6::Documentable {
2728
}
2829

2930
method filename() {
30-
$.kind eq 'operator'
31+
$!filename //= $.kind eq 'operator'
3132
?? "html/language/operators.html"
32-
!! "html/$.kind/$.name.html"
33-
;
33+
!! "html/$.kind/$.name.html";
3434
}
3535
method url() {
3636
$!url //= $.kind eq 'operator'

0 commit comments

Comments
 (0)