Skip to content

Commit

Permalink
Only start the highlights worker thread when we need to
Browse files Browse the repository at this point in the history
Also make sure the user has run `make init-highlights` by checking if
the coffee executable is in the right location.
  • Loading branch information
samcv committed Jan 11, 2017
1 parent f7ff9b7 commit 47761aa
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions htmlify.p6
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,15 @@ sub MAIN(
# the installation directory (share/man).
#
# Then they can be copied to doc/Programs.
if !$no-highlight and !$no-proc-async {
$proc = Proc::Async.new($coffee-exe, './highlights/highlight-filename-from-stdin.coffee', :r, :w);
$proc-supply = $proc.stdout.lines;
$proc-prom = $proc.start;
if !$no-highlight {
if ! $coffee-exe.IO.f {
say "Could not find $coffee-exe, did you run `make init-highlights`?";
exit 1;
}
if !$no-proc-async {
$proc = Proc::Async.new($coffee-exe, './highlights/highlight-filename-from-stdin.coffee', :r, :w);
$proc-supply = $proc.stdout.lines;
}
}
say 'Creating html/subdirectories ...';

Expand Down Expand Up @@ -959,7 +964,10 @@ sub write-qualified-method-call(:$name!, :$pod!, :$type!) {
}

sub highlight-code-blocks(:$no-proc-async = False) {
say "highlight-code-blocks has been called";
if !$proc.started {
say "Starting highlights worker thread";
$proc-prom = $proc.start;
}
%*POD2HTML-CALLBACKS = code => sub (:$node, :&default) {
for @($node.contents) -> $c {
if $c !~~ Str {
Expand Down

0 comments on commit 47761aa

Please sign in to comment.