]> git.uio.no Git - u/mrichter/AliRoot.git/blame - AliGeant4/config/doc_g4ddl2html.pl
This commit was generated by cvs2svn to compensate for changes in r1459,
[u/mrichter/AliRoot.git] / AliGeant4 / config / doc_g4ddl2html.pl
CommitLineData
676fb573 1#!/usr/local/bin/perl5
2# $Id$
3################################################################################
4#
5# Automatic HTML generator for projects using Objectivity
6#
7# Author : Pavel Binko
8#
9# Last update : 09/04/96
10#
11################################################################################
12# Modified for Alice specifics by Ivana Hrivnacova: 22.5.98;
13# some more changes 12.2.99;
14#
15# ------------------------------------------------------------------------------
16# Analyse the command arguments
17#
18if( $#ARGV == -1 )
19{
20 $pwd = `pwd`;
21 chop($pwd);
22 @help = split(/\//,$pwd);
23 $help[$#help] =~ tr/a-z/A-Z/;
24 $html_title = "The ".$help[$#help]." Project";
25 undef $help;
26}
27elsif( $#ARGV == 0 && $ARGV[0] =~ /^-[?hH]/ )
28{
29 print "\n";
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";
54}
55elsif( $#ARGV == 0 && -e $ARGV[0] )
56{
57 $first = 1;
58 while( <> )
59 {
60 if( $first )
61 {
62 chop($_);
63 $html_title = $_;
64 $first = 0;
65 }
66 }
67 undef $first;
68}
69else
70{
71 $html_title = join( " ", @ARGV );
72}
73
74study();
75
76print "\n\n";
77print "*****************************************************************\n";
78print "*\n";
79print "* $html_title\n";
80print "*\n";
81print "*****************************************************************\n\n\n";
82
83#
84# ------------------------------------------------------------------------------
85# Get some information about the creator
86#
87# UID is in the variable $<
88@list = getpwuid($<);
89$user = $list[6];
90
91#
92# ==============================================================================
93# Get a list of all .ddl files
94#
95@ddls = <*.ddl>;
96print "List of Objectivity DDL files = @ddls\n\n";
97
98#
99# ------------------------------------------------------------------------------
100# Get a list of .h files, where no .ddl files exist (ignore _ref.h files)
101#
102while( $hdrname = <*.h> )
103{
104 if( ! ( $hdrname =~ /_ref.h$/ ) )
105 {
106 $helpname = $hdrname;
107 $helpname =~ s/.h$/.ddl/;
108 if( ! -e $helpname )
109 { @hdrs = (@hdrs, $hdrname);
110 }
111 }
112}
113print "List of C++ header files = @hdrs\n\n";
114
115#
116# ------------------------------------------------------------------------------
117# Get a list of all C++ programs
118#
119while( $cppname = <*.C> )
120{
121 if( ! ( $cppname =~ /_ddl.C$/ ) )
122 {
123 $helpname = $cppname;
124 $helpname =~ s/.C$//;
125 if( -e "$helpname.ddl" )
126 { @cppddls = (@cppddls, $cppname);
127 }
128 elsif( -e "$helpname.h" )
129 { @cpphdrs = (@cpphdrs, $cppname);
130 }
131 else
132 { @cppmain = (@cppmain, $cppname);
133 }
134 }
135}
136print "List of C++ programs to the *.ddl = @cppddls\n\n";
137print "List of C++ programs to the *.h = @cpphdrs\n\n";
138print "List of main programs = @cppmain\n\n";
139
140#
141# ------------------------------------------------------------------------------
142# Get a list of all Makefiles, makefiles, s.Makefiles and s.makefiles
143#
144@maks = <*.gmk>;
145print "List of Makefiles = @maks\n\n";
146
147#
148# ------------------------------------------------------------------------------
149# Get a list of all config.* files
150#
151#@cnfs = <config.*>;
152@cnfs = <setup* *boot*>;
153print "List of configuration files = @cnfs\n\n";
154
155#
156# ==============================================================================
157# Analyse the .ddl and .h files
158#
159print "Analysing the .ddl and .h files ...\n\n";
160
161foreach $file (@ddls, @hdrs)
162{
163 open (HF, $file);
164 $fileline = 0;
165
166 while (<HF>)
167 {
168 $fileline += 1;
169 chop;
170 if ( ! (/^[ \t]*\/\//) ) # ignore C++ comment lines
171 {
172 s/\/\/.*//; # ignore all after C++ comment sign //
173
174 if ( /\bclass\b/ && ! ( /template.*<.*class.*>/ ) )
175 {
176 @words = split(); # split line read in
177 for( $i = 0 ; $i < $#words ; $i++ )
178 {
179 if( $words[$i] eq "class" )
180 {
181 $words[$i+1] =~ s/:.*//;
182 $words[$i+1] =~ s/{.*//;
183 if( !($words[$i+1] =~ /;/ ) && !($words[$i+2] =~ /^;/ )
184 && ($words[$i+1] ne "") )
185 {
186 $fileclass{$words[$i+1]} = $file."//".$fileline;
187 $i = $#words;
188 }
189 }
190 }
191 }
192
193 if ( /\benum\b/ )
194 {
195 @words = split(); # split line read in
196 for( $i = 0 ; $i < $#words ; $i++ )
197 {
198 if( $words[$i] eq "enum" )
199 {
200 $words[$i+1] =~ s/{.*//;
201 if( $words[$i+1] ne "" )
202 {
203 $fileenum{$words[$i+1]} = $file."//".$fileline;
204 $i = $#words;
205 }
206 }
207 }
208 }
209
210 }
211 }
212 close(HF);
213}
214
215# debug
216# print "\n\n\nDEBUG INFORMATION :\n";
217# foreach $class (keys %fileclass)
218# { print "DEBUG: class $class found in $fileclass{$class}\n";
219# }
220# foreach $enum (keys %fileenum)
221# { print "DEBUG: enum $enum found in $fileenum{$enum}\n";
222# }
223# print "\n\n";
224# end debug
225
226#
227# ==============================================================================
228# Some variables needed for html files
229#
230$today = localtime(time);
231$today =~ s/ \d\d:\d\d:\d\d / /;
232
233#
234# ------------------------------------------------------------------------------
235# Create the directory html (if not existing)
236#
237if( ! -e "HTML" )
238{
239 `mkdir HTML`;
240}
241if( -e "/usr/sue/bin/fs" )
242{
243 `/usr/sue/bin/fs setacl . cern:nodes rl`;
244 `/usr/sue/bin/fs setacl HTML cern:nodes rl`;
245}
246
247#
248# ==============================================================================
249# Create *.ddl.html and *.h.html files
250#
251foreach $file (@ddls, @hdrs)
252{
253print "Writing file $file.html ... \n";
254
255# Open the .ddl or .h file and the .html file
256open (HDRF, $file);
257open (HLPF,">HTML/$file.html");
258
259&html_header($file);
260#print HLPF "<HR SIZE=5><P>\n\n";
261#&centred_header1($html_title);
262#print HLPF "<P><HR SIZE=5><P>\n\n";
263&see_source_file;
264print HLPF "<P><HR SIZE=5><P>\n\n";
265&centred_header1($file);
266print HLPF "<P><HR><P>\n\n";
267
268print HLPF "<PRE>\n\n";
269&html_ddl_h_cpp_code;
270print HLPF "\n</PRE>\n\n";
271
272print HLPF "<P><HR SIZE=5><P>\n\n";
273&back_to_index_see_source_file;
274&create_address;
275
276close(HLPF);
277close(HDRF);
278}
279print "\nHTML for Objectivity DDL files and C++ header files created ... \n\n";
280
281#
282# ------------------------------------------------------------------------------
283# Create *.C.html files
284#
285foreach $file (@cppddls, @cpphdrs, @cppmain)
286{
287print "Writing file $file.html ... \n";
288
289# Open the C++ file and the .html file
290open (HDRF, $file);
291open (HLPF,">HTML/$file.html");
292
293&html_header($file);
294#print HLPF "<HR SIZE=5><P>\n\n";
295#&centred_header1($html_title);
296#print HLPF "<P><HR SIZE=5><P>\n\n";
297&see_ddl_h_file;
298print HLPF "<P><HR SIZE=5><P>\n\n";
299&centred_header1($file);
300print HLPF "<P><HR><P>\n\n";
301
302print HLPF "<PRE>\n\n";
303&html_ddl_h_cpp_code;
304print HLPF "\n</PRE>\n\n";
305
306print HLPF "<P><HR SIZE=5><P>\n\n";
307&back_to_index_see_ddl_h_file;
308&create_address;
309
310close(HLPF);
311close(HDRF);
312}
313print "\nHTML for C++ files created ... \n\n";
314
315#
316# ------------------------------------------------------------------------------
317# Copy Make and Config files
318#
319foreach $file (@maks, @cnfs)
320{
321print "Copying file $file ... \n";
322`cp $file HTML/$file`;
323}
324print "\nMake and Config files copied ... \n\n";
325
326#
327# ------------------------------------------------------------------------------
328# Write index.html
329#
330print "Writing index file ... \n";
331
332open (HLPF,">HTML/index.html");
333
334&html_header($html_title);
335
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";
342
343print HLPF "<!-- Header material -->\n";
344print HLPF "<table border=0 cellpadding=5 cellspacing=0 width=\"100%\">\n";
345print HLPF " <tr bgcolor=#d0ffd0>\n";
346print HLPF " <td align=left width=30%>\n";
347print HLPF " <img alt=\"Alice\"\n";
348print HLPF " src=\"http://AliSoft.cern.ch/offline/geant4/gif/AliceLogo.gif\"\n";
349print HLPF " width=\"60\" height=\"60\" align=\"absmiddle\" border=1>\n";
350print HLPF " <td align=center width=40%>\n";
351print HLPF " <font size=\"+2\">\n";
352print HLPF " Geant4 Project";
353print HLPF " </font>\n";
354print HLPF " <td align=right width=30% valign=bottom>\n";
355print HLPF " <font size=\"-1\">\n";
356print HLPF " <script language=\"JavaScript\">\n";
357print HLPF " document.write(\"Last modified \"+ document.lastModified)\n";
358print HLPF " // end of script -->\n";
359print HLPF " </script></font>\n";
360print HLPF " </td>\n";
361print HLPF " </tr>\n";
362print HLPF "</table>\n";
363
364#&centred_header1($html_title);
365#print HLPF "<P><HR SIZE=5><P>\n\n";
366
367print HLPF "<UL><BR>\n\n";
368
369if( @hdrs )
370{
371print 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";
375 }
376
377if( @cpphdrs )
378{
379# &and_cpp_code;
380# foreach $file (@cpphdrs)
381# { print HLPF " <LI><A HREF=\"$file.html\">$file</A>\n";
382# }
383}
384print HLPF " </UL>\n\n";
385
386print HLPF "<P><HR><P>\n\n";
387}
388
389if( @ddls )
390{
391print 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";
395 }
396
397if( @cppddls )
398{
399# &and_cpp_code;
400# foreach $file (@cppddls)
401# { print HLPF " <LI><A HREF=\"$file.html\">$file</A>\n";
402# }
403}
404print HLPF " </UL>\n\n";
405
406print HLPF "<P><HR><P>\n\n";
407}
408
409if( @cppmain )
410{
411print 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";
415 }
416 print HLPF " </UL>\n\n";
417
418print HLPF "<P><HR><P>\n\n";
419}
420
421if( @maks || @cnfs )
422{
423print 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";
428 }
429 foreach $file (@cnfs)
430# { print HLPF " <LI><A HREF=\"../$file\">$file</A>\n";
431 { print HLPF " <LI><A HREF=\"$file\">$file</A>\n";
432 }
433 print HLPF " </UL>\n\n";
434}
435
436print HLPF "</UL>\n\n";
437
438&create_address;
439
440close(HLPF);
441
442print "\n\n";
443
444######################## END OF THE PROGRAM ##################################
445
446#
447# ------------------------------------------------------------------------------
448# Subroutine create_address
449#
450sub create_address
451{
452 print HLPF "<P><HR SIZE=5><BR>\n\n";
453
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";
461
462 print HLPF "</BODY bgcolor=#FFFFFF >\n\n";
463
464 print HLPF "</HTML>\n";
465}
466
467#
468# ------------------------------------------------------------------------------
469# Subroutine back_to_index
470#
471sub back_to_index
472{
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";
477}
478
479#
480# ------------------------------------------------------------------------------
481# Subroutine see_source_file
482#
483sub see_source_file
484{
485 # The C++ file corresponding to the .ddl or .h file
486 $cfile = $file;
487 $cfile =~ s/.h$/.C/;
488 $cfile =~ s/.ddl$/.C/;
489
490 if( -e $cfile )
491 {
492 print HLPF "<H4>See the source file ";
493 print HLPF "<A HREF=\"$cfile.html\">$cfile</A>";
494 print HLPF "</H4>\n\n";
495 }
496 undef $cfile;
497}
498
499#
500# ------------------------------------------------------------------------------
501# Subroutine see_ddl_h_file
502#
503sub see_ddl_h_file
504{
505 # The .ddl or .h file corresponding to the C++ file
506 $ddlfile = $file;
507 $ddlfile =~ s/.C$/.ddl/;
508 if( -e $ddlfile )
509 {
510 print HLPF "<H4>See the Objectivity DDL file ";
511 print HLPF "<A HREF=\"$ddlfile.html\">$ddlfile</A>";
512 print HLPF "</H4>\n\n";
513 }
514 else
515 {
516 $hfile = $file;
517 $hfile =~ s/.C$/.h/;
518 if( -e $hfile )
519 {
520 print HLPF "<H4>See the C++ header file ";
521 print HLPF "<A HREF=\"$hfile.html\">$hfile</A>";
522 print HLPF "</H4>\n\n";
523 }
524 }
525 undef $ddlfile;
526 undef $hfile;
527}
528
529#
530# ------------------------------------------------------------------------------
531# Subroutine back_to_index_see_source_file
532#
533sub back_to_index_see_source_file
534{
535 &back_to_index;
536 &see_source_file;
537}
538
539#
540# ------------------------------------------------------------------------------
541# Subroutine back_to_index_see_ddl_h_file
542#
543sub back_to_index_see_ddl_h_file
544{
545 &back_to_index;
546 &see_ddl_h_file;
547}
548
549#
550# ------------------------------------------------------------------------------
551# Subroutine and_cpp_code
552#
553sub and_cpp_code
554{
555 print HLPF "<P>\n";
556 print HLPF "<STRONG>... and the corresponding C++ code :</STRONG>\n\n";
557}
558
559#
560# ------------------------------------------------------------------------------
561# Subroutine centred_header1
562#
563sub centred_header1
564{
565 local($sometitle) = @_;
566
567 print HLPF "<CENTER>\n";
568 print HLPF "<H1>$sometitle</H1>\n";
569 print HLPF "</CENTER>\n\n";
570}
571
572#
573# ------------------------------------------------------------------------------
574# Subroutine html_header
575#
576sub html_header
577{
578 local($sometitle) = @_;
579
580 print HLPF "<HTML>\n\n";
581
582 print HLPF "<HEAD>\n";
583 print HLPF "<TITLE>$sometitle</TITLE>";
584 print HLPF "</HEAD>\n\n";
585
586 print HLPF "<BODY bgcolor=#FFFFFF>\n\n";
587}
588
589#
590# ------------------------------------------------------------------------------
591# Subroutine html_ddl_h_cpp_code
592#
593sub html_ddl_h_cpp_code
594{
595$fileline = 0;
596
597while (<HDRF>)
598{
599 $fileline += 1;
600 chop;
601
602 s/</&lt\;/g; # convert special characters to html
603 s/>/&gt\;/g;
604
605# Write the HTML
606 foreach $class (keys %fileclass) # add links for classes
607 {
608 undef $newstr;
609 undef $newerstr;
610
611 ( $locfileclass, $locfileline ) = split( /\/\//, $fileclass{$class} );
612
613 if( ($file eq $locfileclass) && ($fileline eq $locfileline) )
614 { print HLPF "<A NAME=\"$class\_classdef\">\n";
615 }
616
617 if ( /\b$class\b/ )
618 {
619 if( $file eq $locfileclass )
620 { $newstr="<a href=\"\#$class\_classdef\">$class</a>";
621 }
622 else
623 { $newstr="<a href=\"$locfileclass.html\#$class\_classdef\">$class</a>";
624 }
625
626undef $hotovo;
627
628while( $_ ne "" )
629{
630 if( /\b$class\b/ )
631 {
632 $hotovo = $hotovo.$`;
633 $zbytek = $';
634
635 if( !( ($hotovo =~ /<a href="$/) && ($zbytek =~ /^\./) ) )
636 {
637 $hotovo = $hotovo.$newstr;
638 }
639 else
640 {
641 $hotovo = $hotovo.$class
642 }
643
644 $_ = $zbytek;
645 /\b$class\b/;
646 }
647 else
648 {
649 $hotovo = $hotovo.$_;
650 $_ = "";
651 }
652}
653
654$_ = $hotovo;
655
656 if ( /$newstr\.h/ )
657 {
658 if( -e "$class.ddl" )
659 { $newerstr="<a href=\"$class.ddl.html\">$class.h</a>";
660 s/$newstr\.h/$newerstr/g;
661 }
662 else
663 { $newerstr="<a href=\"$class.h.html\">$class.h</a>";
664 s/$newstr\.h/$newerstr/g;
665 }
666 }
667
668 if ( /$newstr\.C/ )
669 { $newerstr="<a href=\"$class.C.html\">$class.C</a>";
670 s/$newstr\.C/$newerstr/g;
671 }
672
673 }
674 }
675
676 foreach $enum (keys %fileenum) # add links for enums
677 {
678 undef $newstr;
679 undef $newerstr;
680
681 ( $locfileenum, $locfileline ) = split( /\/\//, $fileenum{$enum} );
682
683 if( ($file eq $locfileenum) && ($fileline eq $locfileline) )
684 { print HLPF "<A NAME=\"$enum\_enumdef\">\n";
685 }
686
687 if ( /\b$enum\b/ )
688 {
689 if( $file eq $locfileenum )
690 { $newstr="<a href=\"\#$enum\_enumdef\">$enum</a>";
691 s/\b$enum\b/$newstr/g;
692 }
693 else
694 { $newstr="<a href=\"$locfileenum.html\#$enum\_enumdef\">$enum</a>";
695 s/\b$enum\b/$newstr/g;
696 }
697
698 if ( /$newstr\.ddl/ )
699 { $newerstr="<a href=\"$enum.ddl.html\">$enum.ddl</a>";
700 s/$newstr\.ddl/$newerstr/g;
701 }
702
703 if ( /$newstr\.h/ )
704 {
705 if( -e "$enum.ddl" )
706 { $newerstr="<a href=\"$enum.ddl.html\">$enum.h</a>";
707 s/$newstr\.h/$newerstr/g;
708 }
709 else
710 { $newerstr="<a href=\"$enum.h.html\">$enum.h</a>";
711 s/$newstr\.h/$newerstr/g;
712 }
713 }
714
715 if ( /$newstr\.C/ )
716 { $newerstr="<a href=\"$enum.C.html\">$enum.C</a>";
717 s/$newstr\.C/$newerstr/g;
718 }
719
720 }
721 }
722
723 print HLPF "$_\n"; # output line to html file
724}
725}
726
727# ------------------------------------------------------------------------------
728