300 else: |
300 else: |
301 rbModulesSection = "" |
301 rbModulesSection = "" |
302 return "{0}{1}{2}{3}".format( |
302 return "{0}{1}{2}{3}".format( |
303 modBody, classesSection, rbModulesSection, functionsSection) |
303 modBody, classesSection, rbModulesSection, functionsSection) |
304 |
304 |
305 def __genListSection(self, names, dict, kwSuffix=""): |
305 def __genListSection(self, names, sectionDict, kwSuffix=""): |
306 """ |
306 """ |
307 Private method to generate a list section of the document. |
307 Private method to generate a list section of the document. |
308 |
308 |
309 @param names The names to appear in the list. (list of strings) |
309 @param names The names to appear in the list. (list of strings) |
310 @param dict A dictionary containing all relevant information. |
310 @param sectionDict dictionary containing all relevant information |
|
311 (dict) |
311 @param kwSuffix suffix to be used for the QtHelp keywords (string) |
312 @param kwSuffix suffix to be used for the QtHelp keywords (string) |
312 @return The list section. (string) |
313 @return list section (string) |
313 """ |
314 """ |
314 lst = [] |
315 lst = [] |
315 for name in names: |
316 for name in names: |
316 lst.append(self.listEntryTemplate.format( |
317 lst.append(self.listEntryTemplate.format( |
317 **{'Link': "{0}".format(name), |
318 **{'Link': "{0}".format(name), |
318 'Name': dict[name].name, |
319 'Name': sectionDict[name].name, |
319 'Description': |
320 'Description': |
320 self.__getShortDescription(dict[name].description), |
321 self.__getShortDescription(sectionDict[name].description), |
321 'Deprecated': |
322 'Deprecated': |
322 self.__checkDeprecated(dict[name].description) and |
323 self.__checkDeprecated(sectionDict[name].description) and |
323 self.listEntryDeprecatedTemplate or "", |
324 self.listEntryDeprecatedTemplate or "", |
324 })) |
325 })) |
325 if kwSuffix: |
326 if kwSuffix: |
326 n = "{0} ({1})".format(name, kwSuffix) |
327 n = "{0} ({1})".format(name, kwSuffix) |
327 else: |
328 else: |
447 |
448 |
448 classes.append(clsBody) |
449 classes.append(clsBody) |
449 |
450 |
450 return ''.join(classes) |
451 return ''.join(classes) |
451 |
452 |
452 def __genMethodsListSection(self, names, dict, className, clsName, |
453 def __genMethodsListSection(self, names, sectionDict, className, clsName, |
453 includeInit=True): |
454 includeInit=True): |
454 """ |
455 """ |
455 Private method to generate the methods list section of a class. |
456 Private method to generate the methods list section of a class. |
456 |
457 |
457 @param names names to appear in the list (list of strings) |
458 @param names names to appear in the list (list of strings) |
458 @param dict dictionary containing all relevant information |
459 @param sectionDict dictionary containing all relevant information |
|
460 (dict) |
459 @param className class name containing the names |
461 @param className class name containing the names |
460 @param clsName visible class name containing the names |
462 @param clsName visible class name containing the names |
461 @param includeInit flag indicating to include the __init__ method |
463 @param includeInit flag indicating to include the __init__ method |
462 (boolean) |
464 (boolean) |
463 @return methods list section (string) |
465 @return methods list section (string) |
467 try: |
469 try: |
468 lst.append(self.listEntryTemplate.format( |
470 lst.append(self.listEntryTemplate.format( |
469 **{'Link': "{0}.{1}".format(className, '__init__'), |
471 **{'Link': "{0}.{1}".format(className, '__init__'), |
470 'Name': clsName, |
472 'Name': clsName, |
471 'Description': self.__getShortDescription( |
473 'Description': self.__getShortDescription( |
472 dict['__init__'].description), |
474 sectionDict['__init__'].description), |
473 'Deprecated': self.__checkDeprecated( |
475 'Deprecated': self.__checkDeprecated( |
474 dict['__init__'].description) and |
476 sectionDict['__init__'].description) and |
475 self.listEntryDeprecatedTemplate or "", |
477 self.listEntryDeprecatedTemplate or "", |
476 })) |
478 })) |
477 self.keywords.append( |
479 self.keywords.append( |
478 ("{0} (Constructor)".format(className), |
480 ("{0} (Constructor)".format(className), |
479 "#{0}.{1}".format(className, '__init__'))) |
481 "#{0}.{1}".format(className, '__init__'))) |
481 pass |
483 pass |
482 |
484 |
483 for name in names: |
485 for name in names: |
484 lst.append(self.listEntryTemplate.format( |
486 lst.append(self.listEntryTemplate.format( |
485 **{'Link': "{0}.{1}".format(className, name), |
487 **{'Link': "{0}.{1}".format(className, name), |
486 'Name': dict[name].name, |
488 'Name': sectionDict[name].name, |
487 'Description': |
489 'Description': |
488 self.__getShortDescription(dict[name].description), |
490 self.__getShortDescription(sectionDict[name].description), |
489 'Deprecated': |
491 'Deprecated': |
490 self.__checkDeprecated(dict[name].description) and |
492 self.__checkDeprecated(sectionDict[name].description) and |
491 self.listEntryDeprecatedTemplate or "", |
493 self.listEntryDeprecatedTemplate or "", |
492 })) |
494 })) |
493 self.keywords.append(("{0}.{1}".format(className, name), |
495 self.keywords.append(("{0}.{1}".format(className, name), |
494 "#{0}.{1}".format(className, name))) |
496 "#{0}.{1}".format(className, name))) |
495 return ''.join(lst) |
497 return ''.join(lst) |
496 |
498 |
497 def __genMethodSection(self, obj, className, filter): |
499 def __genMethodSection(self, obj, className, modifierFilter): |
498 """ |
500 """ |
499 Private method to generate the method details section. |
501 Private method to generate the method details section. |
500 |
502 |
501 @param obj reference to the object being formatted |
503 @param obj reference to the object being formatted |
502 @param className name of the class containing the method (string) |
504 @param className name of the class containing the method (string) |
503 @param filter filter value designating the method types |
505 @param modifierFilter filter value designating the method types |
504 @return method list and method details section (tuple of two string) |
506 @return method list and method details section (tuple of two string) |
505 """ |
507 """ |
506 methList = [] |
508 methList = [] |
507 methBodies = [] |
509 methBodies = [] |
508 methods = sorted([k for k in obj.methods.keys() |
510 methods = sorted(k for k in obj.methods.keys() |
509 if obj.methods[k].modifier == filter]) |
511 if obj.methods[k].modifier == modifierFilter) |
510 if '__init__' in methods: |
512 if '__init__' in methods: |
511 methods.remove('__init__') |
513 methods.remove('__init__') |
512 try: |
514 try: |
513 methBody = self.constructorTemplate.format( |
515 methBody = self.constructorTemplate.format( |
514 **{'Anchor': className, |
516 **{'Anchor': className, |
528 className, '__init__')) |
530 className, '__init__')) |
529 sys.stderr.write("{0}\n".format(e)) |
531 sys.stderr.write("{0}\n".format(e)) |
530 methBody = "" |
532 methBody = "" |
531 methBodies.append(methBody) |
533 methBodies.append(methBody) |
532 |
534 |
533 if filter == Function.Class: |
535 if modifierFilter == Function.Class: |
534 methodClassifier = " (class method)" |
536 methodClassifier = " (class method)" |
535 elif filter == Function.Static: |
537 elif modifierFilter == Function.Static: |
536 methodClassifier = " (static)" |
538 methodClassifier = " (static)" |
537 else: |
539 else: |
538 methodClassifier = "" |
540 methodClassifier = "" |
539 for method in methods: |
541 for method in methods: |
540 try: |
542 try: |
558 methBody = "" |
560 methBody = "" |
559 methBodies.append(methBody) |
561 methBodies.append(methBody) |
560 |
562 |
561 methList = self.__genMethodsListSection( |
563 methList = self.__genMethodsListSection( |
562 methods, obj.methods, className, obj.name, |
564 methods, obj.methods, className, obj.name, |
563 includeInit=filter == Function.General) |
565 includeInit=modifierFilter == Function.General) |
564 |
566 |
565 if not methList: |
567 if not methList: |
566 methList = self.listEntryNoneTemplate |
568 methList = self.listEntryNoneTemplate |
567 return (self.listTemplate.format(**{'Entries': methList}), |
569 return (self.listTemplate.format(**{'Entries': methList}), |
568 ''.join(methBodies)) |
570 ''.join(methBodies)) |
658 if not classesList: |
660 if not classesList: |
659 classesList = self.listEntryNoneTemplate |
661 classesList = self.listEntryNoneTemplate |
660 return (self.listTemplate.format(**{'Entries': classesList}), |
662 return (self.listTemplate.format(**{'Entries': classesList}), |
661 ''.join(classes)) |
663 ''.join(classes)) |
662 |
664 |
663 def __genRbModulesClassesListSection(self, names, dict, moduleName): |
665 def __genRbModulesClassesListSection(self, names, sectionDict, moduleName): |
664 """ |
666 """ |
665 Private method to generate the classes list section of a Ruby module. |
667 Private method to generate the classes list section of a Ruby module. |
666 |
668 |
667 @param names The names to appear in the list. (list of strings) |
669 @param names The names to appear in the list. (list of strings) |
668 @param dict A dictionary containing all relevant information. |
670 @param sectionDict dictionary containing all relevant information |
669 @param moduleName Name of the Ruby module containing the classes. |
671 (dict) |
|
672 @param moduleName name of the Ruby module containing the classes |
670 (string) |
673 (string) |
671 @return The list section. (string) |
674 @return The list section. (string) |
672 """ |
675 """ |
673 lst = [] |
676 lst = [] |
674 for name in names: |
677 for name in names: |
675 lst.append(self.listEntryTemplate.format( |
678 lst.append(self.listEntryTemplate.format( |
676 **{'Link': "{0}.{1}".format(moduleName, name), |
679 **{'Link': "{0}.{1}".format(moduleName, name), |
677 'Name': dict[name].name, |
680 'Name': sectionDict[name].name, |
678 'Description': |
681 'Description': |
679 self.__getShortDescription(dict[name].description), |
682 self.__getShortDescription(sectionDict[name].description), |
680 'Deprecated': |
683 'Deprecated': |
681 self.__checkDeprecated(dict[name].description) and |
684 self.__checkDeprecated(sectionDict[name].description) and |
682 self.listEntryDeprecatedTemplate or "", |
685 self.listEntryDeprecatedTemplate or "", |
683 })) |
686 })) |
684 self.keywords.append(("{0}.{1}".format(moduleName, name), |
687 self.keywords.append(("{0}.{1}".format(moduleName, name), |
685 "#{0}.{1}".format(moduleName, name))) |
688 "#{0}.{1}".format(moduleName, name))) |
686 return ''.join(lst) |
689 return ''.join(lst) |