[interchange-docs] xmldocs - docelic modified bin/infobot.facts

docs at icdevgroup.org docs at icdevgroup.org
Wed Aug 30 05:08:01 EDT 2006


User:      docelic
Date:      2006-08-30 09:08:01 GMT
Added:     bin      infobot.facts
Log:
- The new script, infobot.facts, reads tmp/*.list files (produced by
  bin/refs-autogen) and creates files/infobot/interchange.fact

  The purpose is to enable Infobot IRC bot (www.infobot.org) to reply
  with pointers to the documentation.

  If you ask for AllowGlobal, it would reply with
  "Config directive: http://www.icdevgroup.org/xmldocs/confs/AllowGlobal.html"

Revision  Changes    Path
1.1                  xmldocs/bin/infobot.facts


rev 1.1, prev_rev 1.0
Index: infobot.facts
===================================================================
#!/usr/bin/perl

# This script reads tmp/*.list files (lists of symbols) and
# creates interchange.fact file which you can load into an
# infobot (www.infobot.org) to provide factoids on IRC channels.

my @files = <tmp/*.list>;
s/tmp\/// for @files;
s/\..*// for @files;
#print "Got @files\n";

my $output = 'files/infobot/interchange.fact';

my $prefix = 'http://www.icdevgroup.org/xmldocs/';

# Some items may be both say, filter and a tag, so we can't
# print directly to file, we need internal stack to sort those out.
my %output;

# Translation to compound names
my %tr = ( 
catconfs     => 'confs',
catvars      => 'vars',
filters      => 'filters',
globconfs    => 'confs',
globvars     => 'vars',
orderchecks  => 'orderchecks',
pragmas      => 'pragmas',
systemtags   => 'tags',
uitags       => 'tags',
usertags     => 'tags',
);

# Translation from compound to "English"
my %trEn = ( 
'confs'        => 'Config directive: ',
'vars'         => 'Variable: ',
'filters'      => 'Filter: ',
'orderchecks'  => 'Ordercheck: ',
'pragmas'      => 'Pragma: ',
'tags'         => 'Tag: ',
);


for my $file ( @ files ) {
	open IN, "< tmp/$file.list" or die "Can't rdopen 'tmp/$file.list' ($!)\n";
	while ($_ = <IN>) {
		chomp;
		my $data = $trEn{$tr{$file}} . $prefix . $tr{$file} . '/' . $_ . '.html';
		push(@{$output{$_}}, $data) unless grep {/^$data$/} @{$output{$_}};
	}
	close IN or die "Can't rdclose 'tmp/$file.list' ($!)\n";
}


open OUT, "> $output" or die "Can't wropen '$output' ($!)\n";
while (my($k,$v) = each %output) {
	$v = join ", ", @$v;
	print OUT "$k => $v\n";
}
close OUT or die "Can't wrclose '$output' ($!)\n";









More information about the docs mailing list