3 import sys, time, xml.dom.minidom
7 MANUAL="SOPE Dynamic Element Reference"
8 COPYRIGHT="SKYRIX Software AG"
10 HEADER=""".TH %(element)s %(section)i "%(month)s %(year)s" "SOPE" "%(manual)s"
11 .\\" DO NOT EDIT: this file got autogenerated using woapi2man from:
14 .\\" Copyright (C) %(year)s %(copy)s. All rights reserved.
15 .\\" ====================================================================
17 .\\" Copyright (C) %(year)s %(copy)s. All rights reserved.
19 .\\" Check the COPYING file for further information.
21 .\\" Created with the help of:
22 .\\" http://www.schweikhardt.net/man_page_howto.html
28 SOPE related bugs are collected in the OpenGroupware.org Bugzilla:
29 http://bugzilla.opengroupware.org/
34 The SOPE community <developer at opengroupware.org>.
39 .BR sope-ngobjweb-defaults
44 PASSTHROUGHTEXT="This binding is a pass-through binding.\n"
46 # Note: texts may not start with a single quote: '
47 DEFAULTSTEXT="Kind: %s\n"
49 'Page Names': "The value of '%(name)s' will be used to lookup a WOComponent page.\n",
50 'Actions': "The '%(name)s' binding is evaluated as an action (a method which returns a WOComponent or other WOActionResults object).\n",
51 'Resources': "The value of '%(name)s' refers to a resource which will be looked up using the WOResourceManager.\n",
52 'YES/NO': "The value of '%(name)s' will be evaluated in a boolean context.\n",
53 'Frameworks': "The value of '%(name)s' must be the name of a framework or bundle to be used for resource lookups.\n",
55 # 'Direct Actions': "The value of '%(name)s' refers to the name of a direct action method.\n",
56 # 'Direct Action Classes': "The value of '%(name)s' refers to the name of a direct action class.\n"
63 def __init__(self, _path, _dom):
73 def printManPageHeader(self, woroot):
74 self.out.write(HEADER % {
76 'element': woroot.getAttribute('class'),
78 'month': time.strftime("%B"),
79 'year': time.strftime("%Y"),
84 def printManPageName(self, woroot):
85 self.out.write("\n.SH NAME\n%s\n" % woroot.getAttribute('class'))
87 def printManPageBugs(self, woroot):
90 def printManPageAuthor(self, woroot):
91 self.out.write(AUTHOR)
93 def printManPageSeeAlso(self, woroot):
94 self.out.write(SEEALSO)
96 def printManPageFooter(self, woroot):
97 self.out.write(FOOTER)
99 def printSynopsis(self, woroot):
100 self.out.write("\n.SH SYNOPSIS\n")
101 self.out.write(".B %s\n" % woroot.getAttribute('class'))
103 for binding in woroot.getElementsByTagName("binding"):
104 self.out.write(" %s; " % binding.getAttribute('name'))
105 self.out.write("}\n")
107 def escapeText(self, text):
112 def getTextForBindingKind(self, binding, kind):
113 if kind is None: return
114 if len(kind) == 0: return
115 if KINDTOTEXT.has_key(kind):
116 info = { 'kind': kind,
117 'name': binding.getAttribute('name') }
122 return DEFAULTSTEXT % ( kind, )
124 def printBindings(self, woroot):
125 self.out.write("\n.SH BINDINGS\n")
126 for binding in woroot.getElementsByTagName("binding"):
127 self.out.write(".IP %s\n" % binding.getAttribute('name'))
128 s = binding.getAttribute('passthrough')
129 if (s and s == 'YES'):
130 self.out.write(PASSTHROUGHTEXT)
131 s = binding.getAttribute('defaults')
132 if (s and len(s) > 0):
133 self.out.write(self.getTextForBindingKind(binding, s))
135 def printValidation(self, woroot):
136 vals = woroot.getElementsByTagName("validation")
137 if (vals.length == 0): return
138 self.out.write("\n.SH VALIDATION\n")
140 m = val.getAttribute('message')
142 if len(m) == 0: continue
143 self.out.write("%s\n" % self.escapeText(m.capitalize()))
145 def processDOM(self):
146 woroot = self.dom.getElementsByTagName("wo")[0]
147 self.printManPageHeader(woroot)
148 self.printManPageName(woroot)
150 self.printSynopsis(woroot)
151 self.printValidation(woroot)
152 self.printBindings(woroot)
154 self.printManPageBugs(woroot)
155 self.printManPageAuthor(woroot)
156 self.printManPageSeeAlso(woroot)
157 self.printManPageFooter(woroot)
159 def processBinding(self, element):
160 print " check binding", element.getAttribute('name')
162 def processValidation(self, element):
163 print " check validation:", element.getAttribute('message')
165 def processWOTag(self, element):
166 print "check element class", element.getAttribute('class')
168 for binding in dom.getElementsByTagName("binding"):
169 self.processBinding(binding)
170 for subelem in dom.getElementsByTagName("validation"):
171 self.processValidation(subelem)
179 dom = xml.dom.minidom.parse(path)
181 sys.stderr.write("%s:0: %s\n" % ( path, e ))
182 except xml.parsers.expat.ExpatError, xmle:
183 sys.stderr.write("%s:%i: %s\n" % ( path, xmle.lineno, xmle ))
187 cpu = DOMToManPage(path, dom)