Skip to content

Commit

Permalink
Moving functions to library
Browse files Browse the repository at this point in the history
Working towards #19, adding possibly more extensions. The library was
not concerned with them, they were on the script only.

Also #14, since loading was not tested, for instance.
  • Loading branch information
JJ committed May 1, 2018
1 parent 54f7e09 commit 78f6929
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bin/pod2onepage
Expand Up @@ -37,6 +37,7 @@ sub MAIN (Bool :v(:verbose($v)), Str :$source-path = ".", Str :$exclude,
my @toc;
set-foreign-toc(@toc);
put compose-before-content( $title, $html??''!!'x' );
say "Chars ", $source-path.chars;
if $threads > 1 {
put await do start { .&parse-pod-file( next-part-index, .substr($source-path.chars), $precomp, $no-cache, $anchored ) } for sort find-pod-files($source-path, @exclude);
}else{
Expand All @@ -49,6 +50,7 @@ sub find-pod-files ($dir, @exclude) {
state $none-exclude = @exclude.none;
my sub recurse ($dir) {
gather for dir($dir) {
say $_;
take .Str if .Str.ends-with($none-exclude) && .extension ~~ rx:i/pod6$/;
take slip sort recurse $_ if .d && .Str.ends-with($none-exclude);
}
Expand Down
15 changes: 14 additions & 1 deletion lib/Pod/To/BigPage.pm6
Expand Up @@ -68,7 +68,7 @@ class TOC-Counter is export {
}
}

#| Sets up global header and HTML bolierplate
#| Sets up global header and HTML boilerplate
sub setup () is export {
$html-header = q:to/EOH/;
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
Expand Down Expand Up @@ -162,6 +162,19 @@ sub setup () is export {
$html-after-content = '';
}

#| Recursively finds all files for creating the big page
sub find-pod-files ($dir, @exclude, @extensions = <pod6> ) is export {
state $none-exclude = @exclude.none;
my $all-extensions = @extensions.join("|");
my $ending-rx = rx:i/ <$all-extensions> $ /;
my sub recurse ($dir) {
gather for dir($dir) {
take .Str if .Str.ends-with($none-exclude) && .extension ~~ $ending-rx;
take slip sort recurse $_ if .d && .Str.ends-with($none-exclude);
}
}($dir)
}

#| Uses a different table of contents
sub set-foreign-toc (\toc) is export {
@toc := toc;
Expand Down
11 changes: 11 additions & 0 deletions t/00-load.t
@@ -0,0 +1,11 @@
use v6;

use lib 'lib';

use Test;

plan 1;

use-ok 'Pod::To::BigPage';


13 changes: 13 additions & 0 deletions t/000-functions.t
@@ -0,0 +1,13 @@
use v6;

use lib 'lib';

use Test;

plan 1;

use Pod::To::BigPage;

my @files = find-pod-files( ".", <.git .precomp>, <pod6 pm6> );
cmp-ok +@files, ">=", 2, "Found files we wanted to find";

0 comments on commit 78f6929

Please sign in to comment.