view docs/make_hp_files.py @ 3141:717ced83b885

coco3: Build SD card device descriptors for CoCo3FPGA Added "CC3FPGAFLAGS = $(AFLAGS) -DCC3FPGA=1 $(FLAGS)" to "level2/coco3/modules/makefile" for flagging Coco3FPGA specific features in modules sources. Added "llcoco3fpga", "ddsd0_coco3fpga", "sd0_coco3fpga", and "sd1_coco3fpga" to the "coco3/modules/makefile" - RBF section, which also now adds all to the "NITROS9/MODULES/RBF" on all disk images for building new Coco3FPGA disks from NitrOS9. Added new descriptor section to the "level2/coco3/modules/makefile" reflecting the new Coco3FPGA SD card descriptors and their flags.
author Bill Pierce <merlinious999@gmail.com>
date Sat, 04 Feb 2017 11:06:28 +0100
parents 57b5e715a417
children
line wrap: on
line source

#!/usr/bin/env python
# This script is an attempt to build help-files from Docbook sources
# (It is not finished)
# You call it as:
#        ./make_hp_files.py os9guide/os9guide.docbook
#        ./make_hp_files.py ccguide/ccguide.docbook
#
# It requires:
#   Python 2.0 or later
# 
# Author:  Soren Roug
#
from sys import argv
import string 
from xml.sax import make_parser,handler
import sys
#from types import *

class HandleParsing(handler.ContentHandler):
    """Parse a Docbook file"""

    def __init__(self):
        self.__data = ''

    def printdata(self):
        print self.__data
        self.__data = ''

#<funcsynopsis>
#<funcprototype>
#<funcdef>char *<function>mktemp</function></funcdef>
#    <paramdef>char *<parameter>name</parameter></paramdef>
#</funcprototype>

    def startElement(self, tag, attrs):
        if tag == 'refname':
            self.__data = '@'

        elif tag == 'funcprototype':
            self.__data = ''

        elif tag == 'cmdsynopsis':
            self.__data = 'Syntax: '

        elif tag == 'arg':
            self.optional = 0
            if attrs.has_key('choice') and attrs['choice'] == "opt":
                self.optional = 1
                self.__data += '['

        elif tag == 'replaceable':
            self.__data += '<'
        elif tag in ('parameter','paramdef','funcdef','function',
                 'command','option'):
            pass
        else:
            self.__data = ''

    def endElement(self, tag):
        if tag == 'funcdef':
            self.__data += '()\n'

        elif tag == 'paramdef':
            self.__data += ';\n'

        elif tag == 'funcprototype':
            self.printdata()

        elif tag == 'refname':
            self.printdata()

        elif tag == 'refpurpose':
            self.purpose = self.__data

        elif tag == 'refentry':
            print "Usage: %s" % self.purpose

        elif tag == 'arg':
            if self.optional == 1:
                self.__data += ']'
            self.optional = 0

        elif tag == 'cmdsynopsis':
            self.printdata()

        elif tag == 'replaceable':
            self.__data += '>'

    def characters(self, text):
        if not text == '\n':
            self.__data += text

#   def handle_charref(self,ref):
#       self.handle_data('&#' + ref + ';')

#   def unknown_entityref(self,ref):
#       self.handle_data('&' + ref + ';')

#   def syntax_error(self,message):
#       pass

#-----------
parser = make_parser()
chandler = HandleParsing()
parser.setContentHandler(chandler)

for file in argv[1:]:
    f = open(file)
    if not f:
        raise IOError, "Failure in open %s" % file
    parser.parse(f)
    f.close()