3 ################################################################################
5 # Automatic HTML generator for projects using Objectivity
9 # Last update : 09/04/96
11 ################################################################################
12 # Modified for Alice specifics by Ivana Hrivnacova: 22.5.98;
13 # some more changes 12.2.99;
15 # ------------------------------------------------------------------------------
16 # Analyse the command arguments
22 @help = split(/\//,$pwd);
23 $help[$#help] =~ tr/a-z/A-Z/;
24 $html_title = "The ".$help[$#help]." Project";
27 elsif( $#ARGV == 0 && $ARGV[0] =~ /^-[?hH]/ )
30 print "The Ddl2Html functionality :\n\n";
31 print " Ddl2Html has to be started from the project directory you'd like\n";
32 print " to document (to convert to html)\n";
33 print " Ddl2Html creates (if not existing) the directory HTML in the project\n";
34 print " directory and adds the afs access rights \"cern:nodes rl\"\n";
35 print " to both HTML and project directories\n";
36 print " Ddl2Html creates index.html file and *.ddl.html, *.h.html and\n";
37 print " *.C.html files in the HTML directory\n\n";
38 print " Contents of the project directory remains unchanged.\n\n\n";
39 print "The Ddl2Html command syntax :\n\n";
40 print " Ddl2Html [ arguments ] \n\n";
41 print " No argument : The project directory name will be chosen\n";
42 print " as the project name (in upper case)\n\n";
43 print " One argument : a) If the argument starts with -h or -H or -?,\n";
44 print " this help text will be printed\n";
45 print " b) If the argument matches with a file name\n";
46 print " in the project directory, the first line\n";
47 print " from the file will be the project title\n";
48 print " c) Othetwise the whole text from the command\n";
49 print " line will be the project title\n\n";
50 print " More than one argument : The whole text from the command line\n";
51 print " will be the project title\n\n\n";
52 print "For further details see the :\n";
53 die " http://home.cern.ch/~binko/Ddl2Html/Ddl2Html.html\n\n";
55 elsif( $#ARGV == 0 && -e $ARGV[0] )
71 $html_title = join( " ", @ARGV );
77 print "*****************************************************************\n";
79 print "* $html_title\n";
81 print "*****************************************************************\n\n\n";
84 # ------------------------------------------------------------------------------
85 # Get some information about the creator
87 # UID is in the variable $<
92 # ==============================================================================
93 # Get a list of all .ddl files
96 print "List of Objectivity DDL files = @ddls\n\n";
99 # ------------------------------------------------------------------------------
100 # Get a list of .h files, where no .ddl files exist (ignore _ref.h files)
102 while( $hdrname = <*.h> )
104 if( ! ( $hdrname =~ /_ref.h$/ ) )
106 $helpname = $hdrname;
107 $helpname =~ s/.h$/.ddl/;
109 { @hdrs = (@hdrs, $hdrname);
113 print "List of C++ header files = @hdrs\n\n";
116 # ------------------------------------------------------------------------------
117 # Get a list of all C++ programs
119 while( $cppname = <*.C> )
121 if( ! ( $cppname =~ /_ddl.C$/ ) )
123 $helpname = $cppname;
124 $helpname =~ s/.C$//;
125 if( -e "$helpname.ddl" )
126 { @cppddls = (@cppddls, $cppname);
128 elsif( -e "$helpname.h" )
129 { @cpphdrs = (@cpphdrs, $cppname);
132 { @cppmain = (@cppmain, $cppname);
136 print "List of C++ programs to the *.ddl = @cppddls\n\n";
137 print "List of C++ programs to the *.h = @cpphdrs\n\n";
138 print "List of main programs = @cppmain\n\n";
141 # ------------------------------------------------------------------------------
142 # Get a list of all Makefiles, makefiles, s.Makefiles and s.makefiles
145 print "List of Makefiles = @maks\n\n";
148 # ------------------------------------------------------------------------------
149 # Get a list of all config.* files
152 @cnfs = <setup* *boot*>;
153 print "List of configuration files = @cnfs\n\n";
156 # ==============================================================================
157 # Analyse the .ddl and .h files
159 print "Analysing the .ddl and .h files ...\n\n";
161 foreach $file (@ddls, @hdrs)
170 if ( ! (/^[ \t]*\/\//) ) # ignore C++ comment lines
172 s/\/\/.*//; # ignore all after C++ comment sign //
174 if ( /\bclass\b/ && ! ( /template.*<.*class.*>/ ) )
176 @words = split(); # split line read in
177 for( $i = 0 ; $i < $#words ; $i++ )
179 if( $words[$i] eq "class" )
181 $words[$i+1] =~ s/:.*//;
182 $words[$i+1] =~ s/{.*//;
183 if( !($words[$i+1] =~ /;/ ) && !($words[$i+2] =~ /^;/ )
184 && ($words[$i+1] ne "") )
186 $fileclass{$words[$i+1]} = $file."//".$fileline;
195 @words = split(); # split line read in
196 for( $i = 0 ; $i < $#words ; $i++ )
198 if( $words[$i] eq "enum" )
200 $words[$i+1] =~ s/{.*//;
201 if( $words[$i+1] ne "" )
203 $fileenum{$words[$i+1]} = $file."//".$fileline;
216 # print "\n\n\nDEBUG INFORMATION :\n";
217 # foreach $class (keys %fileclass)
218 # { print "DEBUG: class $class found in $fileclass{$class}\n";
220 # foreach $enum (keys %fileenum)
221 # { print "DEBUG: enum $enum found in $fileenum{$enum}\n";
227 # ==============================================================================
228 # Some variables needed for html files
230 $today = localtime(time);
231 $today =~ s/ \d\d:\d\d:\d\d / /;
234 # ------------------------------------------------------------------------------
235 # Create the directory html (if not existing)
241 if( -e "/usr/sue/bin/fs" )
243 `/usr/sue/bin/fs setacl . cern:nodes rl`;
244 `/usr/sue/bin/fs setacl HTML cern:nodes rl`;
248 # ==============================================================================
249 # Create *.ddl.html and *.h.html files
251 foreach $file (@ddls, @hdrs)
253 print "Writing file $file.html ... \n";
255 # Open the .ddl or .h file and the .html file
257 open (HLPF,">HTML/$file.html");
260 #print HLPF "<HR SIZE=5><P>\n\n";
261 #¢red_header1($html_title);
262 #print HLPF "<P><HR SIZE=5><P>\n\n";
264 print HLPF "<P><HR SIZE=5><P>\n\n";
265 ¢red_header1($file);
266 print HLPF "<P><HR><P>\n\n";
268 print HLPF "<PRE>\n\n";
269 &html_ddl_h_cpp_code;
270 print HLPF "\n</PRE>\n\n";
272 print HLPF "<P><HR SIZE=5><P>\n\n";
273 &back_to_index_see_source_file;
279 print "\nHTML for Objectivity DDL files and C++ header files created ... \n\n";
282 # ------------------------------------------------------------------------------
283 # Create *.C.html files
285 foreach $file (@cppddls, @cpphdrs, @cppmain)
287 print "Writing file $file.html ... \n";
289 # Open the C++ file and the .html file
291 open (HLPF,">HTML/$file.html");
294 #print HLPF "<HR SIZE=5><P>\n\n";
295 #¢red_header1($html_title);
296 #print HLPF "<P><HR SIZE=5><P>\n\n";
298 print HLPF "<P><HR SIZE=5><P>\n\n";
299 ¢red_header1($file);
300 print HLPF "<P><HR><P>\n\n";
302 print HLPF "<PRE>\n\n";
303 &html_ddl_h_cpp_code;
304 print HLPF "\n</PRE>\n\n";
306 print HLPF "<P><HR SIZE=5><P>\n\n";
307 &back_to_index_see_ddl_h_file;
313 print "\nHTML for C++ files created ... \n\n";
316 # ------------------------------------------------------------------------------
317 # Copy Make and Config files
319 foreach $file (@maks, @cnfs)
321 print "Copying file $file ... \n";
322 `cp $file HTML/$file`;
324 print "\nMake and Config files copied ... \n\n";
327 # ------------------------------------------------------------------------------
330 print "Writing index file ... \n";
332 open (HLPF,">HTML/index.html");
334 &html_header($html_title);
336 #print HLPF "<H1 ALIGN=RIGHT>";
337 #print HLPF "<TABLE COLSPEC=\"20\" BORDER=5 CELLPADDING=0 CELLSPACING=0>\n";
338 #print HLPF "<TR><TH>";
339 #print HLPF "<A HREF=\"index.html\" TARGET=_top>No Frame</A>";
340 #print HLPF "</TH></TR>\n";
341 #print HLPF "</TABLE></H1>\n\n";
343 print HLPF "<!-- Header material -->\n";
344 print HLPF "<table border=0 cellpadding=5 cellspacing=0 width=\"100%\">\n";
345 print HLPF " <tr bgcolor=#d0ffd0>\n";
346 print HLPF " <td align=left width=30%>\n";
347 print HLPF " <img alt=\"Alice\"\n";
348 print HLPF " src=\"http://AliSoft.cern.ch/offline/geant4/gif/AliceLogo.gif\"\n";
349 print HLPF " width=\"60\" height=\"60\" align=\"absmiddle\" border=1>\n";
350 print HLPF " <td align=center width=40%>\n";
351 print HLPF " <font size=\"+2\">\n";
352 print HLPF " Geant4 Project";
353 print HLPF " </font>\n";
354 print HLPF " <td align=right width=30% valign=bottom>\n";
355 print HLPF " <font size=\"-1\">\n";
356 print HLPF " <script language=\"JavaScript\">\n";
357 print HLPF " document.write(\"Last modified \"+ document.lastModified)\n";
358 print HLPF " // end of script -->\n";
359 print HLPF " </script></font>\n";
360 print HLPF " </td>\n";
361 print HLPF " </tr>\n";
362 print HLPF "</table>\n";
364 #¢red_header1($html_title);
365 #print HLPF "<P><HR SIZE=5><P>\n\n";
367 print HLPF "<UL><BR>\n\n";
371 print HLPF "<LI><STRONG>C++ header files:</STRONG>\n";
372 print HLPF " <UL>\n";
373 foreach $file (@hdrs)
374 { print HLPF " <LI><A HREF=\"$file.html\">$file</A>\n";
380 # foreach $file (@cpphdrs)
381 # { print HLPF " <LI><A HREF=\"$file.html\">$file</A>\n";
384 print HLPF " </UL>\n\n";
386 print HLPF "<P><HR><P>\n\n";
391 print HLPF "<LI><STRONG>Objectivity DDL files:</STRONG>\n";
392 print HLPF " <UL>\n";
393 foreach $file (@ddls)
394 { print HLPF " <LI><A HREF=\"$file.html\">$file</A>\n";
400 # foreach $file (@cppddls)
401 # { print HLPF " <LI><A HREF=\"$file.html\">$file</A>\n";
404 print HLPF " </UL>\n\n";
406 print HLPF "<P><HR><P>\n\n";
411 print HLPF "<LI><STRONG>Main programs/Extern methods:</STRONG>\n";
412 print HLPF " <UL>\n";
413 foreach $file (@cppmain)
414 { print HLPF " <LI><A HREF=\"$file.html\">$file</A>\n";
416 print HLPF " </UL>\n\n";
418 print HLPF "<P><HR><P>\n\n";
423 print HLPF "<LI><STRONG>Makefiles and configuration files:</STRONG>\n";
424 print HLPF " <UL>\n";
425 foreach $file (@maks)
426 # { print HLPF " <LI><A HREF=\"../$file\">$file</A>\n";
427 { print HLPF " <LI><A HREF=\"$file\">$file</A>\n";
429 foreach $file (@cnfs)
430 # { print HLPF " <LI><A HREF=\"../$file\">$file</A>\n";
431 { print HLPF " <LI><A HREF=\"$file\">$file</A>\n";
433 print HLPF " </UL>\n\n";
436 print HLPF "</UL>\n\n";
444 ######################## END OF THE PROGRAM ##################################
447 # ------------------------------------------------------------------------------
448 # Subroutine create_address
452 print HLPF "<P><HR SIZE=5><BR>\n\n";
454 print HLPF "<ADDRESS>\n";
455 print HLPF "Created on $today by <B>$user</B> <BR>\n";
456 print HLPF "using the HTML generator\n";
457 print HLPF "<A HREF=\"http://home.cern.ch/~binko/Ddl2Html/Ddl2Html.html\">Ddl2Html description</A>\n";
458 print HLPF " (the source ";
459 print HLPF "<A HREF=\"http://home.cern.ch/~binko/Ddl2Html/Ddl2Html.code\">Perl5 code</A>)\n";
460 print HLPF "</ADDRESS>\n\n";
462 print HLPF "</BODY bgcolor=#FFFFFF >\n\n";
464 print HLPF "</HTML>\n";
468 # ------------------------------------------------------------------------------
469 # Subroutine back_to_index
473 print HLPF "<H4>Back to: ";
474 print HLPF "<A HREF=\"../G4CodePrototype.html\"> Class categories index, </A>";
475 print HLPF "<A HREF=\"index.html\">Alphabetical index</A>";
476 print HLPF "</H4>\n\n";
480 # ------------------------------------------------------------------------------
481 # Subroutine see_source_file
485 # The C++ file corresponding to the .ddl or .h file
488 $cfile =~ s/.ddl$/.C/;
492 print HLPF "<H4>See the source file ";
493 print HLPF "<A HREF=\"$cfile.html\">$cfile</A>";
494 print HLPF "</H4>\n\n";
500 # ------------------------------------------------------------------------------
501 # Subroutine see_ddl_h_file
505 # The .ddl or .h file corresponding to the C++ file
507 $ddlfile =~ s/.C$/.ddl/;
510 print HLPF "<H4>See the Objectivity DDL file ";
511 print HLPF "<A HREF=\"$ddlfile.html\">$ddlfile</A>";
512 print HLPF "</H4>\n\n";
520 print HLPF "<H4>See the C++ header file ";
521 print HLPF "<A HREF=\"$hfile.html\">$hfile</A>";
522 print HLPF "</H4>\n\n";
530 # ------------------------------------------------------------------------------
531 # Subroutine back_to_index_see_source_file
533 sub back_to_index_see_source_file
540 # ------------------------------------------------------------------------------
541 # Subroutine back_to_index_see_ddl_h_file
543 sub back_to_index_see_ddl_h_file
550 # ------------------------------------------------------------------------------
551 # Subroutine and_cpp_code
556 print HLPF "<STRONG>... and the corresponding C++ code :</STRONG>\n\n";
560 # ------------------------------------------------------------------------------
561 # Subroutine centred_header1
565 local($sometitle) = @_;
567 print HLPF "<CENTER>\n";
568 print HLPF "<H1>$sometitle</H1>\n";
569 print HLPF "</CENTER>\n\n";
573 # ------------------------------------------------------------------------------
574 # Subroutine html_header
578 local($sometitle) = @_;
580 print HLPF "<HTML>\n\n";
582 print HLPF "<HEAD>\n";
583 print HLPF "<TITLE>$sometitle</TITLE>";
584 print HLPF "</HEAD>\n\n";
586 print HLPF "<BODY bgcolor=#FFFFFF>\n\n";
590 # ------------------------------------------------------------------------------
591 # Subroutine html_ddl_h_cpp_code
593 sub html_ddl_h_cpp_code
602 s/</<\;/g; # convert special characters to html
606 foreach $class (keys %fileclass) # add links for classes
611 ( $locfileclass, $locfileline ) = split( /\/\//, $fileclass{$class} );
613 if( ($file eq $locfileclass) && ($fileline eq $locfileline) )
614 { print HLPF "<A NAME=\"$class\_classdef\">\n";
619 if( $file eq $locfileclass )
620 { $newstr="<a href=\"\#$class\_classdef\">$class</a>";
623 { $newstr="<a href=\"$locfileclass.html\#$class\_classdef\">$class</a>";
632 $hotovo = $hotovo.$`;
635 if( !( ($hotovo =~ /<a href="$/) && ($zbytek =~ /^\./) ) )
637 $hotovo = $hotovo.$newstr;
641 $hotovo = $hotovo.$class
649 $hotovo = $hotovo.$_;
658 if( -e "$class.ddl" )
659 { $newerstr="<a href=\"$class.ddl.html\">$class.h</a>";
660 s/$newstr\.h/$newerstr/g;
663 { $newerstr="<a href=\"$class.h.html\">$class.h</a>";
664 s/$newstr\.h/$newerstr/g;
669 { $newerstr="<a href=\"$class.C.html\">$class.C</a>";
670 s/$newstr\.C/$newerstr/g;
676 foreach $enum (keys %fileenum) # add links for enums
681 ( $locfileenum, $locfileline ) = split( /\/\//, $fileenum{$enum} );
683 if( ($file eq $locfileenum) && ($fileline eq $locfileline) )
684 { print HLPF "<A NAME=\"$enum\_enumdef\">\n";
689 if( $file eq $locfileenum )
690 { $newstr="<a href=\"\#$enum\_enumdef\">$enum</a>";
691 s/\b$enum\b/$newstr/g;
694 { $newstr="<a href=\"$locfileenum.html\#$enum\_enumdef\">$enum</a>";
695 s/\b$enum\b/$newstr/g;
698 if ( /$newstr\.ddl/ )
699 { $newerstr="<a href=\"$enum.ddl.html\">$enum.ddl</a>";
700 s/$newstr\.ddl/$newerstr/g;
706 { $newerstr="<a href=\"$enum.ddl.html\">$enum.h</a>";
707 s/$newstr\.h/$newerstr/g;
710 { $newerstr="<a href=\"$enum.h.html\">$enum.h</a>";
711 s/$newstr\.h/$newerstr/g;
716 { $newerstr="<a href=\"$enum.C.html\">$enum.C</a>";
717 s/$newstr\.C/$newerstr/g;
723 print HLPF "$_\n"; # output line to html file
727 # ------------------------------------------------------------------------------