XML DocBook patch



Enclosed is a patch that enables gives gtkdoc-mkdb a new output flag:
--output-format=[xml|sgml]
When --output-format=xml is given gtkdoc-mkdb spits out xml output as xml
rather than sgml (The only difference thus far is that gtkdoc-mkdb closes
the anchor and colspec tags and using .xml as the file extension.)

There are also commented out changes that would move the default output
directory from ./sgml to ./docbook.  I think this is a more logical
directory name but I think it'll require some updates to client makefiles so
I disabled it for now.

-Toshio
-- 

badger  \ 25th March, 1999:  Cold rain in Georgia.  Blustery blowing wind.
@prtr-13 \ Freezing fingers and tired body.  Hiking on because the shelters
.ucsc.edu \ are filled with other hikers.  Life is miserable -- life is grand!
_____________________________________________________________________________
                                                                GA->ME 1999
Index: gtkdoc-mkdb.in
===================================================================
RCS file: /cvs/gnome/gtk-doc/gtkdoc-mkdb.in,v
retrieving revision 1.28
diff -u -r1.28 gtkdoc-mkdb.in
--- gtkdoc-mkdb.in	2001/05/19 23:55:51	1.28
+++ gtkdoc-mkdb.in	2001/05/25 15:21:49
@@ -42,20 +42,24 @@
 my $TMPL_DIR;
 my $SGML_OUTPUT_DIR;
 my @SOURCE_DIRS;
+my $OUTPUT_FORMAT="sgml";
 my $PRINT_VERSION;
 my $PRINT_HELP;
 my $OUTPUT_ALL_SYMBOLS;
 my $MAIN_SGML_FILE;
 
-my %optctl = (module => \$MODULE,
+my %optctl = ('module' => \$MODULE,
 	      'source-dir' => \ SOURCE_DIRS,
 	      'output-dir' => \$SGML_OUTPUT_DIR,
 	      'tmpl-dir' => \$TMPL_DIR,
 	      'version' => \$PRINT_VERSION,
+	      'output-format' => \$OUTPUT_FORMAT,
 	      'help' => \$PRINT_HELP,
 	      'main-sgml-file' => \$MAIN_SGML_FILE,
 	      'outputallsymbols' => \$OUTPUT_ALL_SYMBOLS);
-GetOptions(\%optctl, "module=s", "source-dir:s", "output-dir:s", "version", "outputallsymbols", "main-sgml-file:s", "help");
+GetOptions(\%optctl, "module=s", "source-dir:s", "output-dir:s",
+           "tmpl-dir:s", "output-format=s", "help", "version",
+		   "main-sgml-file:s", "outputallsymbols");
 
 if ($PRINT_VERSION) {
     print "@VERSION \n";
@@ -69,6 +73,8 @@
     print "\n                       May be used more than once for multiple directories";
     print "\n--output-dir=DIRNAME   Directory to put the generated Docbook files in";
     print "\n--tmpl-dir=DIRNAME     DIRECTORY in which template files may be found";
+    print "\n--output-format=FORMAT Specify what type of DocBook to output";
+    print "\n                       FORMAT may be either xml or sgml";
     print "\n--main-sgml-file=FILE  File containing the toplevel SGML file.";
     print "\n--version              Print the version of this program";
     print "\n--help                 Print this help\n";
@@ -80,8 +86,30 @@
 # All the files are written in subdirectories beneath here.
 $TMPL_DIR = $TMPL_DIR ? $TMPL_DIR : "$ROOT_DIR/tmpl";
 
+# The anchor and colspec tags are not explicitly closed in sgml docbook but
+# are closed in xml.  These variables make it easier to close or not.
+my $close_colspec;
+my $close_anchor;
+
+# This string specifies what kind of docbook to output.  Right now the
+# choices are "xml" or "sgml" but they may include versions at a future
+# date if necessary
+if ($OUTPUT_FORMAT =~ m/xml/i) {
+	$OUTPUT_FORMAT="xml";
+	$close_anchor="</anchor>";
+	$close_colspec="</colspec>";
+} else {
+	$OUTPUT_FORMAT="sgml";
+	$close_anchor="";
+	$close_colspec="";
+}
+
 # This is where we put all the DocBook output.
 $SGML_OUTPUT_DIR = $SGML_OUTPUT_DIR ? $SGML_OUTPUT_DIR : "$ROOT_DIR/sgml";
+# sgml => DocBook
+# I think this is more appropriate as our output may be xml rather than sgml
+# but will be docbook in either case
+# $SGML_OUTPUT_DIR = $SGML_OUTPUT_DIR ? $SGML_OUTPUT_DIR : "$ROOT_DIR/docbook";
 
 # This file contains the object hierarchy.
 my $OBJECT_TREE_FILE = "$ROOT_DIR/$MODULE.hierarchy";
@@ -177,6 +205,10 @@
 if ($changed || ! -e "$ROOT_DIR/sgml.stamp") {
     open (TIMESTAMP, ">$ROOT_DIR/sgml.stamp")
 	|| die "Can't create $ROOT_DIR/sgml.stamp";
+# sgml => DocBook
+# if ($changed || ! -e "$ROOT_DIR/docbook.stamp") {
+#    open (TIMESTAMP, ">$ROOT_DIR/docbook.stamp")
+#	|| die "Can't create $ROOT_DIR/docbook.stamp";
     print (TIMESTAMP "timestamp");
     close (TIMESTAMP);
 }
@@ -200,9 +232,9 @@
     print (OUTPUT <<EOF);
 <informaltable pgwide="1" frame="none">
 <tgroup cols="$cols">
-<colspec colwidth="1*">
-<colspec colwidth="1*">
-<colspec colwidth="1*">
+<colspec colwidth="1*">$close_colspec
+<colspec colwidth="1*">$close_colspec
+<colspec colwidth="1*">$close_colspec
 <tbody>
 EOF
 
@@ -300,7 +332,7 @@
 #	    print "End of section: $title\n";
 
 	    $file =~ s/\s/_/g;
-	    $file .= ".sgml";
+	    $file .= ".$OUTPUT_FORMAT";
 
 	    # GtkObjects use their class name as the ID.
 	    my $section_id;
@@ -311,6 +343,8 @@
 	    }
 
 	    if ($num_symbols > 0) {
+		# sgml => DocBook
+		# $book_top .= "<!ENTITY $section_id SYSTEM \"docbook/$file\">\n";
 		$book_top .= "<!ENTITY $section_id SYSTEM \"sgml/$file\">\n";
 		$book_bottom .= "    &$section_id;\n";
 
@@ -427,9 +461,9 @@
     $synop .= "\n";
 
     if ($args ne "") {
-	$desc = "<refsect2>\n<title><anchor id=\"$id\">${symbol}()</title>\n";
+	$desc = "<refsect2>\n<title><anchor id=\"$id\">$close_anchor${symbol}()</title>\n";
     } else {
-	$desc = "<refsect2>\n<title><anchor id=\"$id\">$symbol</title>\n";
+	$desc = "<refsect2>\n<title><anchor id=\"$id\">$close_anchor$symbol</title>\n";
     }
     # Don't output the macro definition if is is a conditional macro or it
     # looks like a function, i.e. starts with "g_" or "_?gnome_", or it is
@@ -470,7 +504,7 @@
     my ($symbol, $declaration) = @_;
     my $id = &CreateValidSGMLID ($symbol);
     my $synop = "typedef     <link linkend=\"$id\">$symbol</link>;\n";
-    my $desc = "<refsect2>\n<title><anchor id=\"$id\">$symbol</title>\n";
+    my $desc = "<refsect2>\n<title><anchor id=\"$id\">$close_anchor$symbol</title>\n";
     if (!defined ($DeclarationConditional{$symbol})) {
 	$declaration = &CreateValidSGML ($declaration);
 	$desc .= "<programlisting>$declaration</programlisting>\n";
@@ -515,7 +549,7 @@
 	$id = &CreateValidSGMLID ($symbol);
     }
     my $synop = "struct      <link linkend=\"$id\">$symbol</link>;\n";
-    my $desc = "<refsect2>\n<title><anchor id=\"$id\">struct $symbol</title>\n";
+    my $desc = "<refsect2>\n<title><anchor id=\"$id\">${close_anchor}struct $symbol</title>\n";
 
     # Form a pretty-printed, private-data-removed form of the declaration
 
@@ -591,8 +625,8 @@
 	    $desc .= <<EOF;
 <informaltable pgwide="1" frame="none" role="struct">
 <tgroup cols="2">
-<colspec colwidth="2*">
-<colspec colwidth="8*">
+<colspec colwidth="2*">$close_colspec
+<colspec colwidth="8*">$close_colspec
 <tbody>
 EOF
 	while (@fields) {
@@ -627,7 +661,7 @@
     my ($symbol, $declaration) = @_;
     my $id = &CreateValidSGMLID ($symbol);
     my $synop = "enum        <link linkend=\"$id\">$symbol</link>;\n";
-    my $desc = "<refsect2>\n<title><anchor id=\"$id\">enum $symbol</title>\n";
+    my $desc = "<refsect2>\n<title><anchor id=\"$id\">${close_anchor}enum $symbol</title>\n";
     $declaration = &CreateValidSGML ($declaration);
     $desc .= "<programlisting>$declaration</programlisting>\n";
 
@@ -663,8 +697,8 @@
 	    $desc .= <<EOF;
 <informaltable pgwide="1" frame="none" role="enum">
 <tgroup cols="2">
-<colspec colwidth="2*">
-<colspec colwidth="8*">
+<colspec colwidth="2*">$close_colspec
+<colspec colwidth="8*">$close_colspec
 <tbody>
 EOF
 	for my $member_name (@members) {
@@ -698,7 +732,7 @@
     my ($symbol, $declaration) = @_;
     my $id = &CreateValidSGMLID ($symbol);
     my $synop = "union       <link linkend=\"$id\">$symbol</link>;\n";
-    my $desc = "<refsect2>\n<title><anchor id=\"$id\">union $symbol</title>\n";
+    my $desc = "<refsect2>\n<title><anchor id=\"$id\">${close_anchor}union $symbol</title>\n";
     $declaration = &CreateValidSGML ($declaration);
     $desc .= "<programlisting>$declaration</programlisting>\n";
 
@@ -736,7 +770,7 @@
 	$synop = "extern      <link linkend=\"$id\">$symbol</link>;\n";
     }
 
-    my $desc = "<refsect2>\n<title><anchor id=\"$id\">$symbol</title>\n";
+    my $desc = "<refsect2>\n<title><anchor id=\"$id\">$close_anchor$symbol</title>\n";
     $declaration = &CreateValidSGML ($declaration);
     $desc .= "<programlisting>$declaration</programlisting>\n";
 
@@ -813,7 +847,7 @@
     }
 
     my $synop = $ret_type_output . $symbol_output . '(';
-    my $desc = "<refsect2>\n<title><anchor id=\"$id\">${symbol} ()</title>\n";
+    my $desc = "<refsect2>\n<title><anchor id=\"$id\">$close_anchor${symbol} ()</title>\n";
     $desc  .= "<programlisting>${ret_type_output}$symbol_desc_output(";
 
     my $param_num = 0;
@@ -958,8 +992,8 @@
 	    $output .= <<EOF;
 <informaltable pgwide="1" frame="none" role="params">
 <tgroup cols="2">
-<colspec colwidth="2*">
-<colspec colwidth="8*">
+<colspec colwidth="2*">$close_colspec
+<colspec colwidth="8*">$close_colspec
 <tbody>
 EOF
 
@@ -1372,7 +1406,7 @@
 		    . (' ' x $SIGNAL_FIELD_WIDTH);
 	    }
 
-	    $desc .= "<refsect2><title><anchor id=\"$id\">The &quot;$name&quot; signal</title>\n";
+	    $desc .= "<refsect2><title><anchor id=\"$id\">${close_anchor}The &quot;$name&quot; signal</title>\n";
 	    $desc .= "<programlisting>";
 
 	    $SignalReturns[$i] =~ m/\s*(const\s*)?(\w+)\s*(\**)/;
@@ -1501,7 +1535,7 @@
 	    my $pad2 = " " x (20 - length ($type));
 	    $synop .= "  &quot;<link linkend=\"$id\">$name</link>&quot;$pad1 $type_output$pad2 : $flags_string\n";
 
-	    $desc .= "<varlistentry><term><anchor id=\"$id\">&quot;<literal>$name</literal>&quot; ($type_output : $flags_string)</term>\n<listitem>\n";
+	    $desc .= "<varlistentry><term><anchor id=\"$id\">$close_anchor&quot;<literal>$name</literal>&quot; ($type_output : $flags_string)</term>\n<listitem>\n";
 
 	    if (defined ($SymbolDocs{$symbol})) {
 	        $desc .= &ExpandAbbreviations($SymbolDocs{$symbol});


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]