3 # This script reads the syntaces of commands from irssi source tree.
4 # Then it browses through all '.in' files in the current directory and
5 # substitutes '@SYNTAX:foo@' tags with real syntaces found. This data
6 # is written into the corresponding files without the '.in' extension.
7 # For example: help.in -> ../help
9 # This path has to be changed. It should point to your irssi/src directory
10 # Remember to include the asterisk ('*').
13 $FOO = `find src -name '*.c' -exec perl findsyntax.pl \{\} \\; | sed 's/.*SYNTAX: //' > irssi_syntax`;
15 while (<docs/help/in/*.in>) {
22 foreach $DATARIVI (@data) {
23 if ($DATARIVI =~ /\@SYNTAX\:(.+)\@/) {
25 $SYNTAX = `grep \'^$etsittava\' irssi_syntax`;
27 $SYNTAX =~ s/ *$//; $SYNTAX =~ s/ *\n/\n/g;
29 # add %| after "COMMAND SUB " so parameters will indent correctly
30 $SYNTAX =~ s/^([A-Z ]+)/\1%|/;
31 $SYNTAX =~ s/(\n[A-Z ]+)/\1%|/g;
32 # no need for this if there's no parameters
35 } elsif ($DATARIVI =~ /^\S+/) {
36 if ($data[$count+1] =~ /^\S+/) {
38 $DATARIVI =~ s/ *$//g;
42 $DATARIVI =~ s/^\t/ / while ($DATARIVI =~ /^\t/);
47 # must always end with empty line
48 push @data, "\n" if ($data[@data-1] ne "\n");
49 push @data, "\n" if ($data[@data-2] !~ /\n$/);
51 $newfilename = $_; $newfilename =~ s/\.in$//;
52 $newfilename =~ s/\/in\//\//;
53 open (NEWFILE, ">$newfilename");
57 unlink "irssi_syntax";