Re: Doclifter and xorg-docs

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

 



Am Sonntag, den 15.06.2008, 22:33 -0400 schrieb François-Denis Gonthier:
> Hello all,
> 
> I've been playing around with trying to convert X11.protocol to
> docbook using doclifter.

I'm converting the documents in the Xext directory. (I was interested
in the mit-shm extension.) I also knew nothing about troff a few days
ago, but the doclifter source code and the documentation of the ms
format [1] was enough to fix some Doclifter 2.3 bugs in the
MsInterpreter class. I'm attaching the patch in case anyone is
interested. 

But X11.protocoll does not seem to use the ms format. doclifter -v
prints a stacktrace on unexpected exceptions, maybe that will help.

Günther

[1] http://mirbsd.org/htman/i386/manUSD/17.msmacros.htm
--- doclifter-2.3/doclifter	2006-12-25 08:43:35.000000000 +0100
+++ doclifter-2.3/doclifter_new	2008-06-16 13:50:11.000000000 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.2
 """
 doclifter: translate man/mdoc/ms/me/mm sources to DocBook.
 
@@ -1590,6 +1590,10 @@
                     # stderr.write("Tokens:" + `tokens` + "\n")
                     self.emit(make_comment(line))
                     self.error("uninterpreted '%s' command" % command)
+        except Exception, inst:
+            self.error("%s: %s" % (line, inst))
+            raise
+            #print inst           # __str__ allows args to printed directly
         except:
             # Pass the exception upwards for debugging purposes
             (exc_type, exc_value, exc_traceback) = sys.exc_info()
@@ -4808,6 +4812,36 @@
             res += "    </affiliation>\n"
         res += "</author>"
         return res
+    def emit(self, source):
+        source.emit("<author>\n")
+        if self.firstname:
+            source.emit("    <firstname>%s</firstname>\n" % self.firstname)
+        if self.middle:
+            if self.middle[-1] == '.':
+                role = " role='mi'"
+            else:
+                role = ""
+            source.emit("    <othername%s>%s</othername>\n" % (role, self.middle))
+        if self.surname:
+            source.emit("    <surname>%s</surname>\n" % self.surname)
+        if self.lineage:
+            source.emit("    <lineage>%s</lineage>\n" % self.lineage)
+        if self.orgname or self.jobtitle or self.orgdiv:
+            source.emit("    <affiliation>\n")
+            
+            if self.orgname:
+                source.emit("<orgname>");
+                source.interpret_block(self.orgname)
+                source.end_paragraph(label="AI")
+                # FIXME: this produces broken output when there are paragraphs in orgname. I don't know how to fix this.
+                source.emit("</orgname>");
+            if self.jobtitle:
+                source.emit("        <jobtitle>%s</jobtitle>\n" % self.jobtitle)
+            if self.orgdiv:
+                source.emit("        <orgdiv>%s</orgdiv>\n" % self.orgdiv)
+            source.emit("    </affiliation>\n")
+        source.emit("</author>")
+    	
 
 class ManInterpreter:
     "Interpret man(7) macros."
@@ -6429,6 +6463,8 @@
         # Also ignore the Berkeley thesis-mode extension
         "TM":1, "CT":1, "XS":1, "XE":1, "XA":1, "PX":1, "AM":1,
         "EH":1, "OH":1, "EF":1, "OF":1,
+        # Occurs in X Consortium manpages redundant with .ta
+        "TA":1,
         # These are not documented in the ms reference, but
         # they occur in ms papers, probably as relics from mm.
         "MH":1, "CS":1, "D3":1
@@ -6480,10 +6516,11 @@
         self.pointsize = 0
         self.fmt = "R"
         self.TL = None
-        self.AU = None
-        self.AI = []
+        #self.AU = None
+        #self.AI = []
         self.AB = None
         self.flushed = False
+        self.authors = []
     def interpret(self, tokens, caller):
         command = tokens[0][1:]
         args = tokens[1:]
@@ -6534,6 +6571,17 @@
         elif command == "UC":
             self.source.pushline("<productname>%s</productname>" % args[0])
             return True
+        # some X11 extension
+        elif command == "PN":
+            # this is only correct most of the time, PN is used for lots of stuff
+            self.source.pushline("<function>%s</function>" % args[0])
+            return True
+        elif command == "Ds":
+            self.source.begin_block("literallayout", remap="Ds")
+            return True
+        elif command == "De":
+            self.source.end_block("literallayout", remap="De", ends="Ds")
+            return True
         # Commands for front matter
         elif command == "TL":
             self.source.declare_body_start()
@@ -6543,11 +6591,36 @@
             gather_lines(self.source)
             return True
         elif command == "AU":
-            self.AU = gather_lines(self.source)
+            rawlines = gather_lines(self.source)
+            # If there's only one line of authors, try to break it up by
+            # looking for " and ".  There are a couple of historical examples
+            # of this, notably in the EQN docs.
+            if len(rawlines) == 1:
+                trial = rawlines[0].split(" and ")
+                if trial > 1:
+                    rawlines = trial
+                else:
+                    # We'll also try splitting on commas
+                    trial = rawlines[0].split(", ")
+                    if trial > 1:
+                        rawlines = trial
+            # Now we have one author per line.  Try to analyze each name.
+            for name in rawlines:
+                author = Author(name)
+                self.authors.append(author)
             return True
         elif command == "AI":
-            self.source.diversion = self.AI
-            self.source.interpret_block(rawlines, self.AI)
+            #self.source.diversion = self.AI
+            #self.source.interpret_block(rawlines, self.AI)
+            
+            #rawlines = gather_lines(self.source)
+            #self.source.diversion = self.AI
+            #self.source.interpret_block(rawlines)
+            #self.source.diversion = self.source.output
+
+            #self.authors[-1].orgname = " ".join(gather_lines(self.source))
+            
+            self.authors[-1].orgname = gather_lines(self.source)
             return True
         elif command == "AB":
             self.AB = []
@@ -6563,37 +6636,16 @@
         if not self.flushed:
             self.source.preamble = False
             self.flushed = True
-            # If there's only one line of authors, try to break it up by
-            # looking for " and ".  There are a couple of historical examples
-            # of this, notably in the EQN docs.
-            if self.AU:
-                if len(self.AU) == 1:
-                    trial = self.AU[0].split(" and ")
-                    if trial > 1:
-                        self.AU = trial
-                    else:
-                        # We'll also try splitting on commas
-                        trial = self.AU[0].split(", ")
-                        if trial > 1:
-                            self.AU = trial
-                # Now we have one author per line.  Try to analyze each name.
-                digested = []
-                for name in self.AU:
-                    author = Author(name)
-                    if self.AI:
-                        author.orgname = " ".join(self.AI)
-                    digested.append(author)
             # OK, we've got enough info to generate the header
-            if self.TL or self.AU or self.AI or self.AB:
+            if self.TL or self.authors or self.AB:
                 self.source.end_paragraph(label="ms header")
                 self.source.emit("<articleinfo>")
                 if self.TL:
                     self.source.emit("<title>")
                     caller.interpret_block(self.TL)
                     self.source.emit("</title>")
-                for author in digested:
-                    if self.author.nonempty():
-                        self.source.emit(`author`)
+                for author in self.authors:
+                    author.emit(self.source)
                 if self.AB:
                     self.source.emit("<abstract>")
                     self.source.need_paragraph()

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

_______________________________________________
xorg mailing list
xorg@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/xorg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [X Forum]     [Intel Graphics]     [AMD Graphics]     [Nouveau Driver]     [XFree86]     [XFree86 Newbie]     [IETF Annouce]     [Security]     [Fontconfig]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Video for Linux]     [Linux RAID]

  Powered by Linux