Hi people, 

I've applied Philippe Martin's patch of March 21 to enable
Docbook output, and shaked makeinfo until it manages to convert
my big texinfo document to valid DocBook.  The patch below is
the result of my toying. It adds supports for function
definitions (although it does not use <funcsynopsis>), and
perform further tweaks to add some missing </para>, or remove
some weird <para> (the DOCTYPE was emited between <para> and
</para>, as well as the closing </variablelist> of the index).
-- 
Alexandre Duret-Lutz
diff -rub -x Makefile* texinfo-4.0+diff-20010321/makeinfo/defun.c texinfo-4.0-patched/makeinfo/defun.c
--- texinfo-4.0+diff-20010321/makeinfo/defun.c	Sun Jul 11 18:50:24 1999
+++ texinfo-4.0-patched/makeinfo/defun.c	Mon Jun 11 14:43:36 2001
@@ -21,6 +21,7 @@
 #include "defun.h"
 #include "insertion.h"
 #include "makeinfo.h"
+#include "docbook.h"
 
 
 #define DEFUN_SELF_DELIMITING(c) \
@@ -430,11 +431,15 @@
   current_indent -= default_indentation_increment;
   start_paragraph ();
 
-  if (html && !x_p)
+  if (!x_p) {
     /* Start the definition on new paragraph.  */
+    if (html)
     add_word ("<p>\n");
+    if (docbook)
+      docbook_begin_paragraph ();
+  }
 
-  if (!html)
+  if (!html && !docbook)
     switch (base_type)
       {
       case deffn:
@@ -505,6 +510,33 @@
         }
     } /* if (html)... */
 
+  if (docbook)
+    {
+      switch (base_type)
+        {
+        case deffn:
+        case defvr:
+        case deftp:
+        case defcv:
+        case defop:
+          add_word_args ("<" DB_FUNCTION ">%s</" DB_FUNCTION ">",
+			 defined_name);
+          break;
+        case deftypefn:
+        case deftypevr:
+          add_word_args ("%s <" DB_FUNCTION ">%s</" DB_FUNCTION ">",
+			 type_name, defined_name);
+          break;
+        case deftypemethod:
+        case deftypeop:
+        case deftypeivar:
+          add_word_args ("%s <" DB_FUNCTION ">%s</" DB_FUNCTION ">",
+			 type_name2, defined_name);
+          break;
+        }
+
+    } /* if (docbook)... */
+
   current_indent += default_indentation_increment;
 
   /* Now process the function arguments, if any.  If these carry onto
diff -rub -x Makefile* texinfo-4.0+diff-20010321/makeinfo/docbook.c texinfo-4.0-patched/makeinfo/docbook.c
--- texinfo-4.0+diff-20010321/makeinfo/docbook.c	Mon Jun 11 15:16:56 2001
+++ texinfo-4.0-patched/makeinfo/docbook.c	Mon Jun 11 15:01:31 2001
@@ -177,8 +177,10 @@
   else
     return;
   
+  ++docbook_no_new_paragraph;
   add_word_args ("<!DOCTYPE book PUBLIC \"-//Davenport//DTD DocBook V3.0//EN\">\n\
 <book>\n<title>%s</title>\n", title);
+  --docbook_no_new_paragraph;
 }
 
 void
@@ -353,11 +355,13 @@
 void
 docbook_begin_table ()
 {
+#if 0
   if (in_docbook_paragraph)
     insert_string ("\n</para>\n\n");
   in_docbook_paragraph = 0;
+#endif
   
-  insert_string ("\n<variablelist>\n");
+  add_word ("\n<variablelist>\n");
   in_table ++;
   in_varlistitem = 0;
   in_entry = 0;
@@ -366,6 +370,8 @@
 void
 docbook_end_table ()
 {
+  if (!in_varlistitem)
+    docbook_begin_paragraph ();
   insert_string ("\n</para></listitem>\n</varlistentry>\n\n</variablelist>\n");
 #if 0
   if (in_table == 1)
@@ -448,8 +454,8 @@
 void 
 docbook_begin_example ()
 {
-  in_example = 1;
   add_word ("\n\n<screen>\n");
+  in_example = 1;
 }
 
 void 
diff -rub -x Makefile* texinfo-4.0+diff-20010321/makeinfo/docbook.h texinfo-4.0-patched/makeinfo/docbook.h
--- texinfo-4.0+diff-20010321/makeinfo/docbook.h	Mon Jun 11 15:16:56 2001
+++ texinfo-4.0-patched/makeinfo/docbook.h	Mon Jun 11 14:42:48 2001
@@ -17,6 +17,7 @@
 #define DB_VAR "replaceable"
 #define DB_I "emphasis"
 #define DB_B "emphasis role=\"bold\""
+#define DB_FUNCTION "function"
 
 extern int docbook_version_inserted;
 extern int docbook_begin_book_p;
diff -rub -x Makefile* texinfo-4.0+diff-20010321/makeinfo/index.c texinfo-4.0-patched/makeinfo/index.c
--- texinfo-4.0+diff-20010321/makeinfo/index.c	Mon Jun 11 15:16:56 2001
+++ texinfo-4.0-patched/makeinfo/index.c	Mon Jun 11 15:04:49 2001
@@ -886,5 +886,5 @@
   if (html)
     add_word ("</ul>");
   else if (docbook)
-    add_word ("</variablelist>");
+    insert_string ("</variablelist>");
 }
diff -rub -x Makefile* texinfo-4.0+diff-20010321/makeinfo/makeinfo.c texinfo-4.0-patched/makeinfo/makeinfo.c
--- texinfo-4.0+diff-20010321/makeinfo/makeinfo.c	Mon Jun 11 15:16:56 2001
+++ texinfo-4.0-patched/makeinfo/makeinfo.c	Mon Jun 11 14:19:13 2001
@@ -2078,7 +2078,7 @@
 
   if (non_splitting_words && strchr (" \t\n", character))
     {
-      if (html)
+      if (html || docbook)
         { /* Seems cleaner to use &nbsp; than an 8-bit char.  */
           add_word ("&nbsp");
           character = ';';

Reply via email to