Generating documentation for gedcom object model.
[gedcom-parse.git] / doc / make_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
12 my $main_structs = "";
13 my $sub_structs="";
14 my $index = "";
15 my $section = "";
16
17 open INPUT, $inputfile or die "Can't read $inputfile\n";
18 open OUTPUT, ">$outputfile" or die "Can't read $outputfile\n";
19
20 while (<INPUT>)
21 {
22   $section = "sub"  if m|/\* Sub-structures \*/|;
23   $section = "main" if m|/\* Main structures \*/|;
24   $section = ""     if m|/\* Functions \*/|;
25   next if m|/\*|;
26
27   if ($section ne "") {
28     if (m|^struct (.*) \{|) {
29       s|^struct (.*?) \{|<a name="$1"><B>struct $1</B></a> \{|;
30       if ($section eq "main") {
31         $index .= "  <LI><a href=\"#$1\">struct $1</a><br>\n";
32       }
33     }
34     elsif (m|struct (.*?) \*|) {
35       my $link = "";
36       my $structname = $1;
37       if ($structname =~ /^(date|age|xref)_value$/) {
38         $link = $ext_link;
39       }
40       s|struct (.*?) \*|<a href="$link#$1">struct $1</a> \*|;
41     }
42     
43     if ($section eq "sub") {
44       $sub_structs .= "$_";
45     }
46     else {
47       $main_structs .= "$_";
48     }
49   }
50 }
51
52 print OUTPUT "<center><h1>Gedcom object model in C</h1></center>\n";
53 print OUTPUT <<END_OF_TEXT;
54 This page provides a cross-reference of all objects in the Gedcom object
55 model for C.  The following links are fast links to the main structures
56 in the Gedcom object model:
57 END_OF_TEXT
58 print OUTPUT "\n";
59 print OUTPUT "<UL>\n";
60 print OUTPUT $index;
61 print OUTPUT "</UL>\n";
62 print OUTPUT "<hr>\n";
63 print OUTPUT "<h2>Main structures</h2>\n";
64 print OUTPUT "<CODE><PRE>\n";
65 print OUTPUT $main_structs;
66 print OUTPUT "</PRE></CODE>\n";
67 print OUTPUT "<hr>\n";
68 print OUTPUT "<h2>Sub-structures</h2>\n";
69 print OUTPUT "<CODE><PRE>\n";
70 print OUTPUT $sub_structs;
71 print OUTPUT "</PRE></CODE>\n";
72
73 close OUTPUT;
74 close INPUT;