Skip to content

Commit

Permalink
* Do some work with 'mkreport' which should report some statistics
Browse files Browse the repository at this point in the history
  about ic source tree
* Adjustment to visual table properties in CSS
* Minor updates here and there
  • Loading branch information
docelic committed Nov 14, 2007
1 parent 55227f0 commit 361d5b5
Show file tree
Hide file tree
Showing 7 changed files with 258 additions and 185 deletions.
5 changes: 5 additions & 0 deletions Makefile
Expand Up @@ -280,6 +280,11 @@ docbook/autofiles.ent: refxmls
files/infobot/interchange.fact facts: refxmls bin/infobot.facts
bin/infobot.facts

#############################################################
# IC source tree stats
guides/stats.xml: guides/stats-template.xml
bin/mkreport

## Helper target, only used by docelic
#colt-preview:
# tar jcf OUTPUT.tar.bz2 OUTPUT
Expand Down
5 changes: 0 additions & 5 deletions TODO
Expand Up @@ -2,7 +2,6 @@ Bugs:
- work on bin/mkreport
- search doc se nevidi jer je search neki actionmap
- provide static files for download, describe keys like alt+n
- u CVS listi, da je fajl nejm link na CVS
- documentation for bounce and restrict is ignored
- some small error in glossary/pragma at the bottom, [tag pragma]0[/tag]
- see if the files we parse in bin/stattree in block (like parseVendConfig, parseVendInterpolate) allow some stuff to go unaccounted for mkreport
Expand All @@ -21,10 +20,6 @@ Bugs:
- remove NEW from <meta>
- In tags, make XSLT code print position number besides "Yes" word in
positional parameters for tags
- add search box to guides/index.xml
- make See Also only go two or three levels recursively. Currently we do it
until the "chain" ends, which results in having many unrelated options
listed under See Also.
- in search.xml replace mv_ listitems with sections so they're listed in TOC
- note in configuration glossentry to use '' to skip values
- Check ConfigDatabase and DirectiveDatabase. Is description correct? One seems to be wrong
Expand Down
187 changes: 17 additions & 170 deletions bin/mkreport
@@ -1,7 +1,6 @@
#!/usr/bin/perl

# Loads csche dump from stattree and generates statistics
# TODO needs serious work (on producing report.txt file)
# Loads cache dump from stattree and generates statistics

use warnings;
use strict;
Expand Down Expand Up @@ -32,162 +31,40 @@ unless ( GetOptions (
"verbose|v!" => \$verbose,
)) { die "Error parsing options\n" }

@ARGV == 1 or die "Usage: $0 path[/]\n";
@ARGV == 1 or warn "No arguments, assuming sources/cvs-head\n";


my $path = shift;
$path ||= "sources/cvs-head";
( my $dumppath = $path ) =~ s#.+?/##;
( $i{ver} = $dumppath ) =~ s/\/$//;
my $dumpdir = $dumppath;
$dumppath .= "/.cache.bin";
my $sf = 'guides/stats-template.xml';
my $so = 'guides/stats.xml';
my @sf;

# Load DB
loaddb( "$cachedir/$dumppath" );

# First dump leafnodes-to-files
# Hashvalue -> file conversion
my @stack = ();
while (my($k,$v) = each %hash) {
procitem(\@stack, $k,$v);
}

# TODO this needs work
open(OUT, "> $reportdir/$i{ver}/treestats.txt") or
die "Cant write/open report file: $!\n";
select OUT;
O("
== Interchange version $i{ver}
=FILES= ===%=== ===BYTES=== ===%===
Overall:${\( gs() )}
+ Perl code:${\( gs('extensions', [qw/pm pl/], 1) )}
C code:${\( gs('extensions', [qw/c/], 0) )}
HTML pages:${\( gs('extensions', [qw/html/], 0) )}
+ ITL Tags:${\( gs('extensions', [qw/coretag tag/], 1) )}
+ Images:${\( gs('extensions', [qw/png gif jpg/], 1) )}
open IN, "< $sf" or die "Can't rdopen '$sf' ($!)\n";
@sf = <IN>;
close IN or die "Can't rdclose '$sf' ($!)\n";

Text:${\( gs('extensions', [qw/txt/], 0) )}
=KLOCS= ===%===
for (@sf) {
s/(\$hash\{.+\})\s$/$1/gee;
}

+ KLOCS:${\( gs('klocs', [qw/code html coretag tag pod comment/],1) )}
open OUT, "> $so" or die "Can't wropen '$so' ($!)\n";
print OUT @sf;
close OUT or die "Can't wrclose '$so' ($!)\n";

");
close (OUT);
select STDOUT;

for my $p (qw/pragma globvar/) {
my $tfile = '';
open(OUT, "> $reportdir/$i{ver}/total.symbols.$p") or
die "Can't write symbols.$p ($!)\n";
print OUT scalar keys %{ $hash{symbols}{$p} };
close OUT;
while (my ($k,$v) = each %{ $hash{symbols}{$p} } ) {
$tfile .= "$k\n";
for my $fe ( @$v ) {
local $" = ":";
$tfile .= "\t@$fe[0,1] $$fe[2]\n";
local $" = "\t\t";
$tfile .= "\t\t@{@$fe[3]}\n";
}
}
open(OUT, "> $reportdir/$i{ver}/symbols.$p") or
die "Can't write symbols.$p ($!)\n";
print OUT $tfile;
close OUT;
}

exit 0;

#################################################################
# Helpers below

sub gs {
# my $stype = shift;
# my @exts = @{(shift)};
my @stat = (0,0,0,0); # important to initialize, we use $#stat below
# my $extended = shift;
my %estats;
#
$^A = "";
############################################################################
# Helper functions
#
# # BY EXTENSION
# if ( $stype eq 'extensions' ) { # By extension
# if ( @exts ) {
# for my $ext ( @exts ) {
# $estats{$ext}[0] += $h{$stype}{$ext}{files};
# $estats{$ext}[2] += $h{$stype}{$ext}{size};
# $estats{$ext}[1] = sprintf("%.2f", $estats{$ext}[0] /
# $h{total}{files} * 100);
# $estats{$ext}[3] = sprintf("%.2f", $estats{$ext}[2] /
# $h{total}{size} * 100);
#
# $stat[$_] += $estats{$ext}[$_] for (0..$#stat);
# # Fill empty fields with ""
# push @{$estats{$ext}}, "", "", "", "";
# }
#
# } else { # Total statistics
unless ( @_ ) {
@stat = ( $hash{total}{files}, "100.00",
$hash{total}{size}, "100.00",
$hash{total}{lines}, "100.00" );
}
#
# } elsif ( $stype eq 'klocs' ) { # By contents
# @stat = (0, 0);
# if ( @exts ) {
# for my $styp ( @exts ) {
# $estats{$styp}[0] += $h{$stype}{$styp}{lines};
# $estats{$styp}[1] = sprintf("%.2f", $estats{$styp}[0] /
# $h{total}{klocs} * 100);
# $estats{$styp}[0] = sprintf("%.2f", $estats{$styp}[0] / 1000);
#
# # Fill empty fields with ""
# push @{$estats{$styp}}, "", "", "", "";
#
# for my $f (0..$#stat) { $stat[$f] += $estats{$styp}[$f] }
# }
# } else {
# @stat = ( $h{total}{klocs}, "100.00" );
# }
# }
#
# unless ( $stype eq 'klocs' ) {
for (my $i = 0; $i <= $#stat; $i+=2 ) {
( $stat[$i] = reverse $stat[$i] ) =~ s/(.{3})(?!$)/$1,/g;
$stat[$i] = reverse $stat[$i];
}
for my $key ( keys %estats ) {
( $estats{$key}[0] = reverse $estats{$key}[0] ) =~ s/(.{3})(?!$)/$1,/g;
( $estats{$key}[2] = reverse $estats{$key}[2] ) =~ s/(.{3})(?!$)/$1./g;
$estats{$key}[0] = reverse $estats{$key}[0];
$estats{$key}[2] = reverse $estats{$key}[2];
}
# }

# Fill empty fields with ""
push @stat, "", "", "", "";

formline <<'ENDD', @stat;
@>>>>>>> @>>>>>> @>>>>>>>>>> @>>>>>>
ENDD

# if ( $extended ) {
# for my $ext ( @exts ) {
# formline <<'ENDD', $desc{$ext} || $ext, @{$estats{$ext}};
#`@>>>>>>>>>>>:@>>>>>>> @>>>>>> @>>>>>>>>>> @>>>>>>
#ENDD
# }
# }
chomp($^A); $^A
}

sub loaddb {
my $dbpath = shift;

Expand All @@ -209,34 +86,4 @@ sub loaddb {
}
}

# Recursive procedure to find leaf nodes in a hash
# (For hashvalue -> file conversion)
sub procitem {
my ($stack, $key, $val) = @_;

# Ignores:
return if "$key" eq "tree";
return if "$key" eq "symbols";
return if "@$stack" eq "total" and $key eq "matches";

unless (ref $val eq 'HASH') {
$val = join("\n", @$val) if ( ref $val eq 'ARRAY' );
local $" = ".";
# Handle cases like $hash{version}, where it's a toplevel element
# without anything on @$stack.
( my $fout = "@$stack.$key" ) =~ s/^\.//;
open OUT, "> $cachedir/$dumpdir/$fout" or
die "Can't dump $dumpdir/@$stack.$key ($!)\n";
print OUT $val;
close OUT;
} else {
push @$stack, $key;
while (my($k,$v) = each %$val) {
procitem($stack, $k, $v);
}
pop @$stack;
}
}

sub O { print "@_\n"; print STDOUT "@_\n" if $verbose }

2 changes: 0 additions & 2 deletions bin/stattree
Expand Up @@ -946,8 +946,6 @@ sub line_findFunctionName {
$hash{total}{perl_functions}++;
@{ $$c{gfunc} } = ( $1, $$c{lnum} );
}

$hash{total}{functions}++;
}

# Parse Config.pm and take out some great stuff ;-)
Expand Down
4 changes: 2 additions & 2 deletions docbook/xmldocs.css
Expand Up @@ -327,8 +327,8 @@ thead {

.informaltable td {
border: 0.5pt solid black;
padding: 2px;
margin: 0
padding: 0px;
margin: 0px;
}

/*
Expand Down
8 changes: 2 additions & 6 deletions guides/iccattut.xml
Expand Up @@ -87,14 +87,10 @@

<abstract>
<para>
The purpose of this document is to guide you through constructing a simple &IC; catalog <emphasis role='bold'>from scratch</emphasis>. The standard catalogs that ship with Interchange are quite complex since they are ready to be used for business and highlight many of the capabilities that Interchange offers. Those catalogs can be too intimidating<footnote><para>Intimidate: to make timid or fearful; to frighten into submission.</para></footnote> places to start the journey if you're interested in learning the basic Interchange building blocks.
The purpose of this document is to guide you through constructing a simple &IC; catalog <emphasis role='bold'>from scratch</emphasis>. The standard catalogs that ship with Interchange are quite complex since they are ready to be used for business and highlight many of the capabilities that Interchange offers. Those catalogs may not be the right places to start the journey if you're interested in learning the basic Interchange building blocks.
</para> <para>
Although this tutorial provides ready-to-use examples, please <emphasis role='bold'>think</emphasis>
about them (and ideally, retype them instead of copy-pasting to your test catalog). From personal
experience, I can tell you <emphasis role='bold'>re-implementing the catalog manually on your system
is the only proper way to read this tutorial</emphasis>. All the examples serve only to quickly
clarify all your doubts and save the time you'd spend wondering about which style is right
and officially encouraged.
about them (and ideally, retype them instead of copy-pasting to your test catalog).
</para>
</abstract>

Expand Down

0 comments on commit 361d5b5

Please sign in to comment.