Skip to content

Commit 4834c08

Browse files
committed
Use File::Find instead of our own implementation of recursive find
1 parent 33670f6 commit 4834c08

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

lib/DocSite/Generator.pm

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use DocSite::Documentable;
66
use DocSite::Documentable::Registry;
77
use DocSite::TypeGraph::Viz;
88
use DocSite::TypeGraph;
9+
use File::Find;
910
use Pod::Convenience;
1011
use Pod::Htmlify;
1112
use Term::ProgressBar;
@@ -187,41 +188,23 @@ method !process-pod-in (Str $dir) {
187188
@files = @files[^(@files / $!sparse).ceiling];
188189
}
189190

191+
method !process-pod-in (Str $dir) {
190192
self!maybe-say("Reading and processing $dir pod files ...");
193+
my $files = self!find-pod-files-in($dir);
191194
self!run-with-progress(
192-
@files,
195+
$files,
193196
sub ($file) {
194197
self!process-one-pod($file);
195198
}
196199
);
197200
}
198201

199-
method !find-pod-files-in (Str $dir) {
202+
method !find-pod-files-in (Str $in) {
203+
my $dir = $*SPEC.catdir( $!root, 'doc', $in );
200204
self!maybe-say: "Finding pod sources in $dir ...";
201-
return gather {
202-
for self!recursive-files-in($dir) -> $file {
203-
take $file if $file.path ~~ / '.pod' $/;
204-
}
205-
}
206-
}
207-
208-
method !recursive-files-in($dir) {
209-
my @todo = $*SPEC.catdir( $!root, 'doc', $dir );
210-
return gather {
211-
while @todo {
212-
my $d = @todo.shift;
213-
for dir($d) -> $f {
214-
if $f.f {
215-
self!maybe-say: " ... found $f";
216-
take $f;
217-
}
218-
else {
219-
self!maybe-say: " ... descending into $f";
220-
@todo.append( $f.path );
221-
}
222-
}
223-
}
224-
}
205+
my $files = find( :dir($dir), :name( rx{ '.pod' $ } ) ).cache;
206+
self!maybe-say(" ... found $_") for $files.values;
207+
return $files;
225208
}
226209

227210
method !process-one-pod (IO::Path $pod-file) {
@@ -247,8 +230,13 @@ method !run-with-progress ($items, Routine $sub, Str $msg = q{ done}) {
247230
my $prog = Term::ProgressBar.new( :count( $items.elems ), :p )
248231
if $!verbose;
249232

233+
my $to-run =
234+
$!sparse
235+
?? $items.pick( ( $items.list.elems / $!sparse ).ceiling )
236+
!! $items;
237+
250238
my $i = 1;
251-
my $supply = $items.Supply.throttle(
239+
my $supply = $to-run.Supply.throttle(
252240
$!threads,
253241
-> $item {
254242
$sub($item);

0 commit comments

Comments
 (0)