Show which CVS element is used to generate the HTML file.
[gedcom-parse.git] / doc / make_gom_xref
1 #!/usr/bin/perl -w
2 # $Id$
3 # $Name$
4
5 use strict;
6 use diagnostics;
7
8 my $inputfile ="$ENV{srcdir}/../include/gom.h";
9 my $outputfile ="gomxref.html";
10 my $ext_link = "interface.html";
11 my $generated = "";
12
13 my $main_structs = "";
14 my $sub_structs="";
15 my $index = "";
16 my $section = "";
17
18 open INPUT, $inputfile or die "Can't read $inputfile\n";
19 open OUTPUT, ">$outputfile" or die "Can't read $outputfile\n";
20
21 while (<INPUT>)
22 {
23   $section = "sub"  if m|/\* Sub-structures \*/|;
24   $section = "main" if m|/\* Main structures \*/|;
25   $section = ""     if m|/\* Functions \*/|;
26   $generated = $1   if m|/\* \$Id$ \*/|;
27   next if m|/\*|;
28
29   if ($section ne "") {
30     if (m|^struct (.*) \{|) {
31       s|^struct (.*?) \{|<a name="$1"><B>struct $1</B></a> \{|;
32       if ($section eq "main") {
33         $index .= "  <LI><a href=\"#$1\">struct $1</a><br>\n";
34       }
35     }
36     elsif (m|struct (.*?) \*|) {
37       my $link = "";
38       my $structname = $1;
39       if ($structname =~ /^(date|age|xref)_value$/) {
40         $link = $ext_link;
41       }
42       s|struct (.*?) \*|<a href="$link#$1">struct $1</a> \*|;
43     }
44     
45     if ($section eq "sub") {
46       $sub_structs .= "$_";
47     }
48     else {
49       $main_structs .= "$_";
50     }
51   }
52 }
53
54 print OUTPUT <<"END_OF_HTML";
55 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 FINAL//EN">
56 <html>
57 <head>
58   <title>Gedcom object model in C</title>
59 </head>
60 <body bgcolor="White">
61   
62 <h1 align="center">Gedcom object model in C</h1>
63 This page provides a cross-reference of all objects in the Gedcom object
64 model for C.  The following links are fast links to the main structures
65 in the Gedcom object model:
66
67 <UL>
68 $index
69 </UL>
70 <HR>
71
72 <h2>Main structures</h2>
73 <CODE><PRE>
74 $main_structs
75 </PRE></CODE>
76 <HR>
77
78 <h2>Sub-structures</h2>
79 <CODE><PRE>
80 $sub_structs
81 </PRE></CODE>
82 <HR>
83
84 <SMALL>Generated from: $generated</SMALL>
85 </body>
86 </html>
87 END_OF_HTML
88     
89 close OUTPUT;
90 close INPUT;