summaryrefslogtreecommitdiff
path: root/lib/WebCoso
diff options
context:
space:
mode:
Diffstat (limited to 'lib/WebCoso')
-rw-r--r--lib/WebCoso/Doc/Base.pm23
-rw-r--r--lib/WebCoso/Maker.pm42
-rw-r--r--lib/WebCoso/Maker/HTML.pm2
-rw-r--r--lib/WebCoso/Maker/RST.pm2
-rw-r--r--lib/WebCoso/Maker/TT.pm2
-rw-r--r--lib/WebCoso/Maker/XHTML.pm2
6 files changed, 56 insertions, 17 deletions
diff --git a/lib/WebCoso/Doc/Base.pm b/lib/WebCoso/Doc/Base.pm
index 46afce8..ab99164 100644
--- a/lib/WebCoso/Doc/Base.pm
+++ b/lib/WebCoso/Doc/Base.pm
@@ -15,15 +15,26 @@ class WebCoso::Doc::Base {
method basename() { ... }
- submethod BUILD(:$wc,:$dir) {
+ submethod BUILD(:$!wc,:$!dir) {
my $basename = self.basename;
- $!tt = WebCoso::Maker::TT.new(:$basename,:$dir,:$wc);
- $!rst = WebCoso::Maker::RST.new(:$basename,:$dir,:$wc);
- $!xhtml = WebCoso::Maker::XHTML.new(:$basename,:$dir,:$wc);
- $!html = WebCoso::Maker::HTML.new(:$basename,:$dir,:$wc);
+ $!tt = WebCoso::Maker::TT.new(:$basename,:$!dir,:$!wc);
+ $!rst = WebCoso::Maker::RST.new(:$basename,:$!dir,:$!wc);
+ $!xhtml = WebCoso::Maker::XHTML.new(:$basename,:$!dir,:$!wc);
+ $!html = WebCoso::Maker::HTML.new(:$basename,:$!dir,:$!wc);
+ }
+
+ method make-by-ext($ext) {
+ say "Doc::Base($.dir/$.basename)::make-by-ext($ext)";
+ given $ext {
+ when 'rest.txt' { return $.tt.make() }
+ when 'du.xml' { return $.rst.make() }
+ when 'xhtml' { return $.xhtml.make() }
+ when 'html' { return $.html.make() }
+ }
}
method make() {
- $.html.get-files();
+ say "Doc::Base($.dir/$.basename)::make";
+ $.make-by-ext('html');
}
}
diff --git a/lib/WebCoso/Maker.pm b/lib/WebCoso/Maker.pm
index 5aae4f8..d5436df 100644
--- a/lib/WebCoso/Maker.pm
+++ b/lib/WebCoso/Maker.pm
@@ -4,16 +4,44 @@ role WebCoso::Maker[$from,$to] {
has $.basename;
has $.dir;
- method process-contents($from-contents) { ... }
+ method process-contents(:$src,:@deps) { ... }
+
+ method dest-files() {
+ say "Maker[$from,$to]($.dir/$.basename)::dest-files";
+ return $.wc.get-files($.dir,$.basename,$to,:!make);
+ }
+
+ method src-files() {
+ say "Maker[$from,$to]($.dir/$.basename)::src-files";
+ return $.wc.get-files($.dir,$.basename,$from);
+ }
+
+ method dep-files() {
+ return Hash;
+ }
+
+ method make() {
+ say "Maker[$from,$to]($.dir/$.basename)::make";
+ my %srcs = $.src-files();
+ my %dsts = $.dest-files();
+ my %deps = $.dep-files();
+
+ say "Maker[$from,$to]($.dir/$.basename)::make from {%srcs.perl} and {%deps.perl} to {%dsts.perl}";
- method get-files() {
- my %srcs = $.wc.get-files($.dir,$.basename,$from);
- my %dsts = $.wc.get-files($.dir,$.basename,$to);
for %srcs.keys -> $lang {
my $src = %srcs{$lang};
- next if %dsts{$lang} and
- %dsts{$lang}.modified after $src.modified;
- my $processed-contents = self.process-contents($src.slurp);
+ my $dst = %dsts{$lang};
+ my @deps = %deps{$lang} // ();
+ say "Maker[$from,$to]($.dir/$.basename)::make lang $lang";
+ next if $dst and $dst.modified after
+ all($src.modified,@depsĀ».modified.flat);
+
+ say "Maker[$from,$to]($.dir/$.basename)::make processing $lang";
+ my $processed-contents = self.process-contents(
+ src => $src.slurp,
+ deps => @depsĀ».slurp,
+ );
+
%dsts{$lang} = $.wc.put-file($.dir,$.basename,$lang,$to,
$processed-contents)
}
diff --git a/lib/WebCoso/Maker/HTML.pm b/lib/WebCoso/Maker/HTML.pm
index 1003cbc..414fe2b 100644
--- a/lib/WebCoso/Maker/HTML.pm
+++ b/lib/WebCoso/Maker/HTML.pm
@@ -1,7 +1,7 @@
# -*- mode: perl6 -*-
use WebCoso::Maker;
class WebCoso::Maker::HTML does WebCoso::Maker['xhtml','html'] {
- method process-contents($xhtml) {
+ method process-contents(:src($xhtml),:@deps) {
return "{$xhtml} decorated";
}
}
diff --git a/lib/WebCoso/Maker/RST.pm b/lib/WebCoso/Maker/RST.pm
index bf75ab1..76bc127 100644
--- a/lib/WebCoso/Maker/RST.pm
+++ b/lib/WebCoso/Maker/RST.pm
@@ -1,7 +1,7 @@
# -*- mode: perl6 -*-
use WebCoso::Maker;
class WebCoso::Maker::RST does WebCoso::Maker['rest.txt','du.xml'] {
- method process-contents($rst) {
+ method process-contents(:src($rst),:@deps) {
return "{$rst} parsed";
}
}
diff --git a/lib/WebCoso/Maker/TT.pm b/lib/WebCoso/Maker/TT.pm
index eb5e390..256cf54 100644
--- a/lib/WebCoso/Maker/TT.pm
+++ b/lib/WebCoso/Maker/TT.pm
@@ -1,7 +1,7 @@
# -*- mode: perl6 -*-
use WebCoso::Maker;
class WebCoso::Maker::TT does WebCoso::Maker['tt','rest.txt'] {
- method process-contents($tt) {
+ method process-contents(:src($tt),:@deps) {
return "{$tt} expanded";
}
}
diff --git a/lib/WebCoso/Maker/XHTML.pm b/lib/WebCoso/Maker/XHTML.pm
index d33c447..c2b1d9e 100644
--- a/lib/WebCoso/Maker/XHTML.pm
+++ b/lib/WebCoso/Maker/XHTML.pm
@@ -1,7 +1,7 @@
# -*- mode: perl6 -*-
use WebCoso::Maker;
class WebCoso::Maker::XHTML does WebCoso::Maker['du.xml','xhtml'] {
- method process-contents($du) {
+ method process-contents(:src($du),:@deps) {
return "{$du} converted";
}
}