1#!/usr/bin/perl -w
2
3# Makes the apps/index.html web page
4# Creates the command lines include files: .ione, .ihelp, .itable
5# Warns of missing documentation pages
6# Updates the doc/programs/{text,html} files in the CVS tree
7
8###############################################################################
9#
10# To be done
11# ==========
12#
13# programs/html version to have separate embassy directories
14# emboss_doc/master with inc subdirectory for templates (or programs/master)
15# emboss_doc/html and emboss_doc/text for the outputs
16# to be installed as /emboss/apps and /embassy/*/
17# and on sourceforge as /apps/release/N.N/emboss/apps etc. or /apps/cvs/
18#
19# Use these as the master copy to create the ~/sfdoc versions
20#
21# need to update included html for emboss and for embassy packages
22#
23# check emboss.cvs for files that need to be added - do not assume
24# the cvs add will be run
25#
26# Why did domainatrix files get updated as zero length when the tests failed?
27#
28# Skeleton version for sourceforge apps directory (for Jemboss)
29#
30# embassy docs - /apps/ redirect (checked)
31#     and embassy/*/ main pages (not yet checked?)
32#
33# plotorf copies plotorf.gif 3 times in 2 tests
34#
35# need to check new docs are created when new applications appear with
36# master docs
37#
38#
39# Changes needed for SourceForge version
40# ======================================
41# need to be better at identifying and fixing embassy missing documentation
42# Need to check for EFUNC and EDATA HTML file updates with main server
43#     including the index.html pages
44###############################################################################
45
46##################################################################
47#
48# Definitions and global variables
49#
50##################################################################
51
52
53my %progdone = ();  # key=program name,
54                    # value = set to 1 if documentation exists
55my %progdir = ();   # key=program name,
56                    # value = EMBASSY name if EMBASSY program
57
58my $embassy;	    # name of current EMBASSY directory being done,
59                    # "" if not an EMBASSY program
60my $docdir;	    # name of directory holding the set of EMBASSY programs
61                    # being done for local distribution
62
63# read in from the EMBOSS application 'wossname'
64# group names, application name and which application is in which groups
65my %grpnames;	    # hash of key=lowercase group name,
66                    # value = uppercase group description
67my %progs;	    # hash of key=program name, value = description
68my %groups;	    # hash of key=lowercase group name, value = program names
69my %embassyprogs;   # hash of embassy package names for each program
70my %missingdoc;     # hash of missing program documentation.
71                    # Value is the directory it should be in
72
73# where the URL for the html pages is
74my $url = "http://emboss.sourceforge.net/apps/cvs";
75my $urlembassy = "http://emboss.sourceforge.net/embassy";
76
77# where the original distribution lives
78my $distribtop = "./";
79
80# where the installed package lives
81my $installtop = "./";
82
83open (VERS, "embossversion -full -auto|") || die "Cannot run embossversion";
84while (<VERS>) {
85    if(/InstallDirectory: +(\S+)/) {
86	$installtop = $1;
87	$installtop =~ s/\/$//;
88    }
89    if(/BaseDirectory: +(\S+)/) {
90	$distribtop = $1;
91	$distribtop =~ s/\/$//;
92    }
93}
94close VERS;
95
96# where the CVS tree program doc pages are
97my $cvsdoc = "$distribtop/doc/programs";
98my $cvsedoc = "$distribtop/embassy";
99
100# where the CVS tree scripts are
101my $scripts = "$distribtop/scripts";
102
103# where the web pages live
104my $doctop = "$cvsdoc/master/emboss/apps";
105my $sfdoctop = "$ENV{HOME}/sfdoc/apps/cvs";
106
107my @embassylist = ("appendixd",
108		   "cbstools",
109		   "clustalomega",
110		   "domainatrix",
111		   "domalign",
112		   "domsearch",
113		   "emnu",
114		   "esim4",
115		   "hmmer",
116		   "hmmernew",
117		   "iprscan",
118		   "meme",
119		   "memenew",
120		   "mira",
121		   "mse",
122		   "myemboss", # we avoid documenting these examples
123		   "myembossdemo", # we avoid documenting these examples
124		   "phylip",
125		   "phylipnew",
126		   "signature",
127		   "structure",
128		   "topo",
129		   "vienna",	# old vienna
130		   "vienna2",
131		   );
132
133# the directories containing web pages - EMBOSS and EMBASSY
134my @doclist = (
135	       "$doctop"
136	       );
137
138# Filenames for cvs add and commit commands.
139# These hold a list of the names of files to be added/committed
140# to the text or html documentation directories
141# This is done at the end of the script
142my $cvsdochtmladd = '';
143my $cvsdochtmlcommit = '';
144my $cvsdoctextadd = '';
145my $cvsdoctextcommit = '';
146my $badlynx = 0;
147my $badsrc = 0;
148
149######################################################################
150######################################################################
151#
152# SUBROUTINES
153#
154######################################################################
155######################################################################
156
157######################################################################
158#
159# Name: usage
160#
161# Description:
162#       Reports command line options
163#
164######################################################################
165
166sub usage () {
167  print STDERR "Usage:\n";
168  print STDERR "  autodoc.pl -create -embassy=package [appname]\n";
169  print STDERR "\n";
170  print STDERR "Default is to produce docuemntation for all applications\n";
171  exit();
172}
173######################################################################
174#
175# Name: htmlsource
176#
177# Description:
178#	resolves #include directives from template
179#       to make a simple html file
180#
181# Args:
182# 	$tfile - HTML template filename
183# 	$edir  - EMBASSY or emboss application dir for includes
184#
185# Warning:
186#	uses temporary filename 'x.x'
187#
188######################################################################
189sub htmlsource ( $$ ) {
190    my($tfile, $edir) = @_;
191    @giffiles = ();
192    open (X, ">x.x") || die "Cannot open temporary file x.x";
193
194    open (H, "$edir/$tfile") ||
195	die "Cannot open HTML template file '$edir/$tfile'";
196
197    while (<H>) {
198	if(/^\s*Function\s*$/) {
199	    print X "Wiki\n";
200	    print X "</H2>\n";
201	    print X "\n";
202	    print X "The master copies of EMBOSS documentation are available\n";
203	    print X "at <a href=\"http://emboss.open-bio.org/wiki/Appdocs\">\n";
204	    print X "http://emboss.open-bio.org/wiki/Appdocs</a>\n";
205	    print X "on the EMBOSS Wiki.\n";
206	    print X "\n";
207	    print X "<p>\n";
208	    print X "Please help by correcting and extending the Wiki pages.\n";
209	    print X "\n";
210	    print X "<H2>\n";
211	}
212	if (/[<][\!][-][-][\#]include file=\"([^\"]+)\" +[-][-][>]/) {
213	    $ifile = $1;
214	    if(-e "$edir/$ifile") {
215		open (I, "$edir/$ifile") ||
216		    die "Cannot open include file '$edir/$ifile'";
217		while (<I>) {
218		    print X;
219		    if(/<p><img src=\"([^\"]+)\" alt=\"\[\S+ results\]\">/){
220			push @giffiles, $1;
221		    }
222		}
223		close I;
224	    }
225	    else {
226		print STDERR "Cannot open include file '$edir/$ifile'\n";
227		print X "[an error has occurred processing this directive]\n";
228	    }
229	    next;
230	}
231	elsif (/[<][\!][-][-][\#]include virtual=\"\/apps\/([^\"]+)\" +[-][-][>]/) {
232	    $ifile = $1;
233	    if(-e "$cvsdoc/master/emboss/apps/$ifile") {
234		open (I, "$cvsdoc/master/emboss/apps/$ifile") ||
235		    die "Cannot open include file '$cvsdoc/master/emboss/apps/$ifile'";
236		while (<I>) {print X}
237		close I;
238	    }
239	    else {
240		print STDERR "Cannot open virtual file '$cvsdoc/master/emboss/apps/$ifile'\n";
241		print X "[an error has occurred processing this directive]\n";
242	    }
243	    next;
244	}
245	else {print X}
246    }
247    close X;
248    close H;
249    return 1;
250}
251
252######################################################################
253#
254# Name: cleantext
255#
256# Description:
257#	removes unwanted acdtable output from text documentation
258#	makes sure seealso output is reasonably spaced
259#
260# Args:
261# 	$afile - first filename
262#
263# Returns:
264# Warning:
265#	uses temporary filename 'z.z'
266#
267######################################################################
268sub cleantext ( $ ) {
269    my $seealso = 0;
270    my ($afile) = @_;
271    if(-e $afile) {
272	open (X, $afile);
273	open (Z, ">z.z");
274	my $acdtable = 0;
275	while (<X>) {
276	    if(/^See also$/) {
277		    $seealso = 1;
278		}
279	    if(/^Author[\(s\)]$/) {
280		    $seealso = 0;
281		}
282	    if($acdtable) {
283		if(/^Input file format$/) {
284		    $acdtable = 0;
285		}
286		if(/^Output file format$/) {
287		    $acdtable = 0;
288		}
289
290		if(/^Data files$/) {
291		    $acdtable = 0;
292		}
293
294	    }
295	    else {
296		if(/^\s+Qualifier Type Description Allowed values Default/) {
297		    $acdtable = 1;
298		}
299	    }
300	    if($seealso) {
301		if(/   Program name Description/) {
302		    $seealso = 2;
303		    s/Program name Description/Program name     Description/;
304		}
305		else {
306		    if(/^(\s+)(\S+) ([A-Z])/) {
307			$name = sprintf "%-16s", $2;
308			s/^(\s+)(\S+) ([A-Z])/$1$name $3/;
309		    }
310		    else {
311			s/^  /                   /;
312		    }
313		}
314		if(/^$/ && $seealso == 2) {$seealso = 0}
315	    }
316
317	    if(!$acdtable) { print Z }
318	}
319    }
320    close X;
321    close Z;
322    open (X, ">$afile");
323    open (Z, "z.z");
324    while (<Z>) {
325	print X;
326    }
327    close X;
328    close Z;
329
330}
331
332######################################################################
333#
334# Name: filediff
335#
336# Description:
337#	runs diff on two files and returns 1 if they differ
338#
339# Args:
340# 	$afile - first filename
341# 	$bfile - second filename
342#
343# Returns:
344#       "replaced" file differed and was replaced
345#       "created"  file did not exist and was created
346#       "same"     files were identical in size and content
347# Warning:
348#	uses temporary filename 'z.z'
349#
350######################################################################
351sub filediff ( $$ ) {
352    my ($afile, $bfile) = @_;
353 $s = 0;
354    my $action = "";
355
356    if(-e $afile) {
357	if ((-s $afile) !=  (-s $bfile)) {
358	    print LOG "$afile " . (-s $afile) . ", $bfile " . (-s $bfile) . "\n";
359	}
360	system ("diff -b $afile $bfile > z.z");
361	$s = (-s "z.z");
362	if ($s) {
363	    print LOG "$afile ** differences ** size:$s\n";
364	    open (DIF, "z.z") || die "cannot open diff output file";
365	    while (<DIF>) { print LOG "> $_";}
366	    close DIF;
367	    $action = "replaced";
368	}
369	unlink "z.z";
370    }
371    else {
372	$s = (-s $bfile);
373	$action = "created";
374	$cvsdochtmladd .= " $afile";
375    }
376
377    if($s) {
378	system "cp $bfile $afile";
379	chmod 0664, "$afile";
380	unlink "$bfile";
381	print "$afile *$action*\n";
382	print LOG "$afile *$action*\n";
383	$cvsdochtmlcommit .= " $afile";
384    }
385    return $s;
386}
387
388
389######################################################################
390#
391# Name: header1
392#
393# Description:
394#	prints out the first part of the HTML header text (before title)
395#
396# Args:
397# 	*OUT - filehandle to print to
398#
399#
400######################################################################
401sub header1 (*) {
402    local (*OUT) = @_;
403
404    print OUT "
405<HTML>
406
407<HEAD>
408  <TITLE>
409  EMBOSS
410  </TITLE>
411</HEAD>
412<BODY BGCOLOR=\"#FFFFFF\" text=\"#000000\">
413
414
415<!--#include file=\"header1.inc\" -->
416";
417
418}
419
420
421######################################################################
422#
423# Name: header2
424#
425# Description:
426#	prints out the second part of the HTML header text (after title)
427#
428# Args:
429# 	*OUT - filehandle to print to
430#
431#
432######################################################################
433sub header2 (*) {
434    local (*OUT) = @_;
435
436    print OUT "
437<!--#include file=\"header2.inc\" -->
438
439<!--END OF HEADER-->
440
441
442
443
444";
445}
446
447
448
449######################################################################
450#
451# Name: footer
452#
453# Description:
454#	ends an HTML page
455#
456# Args:
457# 	*OUT - filehandle to print to
458#
459#
460######################################################################
461sub footer (*) {
462    local (*OUT) = @_;
463    print OUT "
464
465</BODY>
466</HTML>
467";
468}
469
470
471######################################################################
472#
473# Name: indexheader
474#
475# Description:
476# 	prints out the header and text at the start of the file
477#	containing the table of applications.
478#
479# Args:
480#	*OUT - filehandle to print to
481#
482#
483######################################################################
484sub indexheader (*) {
485    local (*OUT) = @_;
486
487    print OUT "
488<HTML>
489
490<HEAD>
491  <TITLE>
492  EMBOSS: The Applications (programs)
493  </TITLE>
494</HEAD>
495<BODY BGCOLOR=\"#FFFFFF\" text=\"#000000\">
496
497
498
499<table align=center border=0 cellspacing=0 cellpadding=0>
500<tr><td valign=top>
501<A HREF=\"http://emboss.sourceforge.net/\" ONMOUSEOVER=\"self.status='Go to the EMBOSS home page';return true\">
502<img border=0 src=\"/emboss_icon.jpg\" alt=\"\" width=150 height=48></a>
503</td>
504<td align=left valign=middle>
505<b><font size=\"+6\">
506The Applications (programs)
507</font></b>
508</td></tr>
509</table>
510<br>&nbsp;
511<p>
512
513
514
515
516The programs are listed in alphabetical order, Look at the individual
517applications or go to the
518<a href=\"groups.html\">GROUPS</a>
519page to search by category.
520<p>
521
522<a href=\"../../embassy/index.html\">EMBASSY applications</a>
523are described in separate documentation for each package.
524
525<h3><A NAME=\"current\">Applications</A> in the <a
526href=\"ftp://emboss.open-bio.org/pub/EMBOSS/\">current release</a></h3>
527
528<table border cellpadding=4 bgcolor=\"#FFFFF0\">
529
530<tr>
531<th>Program name</th>
532<th>Description</th>
533</tr>
534
535";
536
537}
538
539######################################################################
540#
541# Name: indexfooter
542#
543# Description:
544# 	print out the end of the table for the file
545#       containing the table of applications.
546#
547# Args:
548# 	*OUT - filehandle to print to
549#
550#
551######################################################################
552sub indexfooter (*) {
553    local (*OUT) = @_;
554
555    print OUT "
556
557</table>
558
559
560
561
562</BODY>
563</HTML>
564";
565}
566
567######################################################################
568#
569# Name: getprogramnames
570#
571# Description:
572# 	Runs wossname to get the EMBOSS programs on the path
573#	together with their groups
574#
575# Args:
576#   *** These are all global variables ***
577# 	%grpnames - hash of key=lowercase group name,
578#                        value = uppercase group description
579# 	%progs - hash of key=program name, value = program description
580#	%groups - hash of key=lowercase group name, value = program names
581#
582######################################################################
583
584sub getprogramnames ( ) {
585
586    my $prog;	# program name
587    my $capgrp;	# uppcase group name
588    my $grp;	# lowercase group name
589
590    open (PROGS, "wossname -noembassy -auto |") ||
591	die "Cannot run wossname";
592    while ($prog = <PROGS>) {
593	if ($prog =~ /^\s*$/) {	# ignore blank lines
594	    next;
595	} elsif ($prog =~ /^([A-Z0-9 ]+)$/) {	# uppcase means a group name
596	    $capgrp = $1;
597	    $grp = lc($capgrp);
598	    $grp =~ s/ +/_/g;		# lowercase one-word group_name
599	    $grpnames{$grp} = $capgrp;
600#      print "Group $grp = $capgrp\n";
601	} elsif ($prog =~ /^(\S+) +(.*)/) {
602	    $progs{$1} = $2;
603	    $groups{$grp} .= "$1 ";
604#      print "Program in $grp = $1\n";
605	}
606    }
607    close PROGS;
608
609    foreach $e(@embassylist) {
610	open (PROGS, "wossname -showembassy $e -auto |") ||
611	    die "Cannot run wossname";
612	while ($prog = <PROGS>) {
613	    if ($prog =~ /^\s*$/) {	# ignore blank lines
614		next;
615	    } elsif ($prog =~ /^([A-Z0-9 ]+)$/) {  # uppcase means a group name
616		$capgrp = $1;
617		$grp = lc($capgrp);
618		$grp =~ s/ +/_/g;		# lowercase one-word group_name
619		$grpnames{$grp} = $capgrp;
620#      print "Group $grp = $capgrp\n";
621	    } elsif ($prog =~ /^(\S+) +(.*)/) {
622		$progs{$1} = $2;
623		$groups{$grp} .= "$1 ";
624		$embassyprogs{$1} = $e;
625#      print "Program in $grp = $1\n";
626	    }
627	}
628	close PROGS;
629    }
630
631}
632
633
634######################################################################
635#
636# Name: createnewdocumentation
637#
638# Description:
639# 	Asks if the user wishes to create and edit new documentation
640#	for a program.
641#	If so, the template file is copied and the user's favorite
642#	editor is started.
643#
644# Args:
645# 	$thisprogram - the name of the program
646#	$docdir - the location of the web pages
647#
648#
649# Returns:
650#	1 if the document is created and edited
651#	0 if no document is created
652#
653######################################################################
654
655sub createnewdocumentation ( $$$ ) {
656
657    my ($thisprogram, $progdocdir, $sfprogdocdir) = @_;
658    my $ans;
659    my $indexfile = "$progdocdir/index.html";
660
661# application's document is missing
662    print LOG "createnewdocumentation missing $progdocdir/$thisprogram.html\n";
663    print "\n$progdocdir/$thisprogram.html =missing=\n";
664    print STDERR "\n$progdocdir/$thisprogram.html =missing=\n";
665    if ($doccreate) {
666	print STDERR "Create a web page for this program? (y/n) ";
667	$ans = <STDIN>;
668    }
669    else {
670	$ans = "skip";
671	print STDERR "Create later - run with create on commandline\n";
672    }
673    if ($ans =~ /^y/) {
674        system("cp $progdocdir/template.html.save $progdocdir/$thisprogram.html");
675        system "perl -p -i -e 's/ProgramNameToBeReplaced/$thisprogram/g;' $progdocdir/$thisprogram.html";
676	chmod 0664, "$progdocdir/$thisprogram.html";
677	if (defined $ENV{'EDITOR'} && $ENV{'EDITOR'} ne "") {
678	    print STDERR "Generated $thisprogram.html:
679	    Fill in the description section
680	    Describe the input and output
681	    Add notes, references
682";
683	    system("$ENV{'EDITOR'} $progdocdir/$thisprogram.html");
684	    open (INDEX2, ">> $indexfile") || die "Cannot open $indexfile\n";
685	    print INDEX2 "
686
687<tr><td><a href=\"$thisprogram.html\">$thisprogram</a></td><td>
688$progs{$thisprogram}
689</td></tr>
690
691";
692	    close (INDEX2);
693	    print STDERR "Edit $progdocdir/index.html:
694	    Look for $thisprogram line (at end)
695	    Move $thisprogram line to be in alphabetic order
696";
697	    system("$ENV{'EDITOR'} $progdocdir/index.html");
698	}
699	else {
700	    print "*********************************
701
702YOU DO NOT HAVE AN EDITOR DEFINED
703REMEMBER TO EDIT THESE FILES:
704 $progdocdir/$thisprogram.html
705 $indexfile\n\n\n";
706	}
707        return 1;
708    }
709    else {
710	$missingdoc{$thisprogram} = $progdocdir;
711	return 0;
712    }
713}
714
715######################################################################
716#
717# Name: createnewdocumentationembassy
718#
719# Description:
720# 	Asks if the user wishes to create and edit new documentation
721#	for an embassy program.
722#	If so, the top level redirect is created, and then
723#       the embassy template file is copied and the user's favorite
724#	editor is started.
725#
726# Args:
727# 	$thisprogram - the name of the program
728#	$progdocdir - the location of the web pages
729#
730#
731# Returns:
732#	1 if the document is created and edited
733#	0 if no document is created
734#
735######################################################################
736
737sub createnewdocumentationembassy ( $$$ ) {
738
739    my ($thisprogram, $progdocdir, $sfprogdocdir) = @_;
740    my $ans;
741    my $indexfile = "$progdocdir/index.html";
742
743# application's document is missing
744    print LOG "createnewdocumentationembassy missing $progdocdir/$thisprogram.html\n";
745    print "\n$progdocdir/$thisprogram.html =missing=\n";
746    print STDERR "\n$progdocdir/$thisprogram.html =missing=\n";
747    print STDERR "Create a web page for this program? (y/n) ";
748    if ($doccreate) {
749	print STDERR "Create a web page for this program? (y/n) ";
750	$ans = <STDIN>;
751    }
752    else {
753	$ans = "skip";
754	print STDERR "Create later - run with create on commandline\n";
755    }
756    if ($ans =~ /^y/) {
757        system("cp $progdocdir/template.html.save $progdocdir/$thisprogram.html");
758        system "perl -p -i -e 's/ProgramNameToBeReplaced/$thisprogram/g;' $progdocdir/$thisprogram.html";
759	chmod 0664, "$progdocdir/$thisprogram.html";
760	if (defined $ENV{'EDITOR'} && $ENV{'EDITOR'} ne "") {
761	    print STDERR "Generated $thisprogram.html:
762	    Fill in the description section
763	    Describe the input and output
764	    Add notes, references
765";
766	    system("$ENV{'EDITOR'} $progdocdir/$thisprogram.html");
767	    open (INDEX2, ">> $indexfile") || die "Cannot open $indexfile\n";
768	    print INDEX2 "
769
770<tr>
771<td><a href=\"$thisprogram.html\">$thisprogram</a></td>
772<td>
773$progs{$thisprogram}
774</td>
775</tr>
776";
777	    close (INDEX2);
778	    print STDERR "Edit $progdocdir/index.html:
779	    Look for $thisprogram line (at end)
780";
781	    system("$ENV{'EDITOR'} $progdocdir/index.html");
782	}
783	else {
784	    print "*********************************
785
786YOU DO NOT HAVE AN EDITOR DEFINED
787REMEMBER TO EDIT THESE FILES:
788 $progdocdir/$thisprogram.html
789 $indexfile\n\n\n";
790	}
791        return 1;
792    }
793    else {
794	$missingdoc{$thisprogram} = $progdocdir;
795	return 0;
796    }
797}
798
799######################################################################
800#
801# Name: checkincludefile
802#
803# Description:
804# 	This checks for the existence of one of several types of include file
805#	If the file doesn't exist, it is created from the 'x.x' file.
806#	If the file exists, a new one is created and checked to see if it
807#	is different to the old one, if different, it is updated
808#	This assumes that the file 'x.x' has just been set up with the
809#	new include file contents.
810#
811# Args:
812# 	$thisprogram - the name of the program
813#	$docdir - the location of the web pages
814#	$ext - extension of the include file
815#
816#
817######################################################################
818
819sub checkincludefile ( $$$ ) {
820
821    my ($thisprogram, $docdir, $ext) = @_;
822
823
824# check to see if the include file has changed
825    filediff ("$docdir/inc/$thisprogram.$ext", "x.x");
826}
827
828
829
830######################################################################
831#
832# Name: checkhistoryfile
833#
834# Description:
835# 	This checks for the existence of a history file.
836#       If no file is found, creates a blank file..
837#
838# Args:
839# 	$thisprogram - the name of the program
840#	$docdir - the location of the web pages
841#
842#
843######################################################################
844
845sub checkhistoryfile ( $$ ) {
846
847    my ($thisprogram, $docdir) = @_;
848
849    my $histfile = "$docdir/inc/$thisprogram.history";
850
851# check to see if the include file has changed
852    if (! -e "$histfile") {
853	open (HIST, ">$histfile") || die "Cannot open distribution $histfile";
854	print HIST "\n";
855	close HIST;
856    }
857}
858
859
860
861######################################################################
862#
863# Name: checkcommentfile
864#
865# Description:
866# 	This checks for the existence of a coment file.
867#       If no file is found, creates a file with the test 'None'..
868#
869# Args:
870# 	$thisprogram - the name of the program
871#	$docdir - the location of the web pages
872#
873#
874######################################################################
875
876sub checkcommentfile ( $$ ) {
877
878    my ($thisprogram, $docdir) = @_;
879
880    my $commentfile = "$docdir/inc/$thisprogram.comment";
881
882# check to see if the include file has changed
883    if (! -e "$commentfile") {
884	open (HIST, ">$commentfile") || die "Cannot open distribution $commentfile";
885	print HIST "None\n";
886	close HIST;
887    }
888}
889
890
891
892##################################################################
893##################################################################
894#
895# Main routine
896#
897##################################################################
898##################################################################
899
900foreach $x (@embassylist) {
901    push @doclist, "$distribtop/embassy/$x";
902}
903
904$doccreate = "";
905
906foreach $test (@ARGV) {
907    if ($test =~ /^-(.*)/) {
908	$opt=$1;
909	if ($opt eq "create") {$doccreate = "Y"}
910	elsif ($opt =~ /embassy[=](.*)/) {
911	    $singlepackage=$1;
912	    ###print STDERR "Singlepackage '$singlepackage'\n";
913	}
914	else {print STDERR "+++ unknown option '$opt'\n";usage()}
915    }
916    elsif(!defined($singleapp)) {
917	$singleapp = $test;
918	###print STDERR "Singleapp '$singleapp'\n";
919    }
920    else {print STDERR "+++ only one application name allowed\n;usage()"}
921}
922
923$cvscommit = $doccreate;
924@giffiles=();
925open(LOGEX, ">makeexample.log") || die "Cannot open makeexample.log";
926close (LOGEX);
927
928open(LOG, ">autodoc.log") || die "Cannot open autodoc.log";
929
930# get the program and group names
931getprogramnames();
932
933# open the file 'i.i'
934# This will be copied to the file 'index.html' at the end of the script
935# if all goes well.
936# 'index.html' is the file we will be putting in the distribution.
937if(!defined($singlepackage) && !defined($singleapp)) {
938    open (INDEX, "> i.i") || die "Cannot open i.i\n";
939    indexheader(INDEX);
940}
941
942
943# main loop
944# look at all directories in our documentation list
945foreach $docdir (@doclist) {
946    if ($docdir =~ /embassy\/(.*)/) {
947	$embassy = $1;
948	$sfdocdir = "$sfdoctop/embassy/$embassy/";
949	if(defined($singlepackage) && $embassy ne $singlepackage) {next}
950	print LOG "embassy $embassy\n";
951	$eindex =  "$cvsedoc/$embassy/emboss_doc/master/inc/apps.itable";
952	if(!defined($singleapp)) {
953	    open (EINDEX, ">e.e") || die "Cannot open 'e.e'";
954#	embassyindexheader(EINDEX, $embassy);
955	    print EINDEX "<h3><A NAME=\"$embassy\">Applications</A> in the <a
956href=\"ftp://emboss.open-bio.org/pub/EMBOSS/\">current $embassy release</a></h3>
957
958<table border cellpadding=4 bgcolor=\"#FFFFF0\">
959
960<tr>
961<th>Program name</th>
962<th>Description</th>
963</tr>
964
965";
966	}
967    }
968    else {			# main EMBOSS applications
969	$sfdocdir = "$sfdoctop/emboss/apps/";
970	if(defined($singlepackage)) {next}
971	$embassy = "";
972	$eindex = "";
973    }
974
975# look at all applications alphabetically
976    foreach $thisprogram (sort (keys %progs)) {
977	if(defined($singleapp) && $thisprogram ne $singleapp) {next}
978	if ($embassy eq "") {
979	    if (defined($embassyprogs{$thisprogram})) {next}
980	}
981	elsif (!defined($embassyprogs{$thisprogram})) {next}
982	else {
983	    if ($embassyprogs{$thisprogram} ne $embassy) {next}
984	}
985	print "\n$thisprogram '$progs{$thisprogram}'\n";
986	print LOG "\n$thisprogram '$progs{$thisprogram}'\n";
987
988# if this is a non-EMBASSY program then add it to the index.html file
989	if (!defined($embassyprogs{$thisprogram})) {
990	    $progdocdir = $docdir;
991	    $sfprogdocdir = $sfdocdir;
992	    if(!defined($singleapp)) {
993		print INDEX
994"<tr>
995<td><a href=\"$thisprogram.html\">$thisprogram</a></td>
996<td>
997$progs{$thisprogram}
998</td>
999</tr>\n";
1000	    }
1001	}
1002	else {
1003# update the embassy index here -
1004# or just use the %embassyprogs array to make a list?
1005	    $progdocdir = "$cvsedoc/$embassyprogs{$thisprogram}/emboss_doc/master";
1006	    $sfprogdocdir = "$sfdoctop/embassy/$embassyprogs{$thisprogram}";
1007	    if(!defined($singleapp)) {
1008		print EINDEX
1009"<tr>
1010<td><a href=\"$thisprogram.html\">$thisprogram</a></td>
1011<td>
1012$progs{$thisprogram}
1013</td>
1014</tr>\n";
1015	    }
1016	}
1017
1018# check the documentation for this file exists and is not a symbolic link
1019# if this is an EMBASSY document, note which EMBASSY directory it is in
1020	if (!defined($embassyprogs{$thisprogram})) {
1021	    if (-e "$cvsdoc/master/emboss/apps/$thisprogram.html") {
1022###	  print "$progdocdir/$thisprogram.html found\n";
1023		if (-e "$sfprogdocdir/$thisprogram.html") {
1024		    system("diff -b $cvsdoc/html/$thisprogram.html $sfprogdocdir/$thisprogram.html > z.z");
1025		    $s = (-s "z.z");
1026		    if ($s) {
1027			print LOG "** $sfprogdocdir/$thisprogram.html differences ** size:$s ($cvsdoc/html/$thisprogram.html)\n";
1028			print "cp  $cvsdoc/html/$thisprogram.html $sfprogdocdir/$thisprogram.html (differences)\n";
1029			system "cp  $cvsdoc/html/$thisprogram.html $sfprogdocdir/$thisprogram.html";
1030			chmod 0664, "$sfprogdocdir/$thisprogram.html";
1031		    }
1032		}
1033		else {
1034			print LOG "** $sfprogdocdir/$thisprogram.html copied\n";
1035			system "cp  $cvsdoc/html/$thisprogram.html $sfprogdocdir/$thisprogram.html";
1036			chmod 0664, "$sfprogdocdir/$thisprogram.html";
1037		}
1038	    }
1039	    else {
1040# optionally create the documentation and edit it,
1041#	  or abort and do the next program
1042###	  print "$progdocdir/$thisprogram.html missing - EMBOSS\n";
1043		if (!createnewdocumentation($thisprogram, $progdocdir, $sfprogdocdir)) {next;}
1044	    }
1045	    $progdone{$thisprogram} = 1;
1046	}
1047	else {
1048	    $progdir{$thisprogram} = $embassyprogs{$thisprogram};
1049	    $edir = "$cvsedoc/$progdir{$thisprogram}/emboss_doc/html";
1050	    $sfedir = "$sfdoctop/embassy/$progdir{$thisprogram}";
1051	    if(-e "$edir/$thisprogram.html") {
1052###	  print "$edir/$thisprogram.html found\n";
1053		if (-e "$sfedir/$thisprogram.html") {
1054		    system("diff -b $edir/$thisprogram.html $sfedir/$thisprogram.html > z.z");
1055		    $s = (-s "z.z");
1056		    if ($s) {
1057			print LOG "** $sfedir/$thisprogram.html differences ** size:$s ($edir/$thisprogram.html)\n";
1058			print "cp  $edir/$thisprogram.html $sfedir/$thisprogram.html (differences)\n";
1059			system "cp  $edir/$thisprogram.html $sfedir/$thisprogram.html";
1060			chmod 0664, "$sfedir/$thisprogram.html";
1061		    }
1062		}
1063		else {
1064			print LOG "** $edir/$thisprogram.html copied\n";
1065			system "cp  $edir/$thisprogram.html $sfedir/$thisprogram.html";
1066			chmod 0664, "$sfedir/$thisprogram.html";
1067		}
1068	    }
1069	    else {
1070###	  print "$progdocdir/$thisprogram.html missing - EMBASSY $embassyprogs{$thisprogram}\n";
1071		print STDERR "Missing embassy documentation $edir/$thisprogram.html\n";
1072		print STDERR "docdir: $docdir\n";
1073		print STDERR "progdocdir: $progdocdir\n";
1074		print STDERR "embassyprogs: $embassyprogs{$thisprogram}\n";
1075		if (!createnewdocumentationembassy($thisprogram, $progdocdir, $sfedir)) {next;}
1076	    }
1077	    $progdone{$thisprogram} = 1;
1078	}
1079
1080# note whether we now have a documentation file or not
1081	if (!$progdone{$thisprogram}) {
1082	    print "++ Missing main docs: $thisprogram ++ \n";
1083	}
1084
1085# check on the existence of the one-line description include file
1086# for this application
1087	open(FH, ">x.x") || die "Can't open file x.x\n";
1088	print FH $progs{$thisprogram};
1089	close(FH);
1090	checkincludefile($thisprogram, $progdocdir, 'ione');
1091
1092# check on the existence of the '-help' include file for this application
1093	system "acdc $thisprogram -help -verbose 2> x.x";
1094	checkincludefile($thisprogram, $progdocdir, 'ihelp');
1095
1096
1097# check to see if the command table include file exists
1098	system "acdtable $thisprogram -verbose 2> x.x";
1099	checkincludefile($thisprogram, $progdocdir, 'itable');
1100
1101
1102# check to see if the comment file exists
1103	checkcommentfile($thisprogram, $progdocdir);
1104
1105# check to see if the comment file exists
1106	checkhistoryfile($thisprogram, $progdocdir);
1107
1108
1109# check on the existence of the 'seealso' include file for this application
1110# if this is not an EMBASSY program, then we don't want to include EMBASSY
1111# programs in the SEE ALSO file
1112	if (!defined($embassyprogs{$thisprogram})) {
1113	    system "seealso $thisprogram -auto -noembassy -html -out x.x";
1114	    open (X, "x.x") || die "Cannot open x.x";
1115	    $text = "";
1116	    while (<X>) {
1117		if (/\"([^\/.]+)\.html/) {
1118		    $app = $1;
1119		    if (defined($embassyprogs{$app})) {
1120			$apppack = $embassyprogs{$app};
1121			s/\"([^\/.]+)\.html/\"..\/..\/embassy\/$apppack\/$app.html/;
1122		    }
1123		}
1124		$text .= $_;
1125	    }
1126	    close (X);
1127	    open (X, ">x.x") || die "Cannot open x.x for output";
1128	    print X $text;
1129	    close X;
1130	}
1131	else {
1132	    system "seealso $thisprogram -auto -html -out x.x";
1133	    open (X, "x.x") || die "Cannot open x.x";
1134	    $text = "";
1135	    while (<X>) {
1136		if (/\"([^\/.]+)\.html/) {
1137		    $app = $1;
1138		    if (defined($embassyprogs{$app})) {
1139			$apppack = $embassyprogs{$app};
1140			if ($apppack ne $embassyprogs{$thisprogram}) {
1141			    s/\"([^\/.]+)\.html/\"..\/..\/$apppack\/$app.html/;
1142			}
1143		    }
1144		    else {
1145			s/\"([^\/.]+)\.html/\"..\/..\/apps\/$app.html/;
1146		    }
1147		}
1148		$text .= $_;
1149	    }
1150	    close (X);
1151	    open (X, ">x.x") || die "Cannot open x.x for output";
1152	    print X $text;
1153	    close X;
1154	}
1155	system "perl -p -i -e 's/SEE ALSO/See also/g;' x.x";
1156	checkincludefile($thisprogram, $progdocdir, 'isee');
1157
1158# create the '.usage', '.input' and '.output' include files
1159	if ($embassy eq "") {
1160	    $docurl = $url;
1161	    $mkstatus = system "$scripts/makeexample.pl $thisprogram";
1162	    $docmaster = "$cvsdoc/master/emboss/apps";
1163	    $dochtml   = "$cvsdoc/html";
1164	    $doctext   = "$cvsdoc/text";
1165	}
1166	else {
1167	    $docurl = "$urlembassy/$embassy";
1168	    $mkstatus = system "$scripts/makeexample.pl $thisprogram $embassy";
1169	    $docmaster = "$cvsedoc/$embassy/emboss_doc/master";
1170	    $dochtml   = "$cvsedoc/$embassy/emboss_doc/html";
1171	    $doctext   = "$cvsedoc/$embassy/emboss_doc/text";
1172	}
1173	if ($mkstatus) {
1174	    print STDERR "$thisprogram: makeexample.pl status $mkstatus\n";
1175	}
1176
1177# check to see if the CVS tree copy of the html documentation needs updating
1178# check to see if the html file has changed
1179	$status = htmlsource("$thisprogram.html","$docmaster");
1180#	    $status = system "lynx -source $docurl/$thisprogram.html > x.x";
1181	if (!$status) {
1182	    $badsrc++;
1183	    print "htmlsource error $status $docmaster/$thisprogram.html";
1184	}
1185	else {
1186	    if($#giffiles >= 0) {
1187		foreach $gf (@giffiles) {
1188		    system("cp $docmaster/$gf g.g");
1189		    filediff("$dochtml/$gf", "g.g");
1190		    system("cp $docmaster/$gf g.g");
1191		    filediff("$sfprogdocdir/$gf", "g.g");
1192		}
1193	    }
1194# edit the HTML file
1195# change ../emboss_icon.jpg and ../index.html to current directory
1196	    system "perl -p -i -e 's#\.\.\/index.html#index.html#g;' x.x";
1197	    if ($embassy ne "") {
1198		system "perl -p -i -e 's#/images/emboss_icon.jpg#emboss_icon.jpg#g;' x.x";
1199	    }
1200	    $diff = filediff ("$dochtml/$thisprogram.html", "x.x");
1201	    if($diff)
1202	    {
1203		if (!defined($embassyprogs{$thisprogram})) {
1204		    if (-e "$cvsdoc/master/emboss/apps/$thisprogram.html") {
1205###	  print "$progdocdir/$thisprogram.html found\n";
1206			if (-e "$sfprogdocdir/$thisprogram.html") {
1207			    system("diff -b $cvsdoc/html/$thisprogram.html $sfprogdocdir/$thisprogram.html > z.z");
1208			    $s = (-s "z.z");
1209			    if ($s) {
1210				print LOG "** $sfprogdocdir/$thisprogram.html differences ** size:$s ($cvsdoc/html/$thisprogram.html)\n";
1211				print "cp  $cvsdoc/html/$thisprogram.html $sfprogdocdir/$thisprogram.html (differences)\n";
1212				system "cp  $cvsdoc/html/$thisprogram.html $sfprogdocdir/$thisprogram.html";
1213				chmod 0664, "$sfprogdocdir/$thisprogram.html";
1214			    }
1215			}
1216			else {
1217			    print LOG "** $sfprogdocdir/$thisprogram.html copied\n";
1218			    system "cp  $cvsdoc/html/$thisprogram.html $sfprogdocdir/$thisprogram.html";
1219			    chmod 0664, "$sfprogdocdir/$thisprogram.html";
1220			}
1221		    }
1222		}
1223		else {
1224		    $progdir{$thisprogram} = $embassyprogs{$thisprogram};
1225		    $edir = "$cvsedoc/$progdir{$thisprogram}/emboss_doc/html";
1226		    $sfedir = "$sfdoctop/embassy/$progdir{$thisprogram}";
1227		    if(-e "$edir/$thisprogram.html") {
1228###	  print "$edir/$thisprogram.html found\n";
1229			if (-e "$sfedir/$thisprogram.html") {
1230			    system("diff -b $edir/$thisprogram.html $sfedir/$thisprogram.html > z.z");
1231			    $s = (-s "z.z");
1232			    if ($s) {
1233				print LOG "** $sfedir/$thisprogram.html differences ** size:$s ($edir/$thisprogram.html)\n";
1234				print "cp  $edir/$thisprogram.html $sfedir/$thisprogram.html (differences)\n";
1235				system "cp  $edir/$thisprogram.html $sfedir/$thisprogram.html";
1236				chmod 0664, "$sfedir/$thisprogram.html";
1237			    }
1238			}
1239			else {
1240			    print LOG "** $edir/$thisprogram.html copied\n";
1241			    system "cp  $edir/$thisprogram.html $sfedir/$thisprogram.html";
1242			    chmod 0664, "$sfedir/$thisprogram.html";
1243			}
1244		    }
1245		}
1246	    }
1247	}
1248
1249# check to see if the CVS tree copy of the text documentation needs updating
1250# check to see if the text has changed
1251	$status = system "lynx -dump -nolist $dochtml/$thisprogram.html > x.x";
1252	if ($status) {
1253	    $badlynx++;
1254	    print "lynx error $status $dochtml/$thisprogram.html";
1255	}
1256	else {
1257	    cleantext("x.x");
1258	    filediff ("$doctext/$thisprogram.txt", "x.x");
1259	}
1260    }
1261    if($embassy ne "") {
1262	if(!defined($singleapp)) {
1263	    print EINDEX "</table>\n";
1264	    close EINDEX;
1265# check to see if the index.html file has changed
1266	    $diff = filediff ("$eindex", "e.e");
1267
1268	    $status = htmlsource("index.html", "$docmaster");
1269	    if (!$status) {
1270		$badsrc++;
1271		print "htmlsource error $status $docmaster/index.html";
1272	    }
1273	    else {
1274# change ../emboss_icon.jpg and ../index.html to current directory
1275		system "perl -p -i -e 's#\.\.\/index.html#index.html#g;' x.x";
1276		if ($embassy ne "") {
1277		    system "perl -p -i -e 's#/images/emboss_icon.jpg#emboss_icon.jpg#g;' x.x";
1278		}
1279		filediff ("$dochtml/index.html", "x.x");
1280	    }
1281	}
1282    }
1283}
1284# main loop over all directories completed.
1285
1286# end the index.html file
1287if(defined($singleapp)) {exit()}
1288
1289if(defined($singlepackage)) {exit()}
1290indexfooter(INDEX);
1291close(INDEX);
1292
1293# check to see if the index.html file has changed
1294filediff ("$cvsdoc/html/index.html", "i.i");
1295
1296# look at all applications and report the ones with missing documentation
1297foreach $thisprogram (sort (keys %progs)) {
1298    if ($progdone{$thisprogram}) {next}
1299    print "$thisprogram.html =missing=\n";
1300}
1301
1302
1303#############################
1304#
1305# NOW PROCESS THE GROUPS FILE
1306#
1307#############################
1308
1309open (GRPSTD, "$installtop/share/EMBOSS/acd/groups.standard") ||
1310    die "Cannot open $installtop/share/EMBOSS/acd/groups.standard";
1311while (<GRPSTD>) {
1312    if (/^\#/) {next}
1313    if (/^([^ ]+) (\S+) (.*)/) {
1314#	$gterm = $1;
1315	$gname = $2;
1316	$gdesc = ucfirst(lc($3));
1317	$gname =~ s/:/ /g;
1318	$gname =~ s/_/ /g;
1319	$gname = ucfirst(lc($gname));
1320	$gname =~ s/[Dd]na/DNA/;
1321	$gname =~ s/[Rr]na/RNA/;
1322	$gname =~ s/[Cc]pg/CpG/;
1323	$gname =~ s/Hmm/HMM/i;
1324	$gdesc =~ s/[Dd]na/DNA/;
1325	$gdesc =~ s/[Rr]na/RNA/;
1326	$gdesc =~ s/[Cc]pg/CpG/;
1327	$gdesc =~ s/Hmm/HMM/i;
1328	$grpdef{$gname} = $gdesc;
1329    }
1330}
1331close GRPSTD;
1332
1333$docdir = "$cvsdoc/master/emboss/apps";
1334$sfdocdir = "$sfdoctop/apps/cvs";
1335
1336open ( SUM, ">g.g") || die "cannot open temporary groups summary file";
1337
1338header1(SUM);
1339print SUM "Application Groups";
1340header2(SUM);
1341
1342
1343print SUM "
1344<table border cellpadding=4 bgcolor=\"#FFFFF0\">
1345
1346<tr><th>Group</th><th>Description</th></tr>
1347
1348";
1349
1350foreach $g (sort (keys %groups)) {
1351# change the capitalisation on a few group names - most are lowercase
1352    $name = $g;
1353    $name =~ s/_/ /g;
1354    $name = ucfirst(lc($name));
1355    $name =~ s/[Dd]na/DNA/;
1356    $name =~ s/[Rr]na/RNA/;
1357    $name =~ s/Cpg/CpG/i;
1358    $name =~ s/Hmm/HMM/i;
1359    if(!defined($grpdef{$name})){
1360	print STDERR "Unknown group '$name'\n";
1361	$grpdef{$name} = $name;
1362    }
1363    $desc = $grpdef{$name};
1364
1365# this group's name is too long for the Makefile
1366    $filename = $g;
1367    $filename =~ s/restriction_enzymes/re/;
1368
1369
1370    print SUM "<tr>
1371<td><A HREF=\"$filename\_group.html\">$name</A></td>
1372<td>$desc</td>
1373</tr>\n";
1374# print "$filename '$groups{$g}' '$grpnames{$g}'\n";
1375
1376    open ( GRP, ">y.y") || die "cannot open temporary group file";
1377
1378    header1 (GRP);
1379    print GRP "$grpnames{$g}";
1380    header2 (GRP);
1381
1382    print GRP "
1383$desc
1384<p>
1385
1386<table border cellpadding=4 bgcolor=\"#FFFFF0\">
1387
1388<tr><th>Program name</th><th>Description</th></tr>
1389";
1390
1391    foreach $p (split (/\s+/, $groups{$g})) {
1392#   print "$g : '$p'\n";
1393	if ($progdir{$p}) {
1394	    print GRP "
1395<tr>
1396<td><a href=\"../embassy/$progdir{$p}/$p.html\">$p</a></td>
1397<td>
1398$progs{$p}
1399</td>
1400</tr>
1401";
1402
1403	}
1404	else {
1405	    print GRP "
1406<tr>
1407<td><a href=\"$p.html\">$p</a></td>
1408<td>
1409$progs{$p}
1410</td>
1411</tr>
1412";
1413	}
1414    }
1415
1416    print GRP "
1417
1418</table>
1419
1420";
1421
1422    footer (GRP);
1423
1424    close GRP;
1425
1426    filediff ("$docdir/$filename\_group.html", "y.y");
1427
1428# check to see if the CVS tree copy of the html program group documentation
1429# needs updating
1430    $status = htmlsource("$filename\_group.html","$cvsdoc/master/emboss/apps");
1431#	$status = system "lynx -source $url/$filename\_group.html > x.x";
1432    if (!$status) {
1433	$badsrc++;
1434	print "htmlsource error $status $url/$filename\_group.html";
1435    }
1436    else {
1437# change ../emboss_icon.jpg and ../index.html to current directory
1438	system "perl -p -i -e 's#\.\.\/index.html#index.html#g;' x.x";
1439	if ($embassy ne "") {
1440	    system "perl -p -i -e 's#\/images/emboss_icon.jpg#emboss_icon.jpg#g;' x.x";
1441	}
1442	filediff ("$cvsdoc/html/$filename\_group.html", "x.x");
1443    }
1444}
1445
1446print SUM "
1447
1448</table>
1449";
1450
1451footer(SUM);
1452
1453close SUM;
1454
1455filediff("$docdir/groups.html", "g.g");
1456
1457# check to see if the CVS tree copy of the html group documentation needs updating
1458$status = htmlsource("groups.html","$cvsdoc/master/emboss/apps");
1459#    $status = system "lynx -source $url/groups.html > x.x";
1460if (!$status) {
1461    $badsrc++;
1462    print "htmlsource error $status $url/groups.html";
1463}
1464else {
1465# change ../emboss_icon.jpg and ../index.html to current directory
1466    system "perl -p -i -e 's#\.\.\/index.html#index.html#g;' x.x";
1467    system "perl -p -i -e 's#\/images/emboss_icon.jpg#emboss_icon.jpg#g;' x.x";
1468    filediff ("$cvsdoc/html/groups.html", "x.x");
1469}
1470
1471######################################################################
1472# OK - we have updated all our files, now CVS add and CVS commit them
1473######################################################################
1474
1475chdir "$cvsdoc/html";
1476
1477if ($cvsdochtmladd ne "") {
1478    print "cvs add -m'documentation added' $cvsdochtmladd\n";
1479    print STDERR "cvs add -m'documentation added' $cvsdochtmladd\n";
1480    if ($cvscommit) {
1481	system "cvs add -m'documentation added' $cvsdochtmladd";
1482    }
1483}
1484if ($cvsdochtmlcommit ne "") {
1485    print "cvs commit -m'documentation committed' $cvsdochtmlcommit\n";
1486    print STDERR "cvs commit -m'documentation committed' $cvsdochtmlcommit\n";
1487    if ($cvscommit) {
1488	system "cvs commit -m'documentation committed' $cvsdochtmlcommit";
1489    }
1490}
1491else {
1492    print STDERR "HTML docs unchanged\n";
1493}
1494
1495chdir "$cvsdoc/text";
1496
1497if ($cvsdoctextadd ne "") {
1498    print "cvs add -m'documentation added' $cvsdoctextadd\n";
1499    print STDERR "cvs add -m'documentation added' $cvsdoctextadd\n";
1500    if ($cvscommit) {
1501	system "cvs add -m'documentation added' $cvsdoctextadd";
1502    }
1503}
1504if ($cvsdoctextcommit ne "") {
1505    print "cvs commit -m'documentation committed' $cvsdoctextcommit\n";
1506    print STDERR "cvs commit -m'documentation committed' $cvsdoctextcommit\n";
1507    if ($cvscommit) {
1508	system "cvs commit -m'documentation committed' $cvsdoctextcommit";
1509    }
1510}
1511else {
1512    print STDERR "TEXT docs unchanged\n";
1513}
1514
1515# No need to make these makefiles ... now they use wildcards
1516#print "Create make files\n";
1517#system("$scripts/makeMake.pl");	       # no parameter == do text
1518#system("$scripts/makeMake.pl html");   # any parameter == do html
1519
1520print "\n";
1521print LOG "\n";
1522print "==================================\n";
1523print LOG "==================================\n";
1524print "Lynx errors: $badlynx\n";
1525print LOG "Lynx errors: $badlynx\n";
1526print "HTML source errors: $badsrc\n";
1527print LOG "HTML source errors: $badsrc\n";
1528foreach $x (sort(keys(%missingdoc))) {
1529    print "Missing: $missingdoc{$x}/$x.html\n";
1530    print LOG "Missing: $missingdoc{$x}/$x.html\n";
1531}
1532