106 self.seeListTemplate = TemplatesListsStyleCSS.seeListTemplate |
106 self.seeListTemplate = TemplatesListsStyleCSS.seeListTemplate |
107 self.seeListEntryTemplate = TemplatesListsStyleCSS.seeListEntryTemplate |
107 self.seeListEntryTemplate = TemplatesListsStyleCSS.seeListEntryTemplate |
108 self.seeLinkTemplate = TemplatesListsStyleCSS.seeLinkTemplate |
108 self.seeLinkTemplate = TemplatesListsStyleCSS.seeLinkTemplate |
109 self.sinceInfoTemplate = TemplatesListsStyleCSS.sinceInfoTemplate |
109 self.sinceInfoTemplate = TemplatesListsStyleCSS.sinceInfoTemplate |
110 else: |
110 else: |
111 self.headerTemplate = TemplatesListsStyle.headerTemplate % colors |
111 self.headerTemplate = TemplatesListsStyle.headerTemplate.format(**colors) |
112 self.footerTemplate = TemplatesListsStyle.footerTemplate % colors |
112 self.footerTemplate = TemplatesListsStyle.footerTemplate.format(**colors) |
113 self.moduleTemplate = TemplatesListsStyle.moduleTemplate % colors |
113 self.moduleTemplate = TemplatesListsStyle.moduleTemplate.format(**colors) |
114 self.rbFileTemplate = TemplatesListsStyle.rbFileTemplate % colors |
114 self.rbFileTemplate = TemplatesListsStyle.rbFileTemplate.format(**colors) |
115 self.classTemplate = TemplatesListsStyle.classTemplate % colors |
115 self.classTemplate = TemplatesListsStyle.classTemplate.format(**colors) |
116 self.methodTemplate = TemplatesListsStyle.methodTemplate % colors |
116 self.methodTemplate = TemplatesListsStyle.methodTemplate.format(**colors) |
117 self.constructorTemplate = TemplatesListsStyle.constructorTemplate % colors |
117 self.constructorTemplate = \ |
118 self.rbModuleTemplate = TemplatesListsStyle.rbModuleTemplate % colors |
118 TemplatesListsStyle.constructorTemplate.format(**colors) |
|
119 self.rbModuleTemplate = TemplatesListsStyle.rbModuleTemplate.format(**colors) |
119 self.rbModulesClassTemplate = \ |
120 self.rbModulesClassTemplate = \ |
120 TemplatesListsStyle.rbModulesClassTemplate % colors |
121 TemplatesListsStyle.rbModulesClassTemplate.format(**colors) |
121 self.functionTemplate = TemplatesListsStyle.functionTemplate % colors |
122 self.functionTemplate = TemplatesListsStyle.functionTemplate.format(**colors) |
122 self.listTemplate = TemplatesListsStyle.listTemplate % colors |
123 self.listTemplate = TemplatesListsStyle.listTemplate.format(**colors) |
123 self.listEntryTemplate = TemplatesListsStyle.listEntryTemplate % colors |
124 self.listEntryTemplate = \ |
|
125 TemplatesListsStyle.listEntryTemplate.format(**colors) |
124 self.listEntryNoneTemplate = \ |
126 self.listEntryNoneTemplate = \ |
125 TemplatesListsStyle.listEntryNoneTemplate % colors |
127 TemplatesListsStyle.listEntryNoneTemplate.format(**colors) |
126 self.listEntryDeprecatedTemplate = \ |
128 self.listEntryDeprecatedTemplate = \ |
127 TemplatesListsStyle.listEntryDeprecatedTemplate % colors |
129 TemplatesListsStyle.listEntryDeprecatedTemplate.format(**colors) |
128 self.listEntrySimpleTemplate = \ |
130 self.listEntrySimpleTemplate = \ |
129 TemplatesListsStyle.listEntrySimpleTemplate % colors |
131 TemplatesListsStyle.listEntrySimpleTemplate.format(**colors) |
130 self.paragraphTemplate = TemplatesListsStyle.paragraphTemplate % colors |
132 self.paragraphTemplate = \ |
|
133 TemplatesListsStyle.paragraphTemplate.format(**colors) |
131 self.parametersListTemplate = \ |
134 self.parametersListTemplate = \ |
132 TemplatesListsStyle.parametersListTemplate % colors |
135 TemplatesListsStyle.parametersListTemplate.format(**colors) |
133 self.parametersListEntryTemplate = \ |
136 self.parametersListEntryTemplate = \ |
134 TemplatesListsStyle.parametersListEntryTemplate % colors |
137 TemplatesListsStyle.parametersListEntryTemplate.format(**colors) |
135 self.returnsTemplate = TemplatesListsStyle.returnsTemplate % colors |
138 self.returnsTemplate = TemplatesListsStyle.returnsTemplate.format(**colors) |
136 self.exceptionsListTemplate = \ |
139 self.exceptionsListTemplate = \ |
137 TemplatesListsStyle.exceptionsListTemplate % colors |
140 TemplatesListsStyle.exceptionsListTemplate.format(**colors) |
138 self.exceptionsListEntryTemplate = \ |
141 self.exceptionsListEntryTemplate = \ |
139 TemplatesListsStyle.exceptionsListEntryTemplate % colors |
142 TemplatesListsStyle.exceptionsListEntryTemplate.format(**colors) |
140 self.signalsListTemplate = TemplatesListsStyle.signalsListTemplate % colors |
143 self.signalsListTemplate = \ |
|
144 TemplatesListsStyle.signalsListTemplate.format(**colors) |
141 self.signalsListEntryTemplate = \ |
145 self.signalsListEntryTemplate = \ |
142 TemplatesListsStyle.signalsListEntryTemplate % colors |
146 TemplatesListsStyle.signalsListEntryTemplate.format(**colors) |
143 self.eventsListTemplate = TemplatesListsStyle.eventsListTemplate % colors |
147 self.eventsListTemplate = \ |
|
148 TemplatesListsStyle.eventsListTemplate.format(**colors) |
144 self.eventsListEntryTemplate = \ |
149 self.eventsListEntryTemplate = \ |
145 TemplatesListsStyle.eventsListEntryTemplate % colors |
150 TemplatesListsStyle.eventsListEntryTemplate.format(**colors) |
146 self.deprecatedTemplate = TemplatesListsStyle.deprecatedTemplate % colors |
151 self.deprecatedTemplate = \ |
147 self.authorInfoTemplate = TemplatesListsStyle.authorInfoTemplate % colors |
152 TemplatesListsStyle.deprecatedTemplate.format(**colors) |
148 self.seeListTemplate = TemplatesListsStyle.seeListTemplate % colors |
153 self.authorInfoTemplate = \ |
149 self.seeListEntryTemplate = TemplatesListsStyle.seeListEntryTemplate % colors |
154 TemplatesListsStyle.authorInfoTemplate.format(**colors) |
150 self.seeLinkTemplate = TemplatesListsStyle.seeLinkTemplate % colors |
155 self.seeListTemplate = TemplatesListsStyle.seeListTemplate.format(**colors) |
151 self.sinceInfoTemplate = TemplatesListsStyle.sinceInfoTemplate % colors |
156 self.seeListEntryTemplate = \ |
|
157 TemplatesListsStyle.seeListEntryTemplate.format(**colors) |
|
158 self.seeLinkTemplate = TemplatesListsStyle.seeLinkTemplate.format(**colors) |
|
159 self.sinceInfoTemplate = \ |
|
160 TemplatesListsStyle.sinceInfoTemplate.format(**colors) |
152 |
161 |
153 self.keywords = [] # list of tuples containing the name (string) and |
162 self.keywords = [] # list of tuples containing the name (string) and |
154 # the ref (string). The ref is without the filename part. |
163 # the ref (string). The ref is without the filename part. |
155 self.generated = False |
164 self.generated = False |
156 |
165 |
214 classList = self.__genClassListSection() |
223 classList = self.__genClassListSection() |
215 functionList = self.__genFunctionListSection() |
224 functionList = self.__genFunctionListSection() |
216 try: |
225 try: |
217 if self.module.type == RB_SOURCE: |
226 if self.module.type == RB_SOURCE: |
218 rbModulesList = self.__genRbModulesListSection() |
227 rbModulesList = self.__genRbModulesListSection() |
219 modBody = self.rbFileTemplate % { \ |
228 modBody = self.rbFileTemplate.format(**{ \ |
220 'Module' : self.module.name, |
229 'Module' : self.module.name, |
221 'ModuleDescription' : \ |
230 'ModuleDescription' : \ |
222 self.__formatDescription(self.module.description), |
231 self.__formatDescription(self.module.description), |
223 'GlobalsList' : globalsList, |
232 'GlobalsList' : globalsList, |
224 'ClassList' : classList, |
233 'ClassList' : classList, |
225 'RbModulesList' : rbModulesList, |
234 'RbModulesList' : rbModulesList, |
226 'FunctionList' : functionList, |
235 'FunctionList' : functionList, |
227 } |
236 }) |
228 else: |
237 else: |
229 modBody = self.moduleTemplate % { \ |
238 modBody = self.moduleTemplate.format(**{ \ |
230 'Module' : self.module.name, |
239 'Module' : self.module.name, |
231 'ModuleDescription' : \ |
240 'ModuleDescription' : \ |
232 self.__formatDescription(self.module.description), |
241 self.__formatDescription(self.module.description), |
233 'GlobalsList' : globalsList, |
242 'GlobalsList' : globalsList, |
234 'ClassList' : classList, |
243 'ClassList' : classList, |
235 'FunctionList' : functionList, |
244 'FunctionList' : functionList, |
236 } |
245 }) |
237 except TagError as e: |
246 except TagError as e: |
238 sys.stderr.write("Error in tags of description of module %s.\n" % \ |
247 sys.stderr.write("Error in tags of description of module {0}.\n".format( |
239 self.module.name) |
248 self.module.name)) |
240 sys.stderr.write("%s\n" % e) |
249 sys.stderr.write("{0}\n".format(e)) |
241 return "" |
250 return "" |
242 |
251 |
243 classesSection = self.__genClassesSection() |
252 classesSection = self.__genClassesSection() |
244 functionsSection = self.__genFunctionsSection() |
253 functionsSection = self.__genFunctionsSection() |
245 if self.module.type == RB_SOURCE: |
254 if self.module.type == RB_SOURCE: |
246 rbModulesSection = self.__genRbModulesSection() |
255 rbModulesSection = self.__genRbModulesSection() |
247 else: |
256 else: |
248 rbModulesSection = "" |
257 rbModulesSection = "" |
249 return "%s%s%s%s" % (modBody, classesSection, rbModulesSection, functionsSection) |
258 return "{0}{1}{2}{3}".format( |
|
259 modBody, classesSection, rbModulesSection, functionsSection) |
250 |
260 |
251 def __genListSection(self, names, dict, kwSuffix = ""): |
261 def __genListSection(self, names, dict, kwSuffix = ""): |
252 """ |
262 """ |
253 Private method to generate a list section of the document. |
263 Private method to generate a list section of the document. |
254 |
264 |
257 @param kwSuffix suffix to be used for the QtHelp keywords (string) |
267 @param kwSuffix suffix to be used for the QtHelp keywords (string) |
258 @return The list section. (string) |
268 @return The list section. (string) |
259 """ |
269 """ |
260 lst = [] |
270 lst = [] |
261 for name in names: |
271 for name in names: |
262 lst.append(self.listEntryTemplate % { \ |
272 lst.append(self.listEntryTemplate.format(**{ \ |
263 'Link' : "%s" % name, |
273 'Link' : "{0}".format(name), |
264 'Name' : dict[name].name, |
274 'Name' : dict[name].name, |
265 'Description' : self.__getShortDescription(dict[name].description), |
275 'Description' : self.__getShortDescription(dict[name].description), |
266 'Deprecated' : self.__checkDeprecated(dict[name].description) and \ |
276 'Deprecated' : self.__checkDeprecated(dict[name].description) and \ |
267 self.listEntryDeprecatedTemplate or "", |
277 self.listEntryDeprecatedTemplate or "", |
268 }) |
278 })) |
269 if kwSuffix: |
279 if kwSuffix: |
270 n = "%s (%s)" % (name, kwSuffix) |
280 n = "{0} ({1})".format(name, kwSuffix) |
271 else: |
281 else: |
272 n = "%s" % name |
282 n = "{0}".format(name) |
273 self.keywords.append((n, "#%s" % name)) |
283 self.keywords.append((n, "#{0}".format(name))) |
274 return ''.join(lst) |
284 return ''.join(lst) |
275 |
285 |
276 def __genGlobalsListSection(self, class_ = None): |
286 def __genGlobalsListSection(self, class_ = None): |
277 """ |
287 """ |
278 Private method to generate the section listing all global attributes of |
288 Private method to generate the section listing all global attributes of |
361 |
372 |
362 globalsList = self.__genGlobalsListSection(_class) |
373 globalsList = self.__genGlobalsListSection(_class) |
363 methList, methBodies = self.__genMethodSection(_class, className) |
374 methList, methBodies = self.__genMethodSection(_class, className) |
364 |
375 |
365 try: |
376 try: |
366 clsBody = self.classTemplate % { \ |
377 clsBody = self.classTemplate.format(**{ \ |
367 'Anchor' : className, |
378 'Anchor' : className, |
368 'Class' : _class.name, |
379 'Class' : _class.name, |
369 'ClassSuper' : supers, |
380 'ClassSuper' : supers, |
370 'ClassDescription' : self.__formatDescription(_class.description), |
381 'ClassDescription' : self.__formatDescription(_class.description), |
371 'GlobalsList' : globalsList, |
382 'GlobalsList' : globalsList, |
372 'MethodList' : methList, |
383 'MethodList' : methList, |
373 'MethodDetails' : methBodies, |
384 'MethodDetails' : methBodies, |
374 } |
385 }) |
375 except TagError as e: |
386 except TagError as e: |
376 sys.stderr.write("Error in tags of description of class %s.\n" % \ |
387 sys.stderr.write("Error in tags of description of class {0}.\n".format( |
377 className) |
388 className)) |
378 sys.stderr.write("%s\n" % e) |
389 sys.stderr.write("{0}\n".format(e)) |
379 clsBody = "" |
390 clsBody = "" |
380 |
391 |
381 classes.append(clsBody) |
392 classes.append(clsBody) |
382 |
393 |
383 return ''.join(classes) |
394 return ''.join(classes) |
392 @param clsName The visible class name containing the names. |
403 @param clsName The visible class name containing the names. |
393 @return The list section. (string) |
404 @return The list section. (string) |
394 """ |
405 """ |
395 lst = [] |
406 lst = [] |
396 try: |
407 try: |
397 lst.append(self.listEntryTemplate % { \ |
408 lst.append(self.listEntryTemplate.format(**{ \ |
398 'Link' : "%s.%s" % (className, '__init__'), |
409 'Link' : "{0}.{1}".format(className, '__init__'), |
399 'Name' : clsName, |
410 'Name' : clsName, |
400 'Description' : self.__getShortDescription(dict['__init__'].description), |
411 'Description' : self.__getShortDescription(dict['__init__'].description), |
401 'Deprecated' : self.__checkDeprecated(dict['__init__'].description) and \ |
412 'Deprecated' : self.__checkDeprecated(dict['__init__'].description) and \ |
402 self.listEntryDeprecatedTemplate or "", |
413 self.listEntryDeprecatedTemplate or "", |
403 }) |
414 })) |
404 self.keywords.append(("%s (Constructor)" % className, |
415 self.keywords.append(("{0} (Constructor)".format(className), |
405 "#%s.%s" % (className, '__init__'))) |
416 "#{0}.{1}".format(className, '__init__'))) |
406 except KeyError: |
417 except KeyError: |
407 pass |
418 pass |
408 |
419 |
409 for name in names: |
420 for name in names: |
410 lst.append(self.listEntryTemplate % { \ |
421 lst.append(self.listEntryTemplate.format(**{ \ |
411 'Link' : "%s.%s" % (className, name), |
422 'Link' : "{0}.{1}".format(className, name), |
412 'Name' : dict[name].name, |
423 'Name' : dict[name].name, |
413 'Description' : self.__getShortDescription(dict[name].description), |
424 'Description' : self.__getShortDescription(dict[name].description), |
414 'Deprecated' : self.__checkDeprecated(dict[name].description) and \ |
425 'Deprecated' : self.__checkDeprecated(dict[name].description) and \ |
415 self.listEntryDeprecatedTemplate or "", |
426 self.listEntryDeprecatedTemplate or "", |
416 }) |
427 })) |
417 self.keywords.append(("%s.%s" % (className, name), |
428 self.keywords.append(("{0}.{1}".format(className, name), |
418 "#%s.%s" % (className, name))) |
429 "#{0}.{1}".format(className, name))) |
419 return ''.join(lst) |
430 return ''.join(lst) |
420 |
431 |
421 def __genMethodSection(self, obj, className): |
432 def __genMethodSection(self, obj, className): |
422 """ |
433 """ |
423 Private method to generate the method details section. |
434 Private method to generate the method details section. |
430 methBodies = [] |
441 methBodies = [] |
431 methods = sorted(list(obj.methods.keys())) |
442 methods = sorted(list(obj.methods.keys())) |
432 if '__init__' in methods: |
443 if '__init__' in methods: |
433 methods.remove('__init__') |
444 methods.remove('__init__') |
434 try: |
445 try: |
435 methBody = self.constructorTemplate % { \ |
446 methBody = self.constructorTemplate.format(**{ \ |
436 'Anchor' : className, |
447 'Anchor' : className, |
437 'Class' : obj.name, |
448 'Class' : obj.name, |
438 'Method' : '__init__', |
449 'Method' : '__init__', |
439 'MethodDescription' : \ |
450 'MethodDescription' : \ |
440 self.__formatDescription(obj.methods['__init__'].description), |
451 self.__formatDescription(obj.methods['__init__'].description), |
441 'Params' : ', '.join(obj.methods['__init__'].parameters[1:]), |
452 'Params' : ', '.join(obj.methods['__init__'].parameters[1:]), |
442 } |
453 }) |
443 except TagError as e: |
454 except TagError as e: |
444 sys.stderr.write("Error in tags of description of method %s.%s.\n" % \ |
455 sys.stderr.write( |
445 (className, '__init__')) |
456 "Error in tags of description of method {0}.{1}.\n".format( |
446 sys.stderr.write("%s\n" % e) |
457 className, '__init__')) |
|
458 sys.stderr.write("{0}\n".format(e)) |
447 methBody = "" |
459 methBody = "" |
448 methBodies.append(methBody) |
460 methBodies.append(methBody) |
449 |
461 |
450 for method in methods: |
462 for method in methods: |
451 try: |
463 try: |
452 methBody = self.methodTemplate % { \ |
464 methBody = self.methodTemplate.format(**{ \ |
453 'Anchor' : className, |
465 'Anchor' : className, |
454 'Class' : obj.name, |
466 'Class' : obj.name, |
455 'Method' : obj.methods[method].name, |
467 'Method' : obj.methods[method].name, |
456 'MethodDescription' : \ |
468 'MethodDescription' : \ |
457 self.__formatDescription(obj.methods[method].description), |
469 self.__formatDescription(obj.methods[method].description), |
458 'Params' : ', '.join(obj.methods[method].parameters[1:]), |
470 'Params' : ', '.join(obj.methods[method].parameters[1:]), |
459 } |
471 }) |
460 except TagError as e: |
472 except TagError as e: |
461 sys.stderr.write("Error in tags of description of method %s.%s.\n" % \ |
473 sys.stderr.write( |
462 (className, method)) |
474 "Error in tags of description of method {0}.{1}.\n".format( |
463 sys.stderr.write("%s\n" % e) |
475 className, method)) |
|
476 sys.stderr.write("{0}\n".format(e)) |
464 methBody = "" |
477 methBody = "" |
465 methBodies.append(methBody) |
478 methBodies.append(methBody) |
466 |
479 |
467 methList = self.__genMethodsListSection(methods, obj.methods, className, obj.name) |
480 methList = self.__genMethodsListSection(methods, obj.methods, className, obj.name) |
468 |
481 |
469 if not methList: |
482 if not methList: |
470 methList = self.listEntryNoneTemplate |
483 methList = self.listEntryNoneTemplate |
471 return self.listTemplate % { \ |
484 return self.listTemplate.format(**{ \ |
472 'Entries' : methList, |
485 'Entries' : methList, |
473 }, ''.join(methBodies) |
486 }), ''.join(methBodies) |
474 |
487 |
475 def __genRbModulesSection(self): |
488 def __genRbModulesSection(self): |
476 """ |
489 """ |
477 Private method to generate the document section with details about Ruby modules. |
490 Private method to generate the document section with details about Ruby modules. |
478 |
491 |
486 methList, methBodies = self.__genMethodSection(rbModule, rbModuleName) |
499 methList, methBodies = self.__genMethodSection(rbModule, rbModuleName) |
487 classList, classBodies = \ |
500 classList, classBodies = \ |
488 self.__genRbModulesClassesSection(rbModule, rbModuleName) |
501 self.__genRbModulesClassesSection(rbModule, rbModuleName) |
489 |
502 |
490 try: |
503 try: |
491 rbmBody = self.rbModuleTemplate % { \ |
504 rbmBody = self.rbModuleTemplate.format(**{ \ |
492 'Anchor' : rbModuleName, |
505 'Anchor' : rbModuleName, |
493 'Module' : rbModule.name, |
506 'Module' : rbModule.name, |
494 'ModuleDescription' : self.__formatDescription(rbModule.description), |
507 'ModuleDescription' : self.__formatDescription(rbModule.description), |
495 'GlobalsList' : globalsList, |
508 'GlobalsList' : globalsList, |
496 'ClassesList' : classList, |
509 'ClassesList' : classList, |
497 'ClassesDetails' : classBodies, |
510 'ClassesDetails' : classBodies, |
498 'FunctionsList' : methList, |
511 'FunctionsList' : methList, |
499 'FunctionsDetails' : methBodies, |
512 'FunctionsDetails' : methBodies, |
500 } |
513 }) |
501 except TagError as e: |
514 except TagError as e: |
502 sys.stderr.write("Error in tags of description of Ruby module %s.\n" % \ |
515 sys.stderr.write( |
503 rbModuleName) |
516 "Error in tags of description of Ruby module {0}.\n".format( |
504 sys.stderr.write("%s\n" % e) |
517 rbModuleName)) |
|
518 sys.stderr.write("{0}\n".format(e)) |
505 rbmBody = "" |
519 rbmBody = "" |
506 |
520 |
507 rbModules.append(rbmBody) |
521 rbModules.append(rbmBody) |
508 |
522 |
509 return ''.join(rbModules) |
523 return ''.join(rbModules) |
527 supers = 'None' |
541 supers = 'None' |
528 |
542 |
529 methList, methBodies = self.__genMethodSection(_class, className) |
543 methList, methBodies = self.__genMethodSection(_class, className) |
530 |
544 |
531 try: |
545 try: |
532 clsBody = self.rbModulesClassTemplate % { \ |
546 clsBody = self.rbModulesClassTemplate.format(**{ \ |
533 'Anchor' : className, |
547 'Anchor' : className, |
534 'Class' : _class.name, |
548 'Class' : _class.name, |
535 'ClassSuper' : supers, |
549 'ClassSuper' : supers, |
536 'ClassDescription' : self.__formatDescription(_class.description), |
550 'ClassDescription' : self.__formatDescription(_class.description), |
537 'MethodList' : methList, |
551 'MethodList' : methList, |
538 'MethodDetails' : methBodies, |
552 'MethodDetails' : methBodies, |
539 } |
553 }) |
540 except TagError as e: |
554 except TagError as e: |
541 sys.stderr.write("Error in tags of description of class %s.\n" % \ |
555 sys.stderr.write("Error in tags of description of class {0}.\n".format( |
542 className) |
556 className)) |
543 sys.stderr.write("%s\n" % e) |
557 sys.stderr.write("{0}\n".format(e)) |
544 clsBody = "" |
558 clsBody = "" |
545 |
559 |
546 classes.append(clsBody) |
560 classes.append(clsBody) |
547 |
561 |
548 |
562 |
549 classesList = \ |
563 classesList = \ |
550 self.__genRbModulesClassesListSection(classNames, obj.classes, modName) |
564 self.__genRbModulesClassesListSection(classNames, obj.classes, modName) |
551 |
565 |
552 if not classesList: |
566 if not classesList: |
553 classesList = self.listEntryNoneTemplate |
567 classesList = self.listEntryNoneTemplate |
554 return self.listTemplate % { \ |
568 return self.listTemplate.format(**{ \ |
555 'Entries' : classesList, |
569 'Entries' : classesList, |
556 }, ''.join(classes) |
570 }), ''.join(classes) |
557 |
571 |
558 def __genRbModulesClassesListSection(self, names, dict, moduleName): |
572 def __genRbModulesClassesListSection(self, names, dict, moduleName): |
559 """ |
573 """ |
560 Private method to generate the classes list section of a Ruby module. |
574 Private method to generate the classes list section of a Ruby module. |
561 |
575 |
564 @param moduleName Name of the Ruby module containing the classes. (string) |
578 @param moduleName Name of the Ruby module containing the classes. (string) |
565 @return The list section. (string) |
579 @return The list section. (string) |
566 """ |
580 """ |
567 lst = [] |
581 lst = [] |
568 for name in names: |
582 for name in names: |
569 lst.append(self.listEntryTemplate % { \ |
583 lst.append(self.listEntryTemplate.format(**{ \ |
570 'Link' : "%s.%s" % (moduleName, name), |
584 'Link' : "{0}.{1}".format(moduleName, name), |
571 'Name' : dict[name].name, |
585 'Name' : dict[name].name, |
572 'Description' : self.__getShortDescription(dict[name].description), |
586 'Description' : self.__getShortDescription(dict[name].description), |
573 'Deprecated' : self.__checkDeprecated(dict[name].description) and \ |
587 'Deprecated' : self.__checkDeprecated(dict[name].description) and \ |
574 self.listEntryDeprecatedTemplate or "", |
588 self.listEntryDeprecatedTemplate or "", |
575 }) |
589 })) |
576 self.keywords.append(("%s.%s" % (moduleName, name), |
590 self.keywords.append(("{0}.{1}".format(moduleName, name), |
577 "#%s.%s" % (moduleName, name))) |
591 "#{0}.{1}".format(moduleName, name))) |
578 return ''.join(lst) |
592 return ''.join(lst) |
579 |
593 |
580 def __genFunctionsSection(self): |
594 def __genFunctionsSection(self): |
581 """ |
595 """ |
582 Private method to generate the document section with details about functions. |
596 Private method to generate the document section with details about functions. |
585 """ |
599 """ |
586 funcBodies = [] |
600 funcBodies = [] |
587 funcNames = sorted(list(self.module.functions.keys())) |
601 funcNames = sorted(list(self.module.functions.keys())) |
588 for funcName in funcNames: |
602 for funcName in funcNames: |
589 try: |
603 try: |
590 funcBody = self.functionTemplate % { \ |
604 funcBody = self.functionTemplate.format(**{ \ |
591 'Anchor' : funcName, |
605 'Anchor' : funcName, |
592 'Function' : self.module.functions[funcName].name, |
606 'Function' : self.module.functions[funcName].name, |
593 'FunctionDescription' : self.__formatDescription(\ |
607 'FunctionDescription' : self.__formatDescription(\ |
594 self.module.functions[funcName].description), |
608 self.module.functions[funcName].description), |
595 'Params' : ', '.join(self.module.functions[funcName].parameters), |
609 'Params' : ', '.join(self.module.functions[funcName].parameters), |
596 } |
610 }) |
597 except TagError as e: |
611 except TagError as e: |
598 sys.stderr.write("Error in tags of description of function %s.\n" % \ |
612 sys.stderr.write("Error in tags of description of function {0}.\n".format( |
599 funcName) |
613 funcName)) |
600 sys.stderr.write("%s\n" % e) |
614 sys.stderr.write("{0}\n".format(e)) |
601 funcBody = "" |
615 funcBody = "" |
602 |
616 |
603 funcBodies.append(funcBody) |
617 funcBodies.append(funcBody) |
604 |
618 |
605 return ''.join(funcBodies) |
619 return ''.join(funcBodies) |
781 """ |
795 """ |
782 start = desc.find('{@') |
796 start = desc.find('{@') |
783 while start != -1: |
797 while start != -1: |
784 stop = desc.find('}', start + 2) |
798 stop = desc.find('}', start + 2) |
785 if stop == -1: |
799 if stop == -1: |
786 raise TagError("Unterminated inline tag.\n%s" % desc) |
800 raise TagError("Unterminated inline tag.\n{0}".format(desc)) |
787 |
801 |
788 tagText = desc[start + 1:stop] |
802 tagText = desc[start + 1:stop] |
789 if tagText.startswith('@link'): |
803 if tagText.startswith('@link'): |
790 parts = tagText.split(None, 1) |
804 parts = tagText.split(None, 1) |
791 if len(parts) < 2: |
805 if len(parts) < 2: |
792 raise TagError("Wrong format in inline tag %s.\n%s" % \ |
806 raise TagError("Wrong format in inline tag {0}.\n{1}".format( |
793 (parts[0], desc)) |
807 parts[0], desc)) |
794 |
808 |
795 formattedTag = self.__formatCrossReferenceEntry(parts[1]) |
809 formattedTag = self.__formatCrossReferenceEntry(parts[1]) |
796 desc = desc.replace("{%s}" % tagText, formattedTag) |
810 desc = desc.replace("{{{0}}}".format(tagText), formattedTag) |
797 else: |
811 else: |
798 tag = tagText.split(None, 1)[0] |
812 tag = tagText.split(None, 1)[0] |
799 raise TagError("Unknown inline tag encountered, %s.\n%s" % \ |
813 raise TagError("Unknown inline tag encountered, {0}.\n{1}".format( |
800 (tag, desc)) |
814 tag, desc)) |
801 |
815 |
802 start = desc.find('{@') |
816 start = desc.find('{@') |
803 |
817 |
804 return desc |
818 return desc |
805 |
819 |
850 lastItem = paramList[-1][1] |
864 lastItem = paramList[-1][1] |
851 elif desc.startswith("@return"): |
865 elif desc.startswith("@return"): |
852 inTagSection = True |
866 inTagSection = True |
853 parts = desc.split(None, 1) |
867 parts = desc.split(None, 1) |
854 if len(parts) < 2: |
868 if len(parts) < 2: |
855 raise TagError("Wrong format in %s line.\n" % parts[0]) |
869 raise TagError("Wrong format in {0} line.\n".format(parts[0])) |
856 returns = [parts[1]] |
870 returns = [parts[1]] |
857 lastItem = returns |
871 lastItem = returns |
858 elif desc.startswith("@exception") or \ |
872 elif desc.startswith("@exception") or \ |
859 desc.startswith("@throws") or \ |
873 desc.startswith("@throws") or \ |
860 desc.startswith("@raise"): |
874 desc.startswith("@raise"): |
861 inTagSection = True |
875 inTagSection = True |
862 parts = desc.split(None, 2) |
876 parts = desc.split(None, 2) |
863 if len(parts) < 2: |
877 if len(parts) < 2: |
864 raise TagError("Wrong format in %s line.\n" % parts[0]) |
878 raise TagError("Wrong format in {0} line.\n".format(parts[0])) |
865 excName = parts[1] |
879 excName = parts[1] |
866 try: |
880 try: |
867 exceptionDict[excName] = [parts[2]] |
881 exceptionDict[excName] = [parts[2]] |
868 except IndexError: |
882 except IndexError: |
869 exceptionDict[excName] = [] |
883 exceptionDict[excName] = [] |
870 lastItem = exceptionDict[excName] |
884 lastItem = exceptionDict[excName] |
871 elif desc.startswith("@signal"): |
885 elif desc.startswith("@signal"): |
872 inTagSection = True |
886 inTagSection = True |
873 m = _signal(desc,0) |
887 m = _signal(desc,0) |
874 if m is None: |
888 if m is None: |
875 raise TagError("Wrong format in %s line.\n" % parts[0]) |
889 raise TagError("Wrong format in {0} line.\n".format(parts[0])) |
876 signalName = 1 and m.group("SignalName1") \ |
890 signalName = 1 and m.group("SignalName1") \ |
877 or m.group("SignalName2") |
891 or m.group("SignalName2") |
878 signalDesc = 1 and m.group("SignalDescription1") \ |
892 signalDesc = 1 and m.group("SignalDescription1") \ |
879 or m.group("SignalDescription2") |
893 or m.group("SignalDescription2") |
880 signalDict[signalName] = [] |
894 signalDict[signalName] = [] |
896 lastItem = eventDict[eventName] |
910 lastItem = eventDict[eventName] |
897 elif desc.startswith("@deprecated"): |
911 elif desc.startswith("@deprecated"): |
898 inTagSection = True |
912 inTagSection = True |
899 parts = desc.split(None, 1) |
913 parts = desc.split(None, 1) |
900 if len(parts) < 2: |
914 if len(parts) < 2: |
901 raise TagError("Wrong format in %s line.\n" % parts[0]) |
915 raise TagError("Wrong format in {0} line.\n".format(parts[0])) |
902 deprecated = [parts[1]] |
916 deprecated = [parts[1]] |
903 lastItem = deprecated |
917 lastItem = deprecated |
904 elif desc.startswith("@author"): |
918 elif desc.startswith("@author"): |
905 inTagSection = True |
919 inTagSection = True |
906 parts = desc.split(None, 1) |
920 parts = desc.split(None, 1) |
907 if len(parts) < 2: |
921 if len(parts) < 2: |
908 raise TagError("Wrong format in %s line.\n" % parts[0]) |
922 raise TagError("Wrong format in {0} line.\n".format(parts[0])) |
909 authorInfo = [parts[1]] |
923 authorInfo = [parts[1]] |
910 lastItem = authorInfo |
924 lastItem = authorInfo |
911 elif desc.startswith("@since"): |
925 elif desc.startswith("@since"): |
912 inTagSection = True |
926 inTagSection = True |
913 parts = desc.split(None, 1) |
927 parts = desc.split(None, 1) |
914 if len(parts) < 2: |
928 if len(parts) < 2: |
915 raise TagError("Wrong format in %s line.\n" % parts[0]) |
929 raise TagError("Wrong format in {0} line.\n".format(parts[0])) |
916 sinceInfo = [parts[1]] |
930 sinceInfo = [parts[1]] |
917 lastItem = sinceInfo |
931 lastItem = sinceInfo |
918 elif desc.startswith("@see"): |
932 elif desc.startswith("@see"): |
919 inTagSection = True |
933 inTagSection = True |
920 parts = desc.split(None, 1) |
934 parts = desc.split(None, 1) |
921 if len(parts) < 2: |
935 if len(parts) < 2: |
922 raise TagError("Wrong format in %s line.\n" % parts[0]) |
936 raise TagError("Wrong format in {0} line.\n".format(parts[0])) |
923 seeList.append([parts[1]]) |
937 seeList.append([parts[1]]) |
924 lastItem = seeList[-1] |
938 lastItem = seeList[-1] |
925 elif desc.startswith("@@"): |
939 elif desc.startswith("@@"): |
926 lastItem.append(desc[1:]) |
940 lastItem.append(desc[1:]) |
927 elif desc.startswith("@"): |
941 elif desc.startswith("@"): |
928 tag = desc.split(None, 1)[0] |
942 tag = desc.split(None, 1)[0] |
929 raise TagError("Unknown tag encountered, %s.\n" % tag) |
943 raise TagError("Unknown tag encountered, {0}.\n".format(tag)) |
930 else: |
944 else: |
931 lastItem.append(ditem) |
945 lastItem.append(ditem) |
932 elif not inTagSection: |
946 elif not inTagSection: |
933 lastItem.append(ditem) |
947 lastItem.append(ditem) |
934 |
948 |
936 description = self.__genParagraphs(paragraphs) |
950 description = self.__genParagraphs(paragraphs) |
937 else: |
951 else: |
938 description = "" |
952 description = "" |
939 |
953 |
940 if paramList: |
954 if paramList: |
941 parameterSect = self.parametersListTemplate % { \ |
955 parameterSect = self.parametersListTemplate.format(**{ \ |
942 'Parameters' : self.__genParamDescriptionListSection(paramList, |
956 'Parameters' : self.__genParamDescriptionListSection(paramList, |
943 self.parametersListEntryTemplate) |
957 self.parametersListEntryTemplate) |
944 } |
958 }) |
945 else: |
959 else: |
946 parameterSect = "" |
960 parameterSect = "" |
947 |
961 |
948 if returns: |
962 if returns: |
949 returnSect = self.returnsTemplate % html_uencode('\n'.join(returns)) |
963 returnSect = self.returnsTemplate.format(html_uencode('\n'.join(returns))) |
950 else: |
964 else: |
951 returnSect = "" |
965 returnSect = "" |
952 |
966 |
953 if exceptionDict: |
967 if exceptionDict: |
954 exceptionSect = self.exceptionsListTemplate % { \ |
968 exceptionSect = self.exceptionsListTemplate.format(**{ \ |
955 'Exceptions' : self.__genDescriptionListSection(exceptionDict, |
969 'Exceptions' : self.__genDescriptionListSection(exceptionDict, |
956 self.exceptionsListEntryTemplate) |
970 self.exceptionsListEntryTemplate) |
957 } |
971 }) |
958 else: |
972 else: |
959 exceptionSect = "" |
973 exceptionSect = "" |
960 |
974 |
961 if signalDict: |
975 if signalDict: |
962 signalSect = self.signalsListTemplate % { \ |
976 signalSect = self.signalsListTemplate.format(**{ \ |
963 'Signals' : self.__genDescriptionListSection(signalDict, |
977 'Signals' : self.__genDescriptionListSection(signalDict, |
964 self.signalsListEntryTemplate) |
978 self.signalsListEntryTemplate) |
965 } |
979 }) |
966 else: |
980 else: |
967 signalSect = "" |
981 signalSect = "" |
968 |
982 |
969 if eventDict: |
983 if eventDict: |
970 eventSect = self.eventsListTemplate % { \ |
984 eventSect = self.eventsListTemplate.format(**{ \ |
971 'Events' : self.__genDescriptionListSection(eventDict, |
985 'Events' : self.__genDescriptionListSection(eventDict, |
972 self.eventsListEntryTemplate) |
986 self.eventsListEntryTemplate) |
973 } |
987 }) |
974 else: |
988 else: |
975 eventSect = "" |
989 eventSect = "" |
976 |
990 |
977 if deprecated: |
991 if deprecated: |
978 deprecatedSect = self.deprecatedTemplate % { \ |
992 deprecatedSect = self.deprecatedTemplate.format(**{ \ |
979 'Lines' : html_uencode('\n'.join(deprecated)), |
993 'Lines' : html_uencode('\n'.join(deprecated)), |
980 } |
994 }) |
981 else: |
995 else: |
982 deprecatedSect = "" |
996 deprecatedSect = "" |
983 |
997 |
984 if authorInfo: |
998 if authorInfo: |
985 authorInfoSect = self.authorInfoTemplate % { \ |
999 authorInfoSect = self.authorInfoTemplate.format(**{ \ |
986 'Authors' : html_uencode('\n'.join(authorInfo)), |
1000 'Authors' : html_uencode('\n'.join(authorInfo)), |
987 } |
1001 }) |
988 else: |
1002 else: |
989 authorInfoSect = "" |
1003 authorInfoSect = "" |
990 |
1004 |
991 if sinceInfo: |
1005 if sinceInfo: |
992 sinceInfoSect = self.sinceInfoTemplate % { \ |
1006 sinceInfoSect = self.sinceInfoTemplate.format(**{ \ |
993 'Info' : html_uencode(sinceInfo[0]), |
1007 'Info' : html_uencode(sinceInfo[0]), |
994 } |
1008 }) |
995 else: |
1009 else: |
996 sinceInfoSect = "" |
1010 sinceInfoSect = "" |
997 |
1011 |
998 if seeList: |
1012 if seeList: |
999 seeSect = self.seeListTemplate % { \ |
1013 seeSect = self.seeListTemplate.format(**{ \ |
1000 'Links' : self.__genSeeListSection(seeList, self.seeListEntryTemplate), |
1014 'Links' : self.__genSeeListSection(seeList, self.seeListEntryTemplate), |
1001 } |
1015 }) |
1002 else: |
1016 else: |
1003 seeSect = '' |
1017 seeSect = '' |
1004 |
1018 |
1005 return "%s%s%s%s%s%s%s%s%s%s" % ( \ |
1019 return "{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}".format( |
1006 deprecatedSect, description, parameterSect, returnSect, |
1020 deprecatedSect, description, parameterSect, returnSect, |
1007 exceptionSect, signalSect, eventSect, authorInfoSect, |
1021 exceptionSect, signalSect, eventSect, authorInfoSect, |
1008 seeSect, sinceInfoSect |
1022 seeSect, sinceInfoSect |
1009 ) |
1023 ) |
1010 |
1024 |