- if (! exists $oldpagemtime{$page} ||
- mtime(srcfile($file)) > $oldpagemtime{$page}) {
- debug("rendering changed file $file");
- render($file);
- $rendered{$file}=1;
+ my $mtime=mtime(srcfile($file));
+ if (! exists $pagemtime{$page} ||
+ $mtime > $pagemtime{$page} ||
+ $forcerebuild{$page}) {
+ $pagemtime{$page}=$mtime;
+ if (isinternal($page)) {
+ push @internal, $file;
+ # Preprocess internal page in scan-only mode.
+ preprocess($page, $page, readfile(srcfile($file)), 1);
+ }
+ else {
+ push @needsbuild, $file;
+ }
+ }
+ }
+ run_hooks(needsbuild => sub { shift->(\@needsbuild) });
+
+ # scan and render files
+ foreach my $file (@needsbuild) {
+ debug(sprintf(gettext("scanning %s"), $file));
+ scan($file);
+ }
+ calculate_backlinks();
+ foreach my $file (@needsbuild) {
+ debug(sprintf(gettext("rendering %s"), $file));
+ render($file);
+ $rendered{$file}=1;
+ }
+ foreach my $file (@internal) {
+ # internal pages are not rendered
+ my $page=pagename($file);
+ delete $depends{$page};
+ foreach my $old (@{$renderedfiles{$page}}) {
+ delete $destsources{$old};