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 @files = `find src -name '*.c'`;
15 foreach $file (@files) {
19 if (m!/\*.SYNTAX\:! || $state) {
40 while (<docs/help/in/*.in>) {
47 foreach $DATARIVI (@data) {
48 if ($DATARIVI =~ /\@SYNTAX\:(.+)\@/) {
49 $SYNTAX = join "\n", (grep /^\U$1 /, @lines);
50 $SYNTAX .= "\n" if $SYNTAX;
51 $SYNTAX =~ s/ *$//; $SYNTAX =~ s/ *\n/\n/g;
53 # add %| after "COMMAND SUB " so parameters will indent correctly
54 $SYNTAX =~ s/^([A-Z ]+)/\1%|/;
55 $SYNTAX =~ s/(\n[A-Z ]+)/\1%|/g;
56 # no need for this if there's no parameters
59 } elsif ($DATARIVI =~ /^\S+/) {
60 if ($data[$count+1] =~ /^\S+/) {
62 $DATARIVI =~ s/ *$//g;
66 $DATARIVI =~ s/^\t/ / while ($DATARIVI =~ /^\t/);
71 # must always end with empty line
72 push @data, "\n" if ($data[@data-1] ne "\n");
73 push @data, "\n" if ($data[@data-2] !~ /\n$/);
75 $newfilename = $_; $newfilename =~ s/\.in$//;
76 $newfilename =~ s/\/in\//\//;
77 open (NEWFILE, ">$newfilename");