| | 148 | docstr_fmt = '%s' |
|---|
| | 149 | elif output == 'reportlab_xml': |
|---|
| | 150 | newline = "<br/>\n" |
|---|
| | 151 | default_arg_fmt = '%s<font color="gray">=%s</font>' |
|---|
| | 152 | func_sig_fmt = '<b>%s</b>(%s)' |
|---|
| | 153 | function_fmt = '\n<para style="FunctionDef"> %s </para>\n' |
|---|
| | 154 | method_fmt = function_fmt |
|---|
| | 155 | staticmethod_fmt = function_fmt |
|---|
| | 156 | dict_fmt = '\n\n<para><b>%s</b> = { ' |
|---|
| | 157 | dict_fmt_end = '}</para>\n' |
|---|
| | 158 | data_element_fmt = "<para><b>%s</b> = %s</para>" |
|---|
| | 159 | table_begin = ''#"<table>[" |
|---|
| | 160 | table_end = ''#"]</table>" |
|---|
| | 161 | #table_row_fmt = "[ '%s', ':', '%s'],\n" |
|---|
| | 162 | table_row_fmt = "'%s': %s, " |
|---|
| | 163 | category_fmt = '\n<para style="Category">%s</para>\n' |
|---|
| | 164 | class_fmt = '\n<para style="Class">%s</para>\n' |
|---|
| | 165 | horiz_line = '' |
|---|
| | 166 | docstr_fmt = '<para>%s</para>' |
|---|
| | 204 | |
|---|
| | 205 | logging.info("==== FUNCTIONS ====") |
|---|
| | 206 | outputStr += category_fmt % "Functions" |
|---|
| | 207 | for funcname in functions: |
|---|
| | 208 | funcinst = eval('common.%s' % funcname) |
|---|
| | 209 | outputStr += function_fmt % func_sig(funcinst, default_arg_fmt, func_sig_fmt) |
|---|
| | 210 | if funcinst.__doc__: |
|---|
| | 211 | outputStr += docstr_fmt % _(funcinst.__doc__.strip()) |
|---|
| | 212 | |
|---|
| | 213 | logging.info("==== CLASSES ====") |
|---|
| | 214 | # sort classes by type: |
|---|
| | 215 | error_classes = {} |
|---|
| | 216 | celltype_classes = {} |
|---|
| | 217 | other_classes = {} |
|---|
| | 218 | for classname in classes.keys(): |
|---|
| | 219 | if classname.find('Error') > -1: |
|---|
| | 220 | error_classes[classname] = classes[classname] |
|---|
| | 221 | elif issubclass(eval('common.%s' % classname),common.StandardCellType): |
|---|
| | 222 | celltype_classes[classname] = classes[classname] |
|---|
| | 223 | else: |
|---|
| | 224 | other_classes[classname] = classes[classname] |
|---|
| | 225 | |
|---|
| | 226 | logging.info('Sorting classes...') |
|---|
| | 227 | logging.info('Error classes: %s' % ', '.join(error_classes.keys())) |
|---|
| | 228 | logging.info('Celltype classes: %s' % ', '.join(celltype_classes.keys())) |
|---|
| | 229 | logging.info('Other classes: %s' % ', '.join(other_classes.keys())) |
|---|
| | 230 | |
|---|
| | 231 | # Now iterate through the classes |
|---|
| | 232 | outputStr += category_fmt % "Classes" |
|---|
| | 233 | for classes in [celltype_classes, other_classes, error_classes]: |
|---|
| | 234 | classlist = classes.keys() |
|---|
| | 235 | classlist.sort() |
|---|
| | 236 | for classname in classlist: |
|---|
| | 237 | outputStr += class_fmt % classname |
|---|
| | 238 | docstr = eval('common.%s.__doc__' % classname) |
|---|
| | 239 | if docstr: |
|---|
| | 240 | outputStr += docstr_fmt % _(docstr) |
|---|
| | 241 | for methodname in classes[classname]['methods']: |
|---|
| | 242 | methodinst = eval('common.%s.%s' % (classname,methodname)) |
|---|
| | 243 | fs = func_sig(methodinst, default_arg_fmt, func_sig_fmt) |
|---|
| | 244 | if fs: |
|---|
| | 245 | outputStr += method_fmt % fs |
|---|
| | 246 | if methodinst.__doc__: |
|---|
| | 247 | outputStr += docstr_fmt % _(methodinst.__doc__.strip()) |
|---|
| | 248 | for methodname in classes[classname]['staticmethods']: |
|---|
| | 249 | methodinst = eval('common.%s.%s' % (classname,methodname)) |
|---|
| | 250 | fs = func_sig(methodinst, default_arg_fmt, func_sig_fmt) |
|---|
| | 251 | if fs: |
|---|
| | 252 | outputStr += staticmethod_fmt % fs |
|---|
| | 253 | if methodinst.__doc__: |
|---|
| | 254 | outputStr += docstr_fmt % _(methodinst.__doc__.strip()) |
|---|
| | 255 | for element in classes[classname]['data']: |
|---|
| | 256 | instance = eval('common.%s.%s' % (classname,element)) |
|---|
| | 257 | if type(instance) == types.DictType: |
|---|
| | 258 | outputStr += dict_fmt % element |
|---|
| | 259 | if len(instance) > 0: |
|---|
| | 260 | outputStr += table_begin |
|---|
| | 261 | for k,v in instance.items(): |
|---|
| | 262 | if output == 'latex': |
|---|
| | 263 | v = str(v).replace('{',' $\\lbrace$').replace('}',' $\\rbrace$') |
|---|
| | 264 | outputStr += table_row_fmt % (k,v) |
|---|
| | 265 | elif output == 'wiki': |
|---|
| | 266 | outputStr += table_row_fmt % ('"%s"' % k,v) |
|---|
| | 267 | elif output == 'trac': |
|---|
| | 268 | outputStr += table_row_fmt % ("'%s'" % k,v) |
|---|
| | 269 | elif output == 'reportlab_xml': |
|---|
| | 270 | outputStr += table_row_fmt % ("'%s'" % k,v) |
|---|
| | 271 | outputStr += table_end |
|---|
| | 272 | outputStr += dict_fmt_end |
|---|
| | 273 | else: |
|---|
| | 274 | outputStr += data_element_fmt % (element, instance) |
|---|
| | 275 | |
|---|
| | 276 | outputStr += horiz_line |
|---|
| 194 | | logging.info("==== FUNCTIONS ====") |
|---|
| 195 | | outputStr += category_fmt % "Functions" |
|---|
| 196 | | for funcname in functions: |
|---|
| 197 | | funcinst = eval('common.%s' % funcname) |
|---|
| 198 | | outputStr += function_fmt % func_sig(funcinst, default_arg_fmt, func_sig_fmt) |
|---|
| 199 | | if funcinst.__doc__: |
|---|
| 200 | | outputStr += _(funcinst.__doc__.strip()) |
|---|
| 201 | | |
|---|
| 202 | | logging.info("==== CLASSES ====") |
|---|
| 203 | | # sort classes by type: |
|---|
| 204 | | error_classes = {} |
|---|
| 205 | | celltype_classes = {} |
|---|
| 206 | | other_classes = {} |
|---|
| 207 | | for classname in classes.keys(): |
|---|
| 208 | | if classname.find('Error') > -1: |
|---|
| 209 | | error_classes[classname] = classes[classname] |
|---|
| 210 | | elif issubclass(eval('common.%s' % classname),common.StandardCellType): |
|---|
| 211 | | celltype_classes[classname] = classes[classname] |
|---|
| 212 | | else: |
|---|
| 213 | | other_classes[classname] = classes[classname] |
|---|
| 214 | | |
|---|
| 215 | | logging.info('Sorting classes...') |
|---|
| 216 | | logging.info('Error classes: %s' % ', '.join(error_classes.keys())) |
|---|
| 217 | | logging.info('Celltype classes: %s' % ', '.join(celltype_classes.keys())) |
|---|
| 218 | | logging.info('Other classes: %s' % ', '.join(other_classes.keys())) |
|---|
| 219 | | |
|---|
| 220 | | # Now iterate through the classes |
|---|
| 221 | | outputStr += category_fmt % "Classes" |
|---|
| 222 | | for classes in [celltype_classes, other_classes, error_classes]: |
|---|
| 223 | | classlist = classes.keys() |
|---|
| 224 | | classlist.sort() |
|---|
| 225 | | for classname in classlist: |
|---|
| 226 | | outputStr += class_fmt % classname |
|---|
| 227 | | docstr = eval('common.%s.__doc__' % classname) |
|---|
| 228 | | if docstr: |
|---|
| 229 | | outputStr += _(docstr) |
|---|
| 230 | | for methodname in classes[classname]['methods']: |
|---|
| 231 | | methodinst = eval('common.%s.%s' % (classname,methodname)) |
|---|
| 232 | | fs = func_sig(methodinst, default_arg_fmt, func_sig_fmt) |
|---|
| 233 | | if fs: |
|---|
| 234 | | outputStr += method_fmt % fs |
|---|
| 235 | | if methodinst.__doc__: |
|---|
| 236 | | outputStr += _(methodinst.__doc__.strip()) |
|---|
| 237 | | for methodname in classes[classname]['staticmethods']: |
|---|
| 238 | | methodinst = eval('common.%s.%s' % (classname,methodname)) |
|---|
| 239 | | fs = func_sig(methodinst, default_arg_fmt, func_sig_fmt) |
|---|
| 240 | | if fs: |
|---|
| 241 | | outputStr += staticmethod_fmt % fs |
|---|
| 242 | | if methodinst.__doc__: |
|---|
| 243 | | outputStr += _(methodinst.__doc__.strip()) |
|---|
| 244 | | for element in classes[classname]['data']: |
|---|
| 245 | | instance = eval('common.%s.%s' % (classname,element)) |
|---|
| 246 | | if type(instance) == types.DictType: |
|---|
| 247 | | outputStr += dict_fmt % element |
|---|
| 248 | | if len(instance) > 0: |
|---|
| 249 | | outputStr += table_begin |
|---|
| 250 | | for k,v in instance.items(): |
|---|
| 251 | | if output == 'latex': |
|---|
| 252 | | v = str(v).replace('{',' $\\lbrace$').replace('}',' $\\rbrace$') |
|---|
| 253 | | outputStr += table_row_fmt % (k,v) |
|---|
| 254 | | elif output == 'wiki': |
|---|
| 255 | | outputStr += table_row_fmt % ('"%s"' % k,v) |
|---|
| 256 | | elif output == 'trac': |
|---|
| 257 | | outputStr += table_row_fmt % ("'%s'" % k,v) |
|---|
| 258 | | outputStr += table_end |
|---|
| 259 | | outputStr += dict_fmt_end |
|---|
| 260 | | else: |
|---|
| 261 | | outputStr += data_element_fmt % (element, instance) |
|---|
| 262 | | |
|---|
| 263 | | outputStr += horiz_line |
|---|
| 264 | | |
|---|