diff options
author | Rob Austein <sra@hactrn.net> | 2007-07-07 17:04:37 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2007-07-07 17:04:37 +0000 |
commit | ed43d040bf72c2b8eb9d2cec3444556761b3c606 (patch) | |
tree | 57d47ba90cd2c6672f32f0a514c47058e23e3f90 /pow/POW-0.7/docs/doc.py | |
parent | 2d5c53975e6ddaec9ac3d49a70278fcdd584273d (diff) |
Add pow
svn path=/pow/POW-0.7/PKG-INFO; revision=722
Diffstat (limited to 'pow/POW-0.7/docs/doc.py')
-rwxr-xr-x | pow/POW-0.7/docs/doc.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/pow/POW-0.7/docs/doc.py b/pow/POW-0.7/docs/doc.py new file mode 100755 index 00000000..0a0e4450 --- /dev/null +++ b/pow/POW-0.7/docs/doc.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python + +import sys, string, os, commands + +class DocError(Exception): + def __init__(self, mesg): + self.mesg = mesg + + def __str__(self): + return self.mesg + +class Extractor: + def __init__(self, module): + exec('import %s' % module) + self.module = eval(module) + + def get(self): + fragments = '' + for doc in self.module._docset(): + fragments += doc + + return '<moduleSet>' + fragments + '</moduleSet>' + + +if __name__ == '__main__': + if len(sys.argv) < 2: + raise DocError( 'module name must be supplied') + + lines = '' + for mod in sys.argv[1:]: + print 'processing module', mod + ex = Extractor(mod) + lines += ex.get() + + file = open('fragments.xml', 'w') + file.write('%s\n%s\n%s' % ('<collection>', lines, '</collection>')) + file.close() + + print 'transforming document...' + (status, doc) = commands.getstatusoutput('java org.apache.xalan.xslt.Process -IN fragments.xml -XSL doc.xsl' ) + if status: + print doc + sys.exit(1) + + doc = doc.replace('/>', '>') + lines = string.split(doc, '\n') + lines[0] = '<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.1//EN">' + + file = open(sys.argv[1] + '.sgm', 'w') + file.write( string.join(lines, '\n') ) + file.close() + |