Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Minor regularization of status messages from htmlify.pl
  • Loading branch information
Geoffrey Broadwell committed Aug 31, 2012
1 parent 018e939 commit f1eb292
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions htmlify.pl
Expand Up @@ -4,6 +4,8 @@
# this script isn't in bin/ because it's not meant
# to be installed.

BEGIN say 'Initializing ...';

use Pod::To::HTML;
use URI::Escape;
use lib 'lib';
Expand Down Expand Up @@ -83,6 +85,8 @@ ($pod)

sub MAIN(Bool :$debug, Bool :$typegraph = False) {
$*DEBUG = $debug;

say 'Creating html/ subdirectories ...';
for '', <type language routine images op op/prefix op/postfix op/infix
op/circumfix op/postcircumfix op/listop> {
mkdir "html/$_" unless "html/$_".IO ~~ :e;
Expand All @@ -91,18 +95,17 @@ (Bool :$debug, Bool :$typegraph = False)
say 'Reading lib/ ...';
my @source = recursive-dir('lib').grep(*.f).grep(rx{\.pod$});
@source.=map: {; .path.subst('lib/', '').subst(rx{\.pod$}, '').subst(:g, '/', '::') => $_ };
say '... done';

say "Reading type graph ...";
say 'Reading type graph ...';
$tg = Perl6::TypeGraph.new-from-file('type-graph.txt');
{
my %h = $tg.sorted.kv.flat.reverse;
@source.=sort: { %h{.key} // -1 };
}
say "... done";

my $dr = Perl6::Documentable::Registry.new;

say 'Processing Pod files ...';
for (@source) {
my $podname = .key;
my $file = .value;
Expand Down Expand Up @@ -244,6 +247,7 @@ (Bool :$debug, Bool :$typegraph = False)
spurt "html/$what/$podname.html", p2h($pod);
}

say 'Composing doc registry ...';
$dr.compose;

write-disambiguation-files($dr);
Expand All @@ -252,14 +256,16 @@ (Bool :$debug, Bool :$typegraph = False)
write-type-graph-images(:force($typegraph));
write-search-file($dr);
write-index-file($dr);
say "Writing per-routine files";
say 'Writing per-routine files ...';
my %routine-seen;
for $dr.lookup('routine', :by<kind>).list -> $d {
next if %routine-seen{$d.name}++;
write-routine-file($dr, $d.name);
print '.'
}
say "\ndone writing per-routine files";
say '';

say 'Processing complete.';
}

sub chunks-grep(:$from!, :&to!, *@elems) {
Expand Down Expand Up @@ -335,16 +341,16 @@ (Bool :$debug, Bool :$typegraph = False)
return;
}
}
print "Writing type graph images to html/images/ ";
say 'Writing type graph images to html/images/ ...';
for $tg.sorted -> $type {
my $viz = Perl6::TypeGraph::Viz.new-for-type($type);
$viz.to-file("html/images/type-graph-{$type}.svg", format => 'svg');
$viz.to-file("html/images/type-graph-{$type}.png", format => 'png', size => '8,3');
print '.'
}
say ' done.';
say '';

say "Writing specialized visualizations to html/images/";
say 'Writing specialized visualizations to html/images/ ...';
my %by-group = $tg.sorted.classify(&viz-group);
%by-group<Exception>.push: $tg.types< Exception Any Mu >;
%by-group<Metamodel>.push: $tg.types< Any Mu >;
Expand Down Expand Up @@ -398,7 +404,7 @@ (Bool :$debug, Bool :$typegraph = False)
}

sub write-search-file($dr) {
say "Writing html/search.html";
say 'Writing html/search.html ...';
my $template = slurp("search_template.html");
my @items;
my sub fix-url ($raw) { $raw.substr(1) ~ '.html' };
Expand Down Expand Up @@ -426,7 +432,7 @@ (Bool :$debug, Bool :$typegraph = False)
my %operator_disambiguation_file_written;

sub write-disambiguation-files($dr) {
say "Writing disambiguation files";
say 'Writing disambiguation files ...';
for $dr.grouped-by('name').kv -> $name, $p is copy {
print '.';
my $pod = pod-with-title("Disambiguation for '$name'");
Expand Down Expand Up @@ -470,11 +476,11 @@ (Bool :$debug, Bool :$typegraph = False)
%operator_disambiguation_file_written{$p[0].name} = 1;
}
}
say "... done writing disambiguation files";
say '';
}

sub write-op-disambiguation-files($dr) {
say "Writing operator disambiguation files";
say 'Writing operator disambiguation files ...';
for $dr.lookup('operator', :by<kind>).classify(*.name).kv -> $name, @ops {
next unless %operator_disambiguation_file_written{$name};
my $pod = pod-with-title("Disambiguation for '$name'");
Expand Down Expand Up @@ -518,7 +524,7 @@ (Bool :$debug, Bool :$typegraph = False)
}

sub write-operator-files($dr) {
say "Writing operator files";
say 'Writing operator files ...';
for $dr.lookup('operator', :by<kind>).list -> $doc {
my $what = $doc.subkind;
my $op = $doc.name;
Expand All @@ -535,7 +541,7 @@ (Bool :$debug, Bool :$typegraph = False)
}

sub write-index-file($dr) {
say "Writing html/index.html";
say 'Writing html/index.html ...';
my %routine-seen;
my $pod = pod-with-title('Perl 6 Documentation',
Pod::Block::Para.new(
Expand All @@ -560,7 +566,7 @@ (Bool :$debug, Bool :$typegraph = False)
}

sub write-routine-file($dr, $name) {
say "Writing html/routine/$name.html" if $*DEBUG;
say 'Writing html/routine/$name.html ...' if $*DEBUG;
my @docs = $dr.lookup($name, :by<name>).grep(*.kind eq 'routine');
my $subkind = 'routine';
{
Expand Down

0 comments on commit f1eb292

Please sign in to comment.