64 """ |
64 """ |
65 def __init__(self, module): |
65 def __init__(self, module): |
66 """ |
66 """ |
67 Constructor |
67 Constructor |
68 |
68 |
69 @param outputDir The output directory for the files |
69 @param module information of the parsed Python file |
70 @type str |
70 @type str |
71 """ |
71 """ |
72 self.module = module |
72 self.module = module |
73 self.empty = True |
73 self.empty = True |
74 |
|
75 # TODO: replace these assignments |
|
76 self.headerTemplate = TemplatesListsStyleCSS.headerTemplate |
|
77 self.footerTemplate = TemplatesListsStyleCSS.footerTemplate |
|
78 self.moduleTemplate = TemplatesListsStyleCSS.moduleTemplate |
|
79 self.rbFileTemplate = TemplatesListsStyleCSS.rbFileTemplate |
|
80 self.classTemplate = TemplatesListsStyleCSS.classTemplate |
|
81 self.methodTemplate = TemplatesListsStyleCSS.methodTemplate |
|
82 self.constructorTemplate = ( |
|
83 TemplatesListsStyleCSS.constructorTemplate) |
|
84 self.rbModuleTemplate = TemplatesListsStyleCSS.rbModuleTemplate |
|
85 self.rbModulesClassTemplate = ( |
|
86 TemplatesListsStyleCSS.rbModulesClassTemplate) |
|
87 self.functionTemplate = TemplatesListsStyleCSS.functionTemplate |
|
88 self.listTemplate = TemplatesListsStyleCSS.listTemplate |
|
89 self.listEntryTemplate = TemplatesListsStyleCSS.listEntryTemplate |
|
90 self.listEntryNoneTemplate = ( |
|
91 TemplatesListsStyleCSS.listEntryNoneTemplate) |
|
92 self.listEntryDeprecatedTemplate = ( |
|
93 TemplatesListsStyleCSS.listEntryDeprecatedTemplate) |
|
94 self.listEntrySimpleTemplate = ( |
|
95 TemplatesListsStyleCSS.listEntrySimpleTemplate) |
|
96 self.paragraphTemplate = TemplatesListsStyleCSS.paragraphTemplate |
|
97 self.parametersListTemplate = ( |
|
98 TemplatesListsStyleCSS.parametersListTemplate) |
|
99 self.parameterTypesListEntryTemplate = ( |
|
100 TemplatesListsStyleCSS.parameterTypesListEntryTemplate) |
|
101 self.parametersListEntryTemplate = ( |
|
102 TemplatesListsStyleCSS.parametersListEntryTemplate) |
|
103 self.returnsTemplate = TemplatesListsStyleCSS.returnsTemplate |
|
104 self.returnTypesTemplate = ( |
|
105 TemplatesListsStyleCSS.returnTypesTemplate) |
|
106 self.yieldsTemplate = TemplatesListsStyleCSS.yieldsTemplate |
|
107 self.yieldTypesTemplate = ( |
|
108 TemplatesListsStyleCSS.yieldTypesTemplate) |
|
109 self.exceptionsListTemplate = ( |
|
110 TemplatesListsStyleCSS.exceptionsListTemplate) |
|
111 self.exceptionsListEntryTemplate = ( |
|
112 TemplatesListsStyleCSS.exceptionsListEntryTemplate) |
|
113 self.signalsListTemplate = ( |
|
114 TemplatesListsStyleCSS.signalsListTemplate) |
|
115 self.signalsListEntryTemplate = ( |
|
116 TemplatesListsStyleCSS.signalsListEntryTemplate) |
|
117 self.eventsListTemplate = TemplatesListsStyleCSS.eventsListTemplate |
|
118 self.eventsListEntryTemplate = ( |
|
119 TemplatesListsStyleCSS.eventsListEntryTemplate) |
|
120 self.deprecatedTemplate = TemplatesListsStyleCSS.deprecatedTemplate |
|
121 self.authorInfoTemplate = TemplatesListsStyleCSS.authorInfoTemplate |
|
122 self.seeListTemplate = TemplatesListsStyleCSS.seeListTemplate |
|
123 self.seeListEntryTemplate = ( |
|
124 TemplatesListsStyleCSS.seeListEntryTemplate) |
|
125 self.seeLinkTemplate = TemplatesListsStyleCSS.seeLinkTemplate |
|
126 self.sinceInfoTemplate = TemplatesListsStyleCSS.sinceInfoTemplate |
|
127 |
74 |
128 self.keywords = [] |
75 self.keywords = [] |
129 # list of tuples containing the name (string) and |
76 # list of tuples containing the name (string) and |
130 # the ref (string). The ref is without the filename part. |
77 # the ref (string). The ref is without the filename part. |
131 self.generated = False |
78 self.generated = False |
172 Public method to generate the source code documentation. |
119 Public method to generate the source code documentation. |
173 |
120 |
174 @return The source code documentation. (string) |
121 @return The source code documentation. (string) |
175 """ |
122 """ |
176 doc = ( |
123 doc = ( |
177 self.headerTemplate.format( |
124 TemplatesListsStyleCSS.headerTemplate.format( |
178 **{'Title': self.module.name} |
125 **{'Title': self.module.name} |
179 ) + |
126 ) + |
180 self.__genModuleSection() + |
127 self.__genModuleSection() + |
181 self.footerTemplate |
128 TemplatesListsStyleCSS.footerTemplate |
182 ) |
129 ) |
183 self.generated = True |
130 self.generated = True |
184 return doc |
131 return doc |
185 |
132 |
186 def __genModuleSection(self): |
133 def __genModuleSection(self): |
193 classList = self.__genClassListSection() |
140 classList = self.__genClassListSection() |
194 functionList = self.__genFunctionListSection() |
141 functionList = self.__genFunctionListSection() |
195 try: |
142 try: |
196 if self.module.type == RB_SOURCE: |
143 if self.module.type == RB_SOURCE: |
197 rbModulesList = self.__genRbModulesListSection() |
144 rbModulesList = self.__genRbModulesListSection() |
198 modBody = self.rbFileTemplate.format( |
145 modBody = TemplatesListsStyleCSS.rbFileTemplate.format( |
199 **{'Module': self.module.name, |
146 **{'Module': self.module.name, |
200 'ModuleDescription': |
147 'ModuleDescription': |
201 self.__formatDescription(self.module.description), |
148 self.__formatDescription(self.module.description), |
202 'GlobalsList': globalsList, |
149 'GlobalsList': globalsList, |
203 'ClassList': classList, |
150 'ClassList': classList, |
204 'RbModulesList': rbModulesList, |
151 'RbModulesList': rbModulesList, |
205 'FunctionList': functionList, |
152 'FunctionList': functionList, |
206 }) |
153 }) |
207 else: |
154 else: |
208 modBody = self.moduleTemplate.format( |
155 modBody = TemplatesListsStyleCSS.moduleTemplate.format( |
209 **{'Module': self.module.name, |
156 **{'Module': self.module.name, |
210 'ModuleDescription': |
157 'ModuleDescription': |
211 self.__formatDescription(self.module.description), |
158 self.__formatDescription(self.module.description), |
212 'GlobalsList': globalsList, |
159 'GlobalsList': globalsList, |
213 'ClassList': classList, |
160 'ClassList': classList, |
242 @param kwSuffix suffix to be used for the QtHelp keywords (string) |
189 @param kwSuffix suffix to be used for the QtHelp keywords (string) |
243 @return list section (string) |
190 @return list section (string) |
244 """ |
191 """ |
245 lst = [] |
192 lst = [] |
246 for name in names: |
193 for name in names: |
247 lst.append(self.listEntryTemplate.format( |
194 lst.append(TemplatesListsStyleCSS.listEntryTemplate.format( |
248 **{'Link': "{0}".format(name), |
195 **{'Link': "{0}".format(name), |
249 'Name': sectionDict[name].name, |
196 'Name': sectionDict[name].name, |
250 'Description': |
197 'Description': |
251 self.__getShortDescription(sectionDict[name].description), |
198 self.__getShortDescription(sectionDict[name].description), |
252 'Deprecated': |
199 'Deprecated': |
253 self.__checkDeprecated(sectionDict[name].description) and |
200 self.__checkDeprecated(sectionDict[name].description) and |
254 self.listEntryDeprecatedTemplate or "", |
201 TemplatesListsStyleCSS.listEntryDeprecatedTemplate or "", |
255 })) |
202 })) |
256 n = ("{0} ({1})".format(name, kwSuffix) if kwSuffix |
203 n = ("{0} ({1})".format(name, kwSuffix) if kwSuffix |
257 else "{0}".format(name)) |
204 else "{0}".format(name)) |
258 self.keywords.append((n, "#{0}".format(name))) |
205 self.keywords.append((n, "#{0}".format(name))) |
259 return ''.join(lst) |
206 return ''.join(lst) |
270 scope = class_ if class_ is not None else self.module |
217 scope = class_ if class_ is not None else self.module |
271 attrNames = sorted(attr for attr in scope.globals.keys() |
218 attrNames = sorted(attr for attr in scope.globals.keys() |
272 if not scope.globals[attr].isSignal) |
219 if not scope.globals[attr].isSignal) |
273 s = ( |
220 s = ( |
274 ''.join( |
221 ''.join( |
275 [self.listEntrySimpleTemplate.format(**{'Name': name}) |
222 [TemplatesListsStyleCSS.listEntrySimpleTemplate |
276 for name in attrNames]) |
223 .format(**{'Name': name}) for name in attrNames]) |
277 if attrNames else |
224 if attrNames else |
278 self.listEntryNoneTemplate |
225 TemplatesListsStyleCSS.listEntryNoneTemplate |
279 ) |
226 ) |
280 return self.listTemplate.format(**{'Entries': s}) |
227 return TemplatesListsStyleCSS.listTemplate.format(**{'Entries': s}) |
281 |
228 |
282 def __genClassListSection(self): |
229 def __genClassListSection(self): |
283 """ |
230 """ |
284 Private method to generate the section listing all classes of the |
231 Private method to generate the section listing all classes of the |
285 module. |
232 module. |
289 names = sorted(list(self.module.classes.keys())) |
236 names = sorted(list(self.module.classes.keys())) |
290 if names: |
237 if names: |
291 self.empty = False |
238 self.empty = False |
292 s = self.__genListSection(names, self.module.classes) |
239 s = self.__genListSection(names, self.module.classes) |
293 else: |
240 else: |
294 s = self.listEntryNoneTemplate |
241 s = TemplatesListsStyleCSS.listEntryNoneTemplate |
295 return self.listTemplate.format(**{'Entries': s}) |
242 return TemplatesListsStyleCSS.listTemplate.format(**{'Entries': s}) |
296 |
243 |
297 def __genRbModulesListSection(self): |
244 def __genRbModulesListSection(self): |
298 """ |
245 """ |
299 Private method to generate the section listing all modules of the file |
246 Private method to generate the section listing all modules of the file |
300 (Ruby only). |
247 (Ruby only). |
304 names = sorted(list(self.module.modules.keys())) |
251 names = sorted(list(self.module.modules.keys())) |
305 if names: |
252 if names: |
306 self.empty = False |
253 self.empty = False |
307 s = self.__genListSection(names, self.module.modules) |
254 s = self.__genListSection(names, self.module.modules) |
308 else: |
255 else: |
309 s = self.listEntryNoneTemplate |
256 s = TemplatesListsStyleCSS.listEntryNoneTemplate |
310 return self.listTemplate.format(**{'Entries': s}) |
257 return TemplatesListsStyleCSS.listTemplate.format(**{'Entries': s}) |
311 |
258 |
312 def __genFunctionListSection(self): |
259 def __genFunctionListSection(self): |
313 """ |
260 """ |
314 Private method to generate the section listing all functions of the |
261 Private method to generate the section listing all functions of the |
315 module. |
262 module. |
345 _class, className, Function.General) |
292 _class, className, Function.General) |
346 staticMethList, staticMethBodies = self.__genMethodSection( |
293 staticMethList, staticMethBodies = self.__genMethodSection( |
347 _class, className, Function.Static) |
294 _class, className, Function.Static) |
348 |
295 |
349 try: |
296 try: |
350 clsBody = self.classTemplate.format( |
297 clsBody = TemplatesListsStyleCSS.classTemplate.format( |
351 **{'Anchor': className, |
298 **{'Anchor': className, |
352 'Class': _class.name, |
299 'Class': _class.name, |
353 'ClassSuper': supers, |
300 'ClassSuper': supers, |
354 'ClassDescription': |
301 'ClassDescription': |
355 self.__formatDescription(_class.description), |
302 self.__formatDescription(_class.description), |
388 @return methods list section (string) |
335 @return methods list section (string) |
389 """ |
336 """ |
390 lst = [] |
337 lst = [] |
391 if includeInit: |
338 if includeInit: |
392 with contextlib.suppress(KeyError): |
339 with contextlib.suppress(KeyError): |
393 lst.append(self.listEntryTemplate.format( |
340 lst.append(TemplatesListsStyleCSS.listEntryTemplate.format( |
394 **{'Link': "{0}.{1}".format(className, '__init__'), |
341 **{'Link': "{0}.{1}".format(className, '__init__'), |
395 'Name': clsName, |
342 'Name': clsName, |
396 'Description': self.__getShortDescription( |
343 'Description': self.__getShortDescription( |
397 sectionDict['__init__'].description), |
344 sectionDict['__init__'].description), |
398 'Deprecated': self.__checkDeprecated( |
345 'Deprecated': self.__checkDeprecated( |
399 sectionDict['__init__'].description) and |
346 sectionDict['__init__'].description) and |
400 self.listEntryDeprecatedTemplate or "", |
347 TemplatesListsStyleCSS.listEntryDeprecatedTemplate or |
|
348 "", |
401 })) |
349 })) |
402 self.keywords.append( |
350 self.keywords.append( |
403 ("{0} (Constructor)".format(className), |
351 ("{0} (Constructor)".format(className), |
404 "#{0}.{1}".format(className, '__init__'))) |
352 "#{0}.{1}".format(className, '__init__'))) |
405 |
353 |
406 for name in names: |
354 for name in names: |
407 lst.append(self.listEntryTemplate.format( |
355 lst.append(TemplatesListsStyleCSS.listEntryTemplate.format( |
408 **{'Link': "{0}.{1}".format(className, name), |
356 **{'Link': "{0}.{1}".format(className, name), |
409 'Name': sectionDict[name].name, |
357 'Name': sectionDict[name].name, |
410 'Description': |
358 'Description': |
411 self.__getShortDescription(sectionDict[name].description), |
359 self.__getShortDescription(sectionDict[name].description), |
412 'Deprecated': |
360 'Deprecated': |
413 self.__checkDeprecated(sectionDict[name].description) and |
361 self.__checkDeprecated(sectionDict[name].description) and |
414 self.listEntryDeprecatedTemplate or "", |
362 TemplatesListsStyleCSS.listEntryDeprecatedTemplate or "", |
415 })) |
363 })) |
416 self.keywords.append(("{0}.{1}".format(className, name), |
364 self.keywords.append(("{0}.{1}".format(className, name), |
417 "#{0}.{1}".format(className, name))) |
365 "#{0}.{1}".format(className, name))) |
418 return ''.join(lst) |
366 return ''.join(lst) |
419 |
367 |
431 methods = sorted(k for k in obj.methods.keys() |
379 methods = sorted(k for k in obj.methods.keys() |
432 if obj.methods[k].modifier == modifierFilter) |
380 if obj.methods[k].modifier == modifierFilter) |
433 if '__init__' in methods: |
381 if '__init__' in methods: |
434 methods.remove('__init__') |
382 methods.remove('__init__') |
435 try: |
383 try: |
436 methBody = self.constructorTemplate.format( |
384 methBody = TemplatesListsStyleCSS.constructorTemplate.format( |
437 **{'Anchor': className, |
385 **{'Anchor': className, |
438 'Class': obj.name, |
386 'Class': obj.name, |
439 'Method': '__init__', |
387 'Method': '__init__', |
440 'MethodDescription': |
388 'MethodDescription': |
441 self.__formatDescription( |
389 self.__formatDescription( |
459 methodClassifier = " (static)" |
407 methodClassifier = " (static)" |
460 else: |
408 else: |
461 methodClassifier = "" |
409 methodClassifier = "" |
462 for method in methods: |
410 for method in methods: |
463 try: |
411 try: |
464 methBody = self.methodTemplate.format( |
412 methBody = TemplatesListsStyleCSS.methodTemplate.format( |
465 **{'Anchor': className, |
413 **{'Anchor': className, |
466 'Class': obj.name, |
414 'Class': obj.name, |
467 'Method': obj.methods[method].name, |
415 'Method': obj.methods[method].name, |
468 'MethodClassifier': methodClassifier, |
416 'MethodClassifier': methodClassifier, |
469 'MethodDescription': |
417 'MethodDescription': |
484 methList = self.__genMethodsListSection( |
432 methList = self.__genMethodsListSection( |
485 methods, obj.methods, className, obj.name, |
433 methods, obj.methods, className, obj.name, |
486 includeInit=modifierFilter == Function.General) |
434 includeInit=modifierFilter == Function.General) |
487 |
435 |
488 if not methList: |
436 if not methList: |
489 methList = self.listEntryNoneTemplate |
437 methList = TemplatesListsStyleCSS.listEntryNoneTemplate |
490 return (self.listTemplate.format(**{'Entries': methList}), |
438 return (TemplatesListsStyleCSS.listTemplate |
491 ''.join(methBodies)) |
439 .format(**{'Entries': methList}), ''.join(methBodies)) |
492 |
440 |
493 def __genRbModulesSection(self): |
441 def __genRbModulesSection(self): |
494 """ |
442 """ |
495 Private method to generate the document section with details about |
443 Private method to generate the document section with details about |
496 Ruby modules. |
444 Ruby modules. |
506 rbModule, rbModuleName, Function.General) |
454 rbModule, rbModuleName, Function.General) |
507 classList, classBodies = self.__genRbModulesClassesSection( |
455 classList, classBodies = self.__genRbModulesClassesSection( |
508 rbModule, rbModuleName) |
456 rbModule, rbModuleName) |
509 |
457 |
510 try: |
458 try: |
511 rbmBody = self.rbModuleTemplate.format( |
459 rbmBody = TemplatesListsStyleCSS.rbModuleTemplate.format( |
512 **{'Anchor': rbModuleName, |
460 **{'Anchor': rbModuleName, |
513 'Module': rbModule.name, |
461 'Module': rbModule.name, |
514 'ModuleDescription': |
462 'ModuleDescription': |
515 self.__formatDescription(rbModule.description), |
463 self.__formatDescription(rbModule.description), |
516 'GlobalsList': globalsList, |
464 'GlobalsList': globalsList, |
550 |
498 |
551 methList, methBodies = self.__genMethodSection( |
499 methList, methBodies = self.__genMethodSection( |
552 _class, className, Function.General) |
500 _class, className, Function.General) |
553 |
501 |
554 try: |
502 try: |
555 clsBody = self.rbModulesClassTemplate.format( |
503 clsBody = TemplatesListsStyleCSS.rbModulesClassTemplate.format( |
556 **{'Anchor': className, |
504 **{'Anchor': className, |
557 'Class': _class.name, |
505 'Class': _class.name, |
558 'ClassSuper': supers, |
506 'ClassSuper': supers, |
559 'ClassDescription': |
507 'ClassDescription': |
560 self.__formatDescription(_class.description), |
508 self.__formatDescription(_class.description), |
574 |
522 |
575 classesList = self.__genRbModulesClassesListSection( |
523 classesList = self.__genRbModulesClassesListSection( |
576 classNames, obj.classes, modName) |
524 classNames, obj.classes, modName) |
577 |
525 |
578 if not classesList: |
526 if not classesList: |
579 classesList = self.listEntryNoneTemplate |
527 classesList = TemplatesListsStyleCSS.listEntryNoneTemplate |
580 return (self.listTemplate.format(**{'Entries': classesList}), |
528 return (TemplatesListsStyleCSS.listTemplate |
581 ''.join(classes)) |
529 .format(**{'Entries': classesList}), ''.join(classes)) |
582 |
530 |
583 def __genRbModulesClassesListSection(self, names, sectionDict, moduleName): |
531 def __genRbModulesClassesListSection(self, names, sectionDict, moduleName): |
584 """ |
532 """ |
585 Private method to generate the classes list section of a Ruby module. |
533 Private method to generate the classes list section of a Ruby module. |
586 |
534 |
591 (string) |
539 (string) |
592 @return The list section. (string) |
540 @return The list section. (string) |
593 """ |
541 """ |
594 lst = [] |
542 lst = [] |
595 for name in names: |
543 for name in names: |
596 lst.append(self.listEntryTemplate.format( |
544 lst.append(TemplatesListsStyleCSS.listEntryTemplate.format( |
597 **{'Link': "{0}.{1}".format(moduleName, name), |
545 **{'Link': "{0}.{1}".format(moduleName, name), |
598 'Name': sectionDict[name].name, |
546 'Name': sectionDict[name].name, |
599 'Description': |
547 'Description': |
600 self.__getShortDescription(sectionDict[name].description), |
548 self.__getShortDescription(sectionDict[name].description), |
601 'Deprecated': |
549 'Deprecated': |
602 self.__checkDeprecated(sectionDict[name].description) and |
550 self.__checkDeprecated(sectionDict[name].description) and |
603 self.listEntryDeprecatedTemplate or "", |
551 TemplatesListsStyleCSS.listEntryDeprecatedTemplate or "", |
604 })) |
552 })) |
605 self.keywords.append(("{0}.{1}".format(moduleName, name), |
553 self.keywords.append(("{0}.{1}".format(moduleName, name), |
606 "#{0}.{1}".format(moduleName, name))) |
554 "#{0}.{1}".format(moduleName, name))) |
607 return ''.join(lst) |
555 return ''.join(lst) |
608 |
556 |
615 """ |
563 """ |
616 funcBodies = [] |
564 funcBodies = [] |
617 funcNames = sorted(list(self.module.functions.keys())) |
565 funcNames = sorted(list(self.module.functions.keys())) |
618 for funcName in funcNames: |
566 for funcName in funcNames: |
619 try: |
567 try: |
620 funcBody = self.functionTemplate.format( |
568 funcBody = TemplatesListsStyleCSS.functionTemplate.format( |
621 **{'Anchor': funcName, |
569 **{'Anchor': funcName, |
622 'Function': self.module.functions[funcName].name, |
570 'Function': self.module.functions[funcName].name, |
623 'FunctionDescription': self.__formatDescription( |
571 'FunctionDescription': self.__formatDescription( |
624 self.module.functions[funcName].description), |
572 self.module.functions[funcName].description), |
625 'Params': |
573 'Params': |
714 if line == '.': |
662 if line == '.': |
715 linelist.append("") |
663 linelist.append("") |
716 else: |
664 else: |
717 linelist.append(html_uencode(line)) |
665 linelist.append(html_uencode(line)) |
718 else: |
666 else: |
719 lst.append(self.paragraphTemplate.format( |
667 lst.append(TemplatesListsStyleCSS.paragraphTemplate.format( |
720 **{'Lines': '\n'.join(linelist)})) |
668 **{'Lines': '\n'.join(linelist)})) |
721 linelist = [] |
669 linelist = [] |
722 if linelist: |
670 if linelist: |
723 lst.append(self.paragraphTemplate.format( |
671 lst.append(TemplatesListsStyleCSS.paragraphTemplate.format( |
724 **{'Lines': '\n'.join(linelist)})) |
672 **{'Lines': '\n'.join(linelist)})) |
725 return ''.join(lst) |
673 return ''.join(lst) |
726 |
674 |
727 def __genDescriptionListSection(self, dictionary, template): |
675 def __genDescriptionListSection(self, dictionary, template): |
728 """ |
676 """ |
751 @return formatted list section (string) |
699 @return formatted list section (string) |
752 """ |
700 """ |
753 lst = [] |
701 lst = [] |
754 for name, type_, lines in _list: |
702 for name, type_, lines in _list: |
755 if type_: |
703 if type_: |
756 lst.append(self.parameterTypesListEntryTemplate.format( |
704 lst.append( |
757 **{'Name': name, |
705 TemplatesListsStyleCSS.parameterTypesListEntryTemplate |
758 'Type': type_, |
706 .format( |
759 'Description': html_uencode('\n'.join(lines)), |
707 **{'Name': name, |
760 })) |
708 'Type': type_, |
|
709 'Description': html_uencode('\n'.join(lines)), |
|
710 } |
|
711 ) |
|
712 ) |
761 else: |
713 else: |
762 lst.append(self.parametersListEntryTemplate.format( |
714 lst.append( |
763 **{'Name': name, |
715 TemplatesListsStyleCSS.parametersListEntryTemplate.format( |
764 'Description': html_uencode('\n'.join(lines)), |
716 **{'Name': name, |
765 })) |
717 'Description': html_uencode('\n'.join(lines)), |
|
718 } |
|
719 ) |
|
720 ) |
766 return ''.join(lst) |
721 return ''.join(lst) |
767 |
722 |
768 def __formatCrossReferenceEntry(self, entry): |
723 def __formatCrossReferenceEntry(self, entry): |
769 """ |
724 """ |
770 Private method to format a cross reference entry. |
725 Private method to format a cross reference entry. |
792 reference = path and "{0}.html".format(path) or '' |
747 reference = path and "{0}.html".format(path) or '' |
793 if anchor: |
748 if anchor: |
794 reference = "{0}#{1}".format(reference, anchor) |
749 reference = "{0}#{1}".format(reference, anchor) |
795 entry = 'href="{0}">{1}</a>'.format(reference, label) |
750 entry = 'href="{0}">{1}</a>'.format(reference, label) |
796 |
751 |
797 return self.seeLinkTemplate.format(**{'Link': entry}) |
752 return TemplatesListsStyleCSS.seeLinkTemplate.format(**{'Link': entry}) |
798 |
753 |
799 def __genSeeListSection(self, _list, template): |
754 def __genSeeListSection(self, _list, template): |
800 """ |
755 """ |
801 Private method to generate the "see also" list section of a |
756 Private method to generate the "see also" list section of a |
802 description. |
757 description. |
1078 lastItem.append(ditem) |
1033 lastItem.append(ditem) |
1079 |
1034 |
1080 description = self.__genParagraphs(paragraphs) if paragraphs else "" |
1035 description = self.__genParagraphs(paragraphs) if paragraphs else "" |
1081 |
1036 |
1082 parameterSect = ( |
1037 parameterSect = ( |
1083 self.parametersListTemplate.format( |
1038 TemplatesListsStyleCSS.parametersListTemplate.format( |
1084 **{'Parameters': self.__genParamDescriptionListSection( |
1039 **{'Parameters': self.__genParamDescriptionListSection( |
1085 paramList)}) |
1040 paramList)}) |
1086 if paramList else |
1041 if paramList else |
1087 "" |
1042 "" |
1088 ) |
1043 ) |
1089 |
1044 |
1090 returnSect = ( |
1045 returnSect = ( |
1091 self.returnsTemplate.format( |
1046 TemplatesListsStyleCSS.returnsTemplate.format( |
1092 html_uencode('\n'.join(returns))) |
1047 html_uencode('\n'.join(returns))) |
1093 if returns else |
1048 if returns else |
1094 "" |
1049 "" |
1095 ) |
1050 ) |
1096 |
1051 |
1097 returnTypesSect = ( |
1052 returnTypesSect = ( |
1098 self.returnTypesTemplate.format( |
1053 TemplatesListsStyleCSS.returnTypesTemplate.format( |
1099 html_uencode('\n'.join(returnTypes))) |
1054 html_uencode('\n'.join(returnTypes))) |
1100 if returnTypes else |
1055 if returnTypes else |
1101 "" |
1056 "" |
1102 ) |
1057 ) |
1103 |
1058 |
1104 yieldSect = ( |
1059 yieldSect = ( |
1105 self.yieldsTemplate.format( |
1060 TemplatesListsStyleCSS.yieldsTemplate.format( |
1106 html_uencode('\n'.join(yields))) |
1061 html_uencode('\n'.join(yields))) |
1107 if yields else |
1062 if yields else |
1108 "" |
1063 "" |
1109 ) |
1064 ) |
1110 |
1065 |
1111 yieldTypesSect = ( |
1066 yieldTypesSect = ( |
1112 self.yieldTypesTemplate.format( |
1067 TemplatesListsStyleCSS.yieldTypesTemplate.format( |
1113 html_uencode('\n'.join(yieldTypes))) |
1068 html_uencode('\n'.join(yieldTypes))) |
1114 if yieldTypes else |
1069 if yieldTypes else |
1115 "" |
1070 "" |
1116 ) |
1071 ) |
1117 |
1072 |
1118 exceptionSect = ( |
1073 exceptionSect = ( |
1119 self.exceptionsListTemplate.format( |
1074 TemplatesListsStyleCSS.exceptionsListTemplate.format( |
1120 **{'Exceptions': self.__genDescriptionListSection( |
1075 **{'Exceptions': self.__genDescriptionListSection( |
1121 exceptionDict, self.exceptionsListEntryTemplate)}) |
1076 exceptionDict, |
|
1077 TemplatesListsStyleCSS.exceptionsListEntryTemplate)} |
|
1078 ) |
1122 if exceptionDict else |
1079 if exceptionDict else |
1123 "" |
1080 "" |
1124 ) |
1081 ) |
1125 |
1082 |
1126 signalSect = ( |
1083 signalSect = ( |
1127 self.signalsListTemplate.format( |
1084 TemplatesListsStyleCSS.signalsListTemplate.format( |
1128 **{'Signals': self.__genDescriptionListSection( |
1085 **{'Signals': self.__genDescriptionListSection( |
1129 signalDict, self.signalsListEntryTemplate)}) |
1086 signalDict, |
|
1087 TemplatesListsStyleCSS.signalsListEntryTemplate)} |
|
1088 ) |
1130 if signalDict else |
1089 if signalDict else |
1131 "" |
1090 "" |
1132 ) |
1091 ) |
1133 |
1092 |
1134 eventSect = ( |
1093 eventSect = ( |
1135 self.eventsListTemplate.format( |
1094 TemplatesListsStyleCSS.eventsListTemplate.format( |
1136 **{'Events': self.__genDescriptionListSection( |
1095 **{'Events': self.__genDescriptionListSection( |
1137 eventDict, self.eventsListEntryTemplate)}) |
1096 eventDict, |
|
1097 TemplatesListsStyleCSS.eventsListEntryTemplate)} |
|
1098 ) |
1138 if eventDict else |
1099 if eventDict else |
1139 "" |
1100 "" |
1140 ) |
1101 ) |
1141 |
1102 |
1142 deprecatedSect = ( |
1103 deprecatedSect = ( |
1143 self.deprecatedTemplate.format( |
1104 TemplatesListsStyleCSS.deprecatedTemplate.format( |
1144 **{'Lines': html_uencode('\n'.join(deprecated))}) |
1105 **{'Lines': html_uencode('\n'.join(deprecated))}) |
1145 if deprecated else |
1106 if deprecated else |
1146 "" |
1107 "" |
1147 ) |
1108 ) |
1148 |
1109 |
1149 authorInfoSect = ( |
1110 authorInfoSect = ( |
1150 self.authorInfoTemplate.format( |
1111 TemplatesListsStyleCSS.authorInfoTemplate.format( |
1151 **{'Authors': html_uencode('\n'.join(authorInfo))}) |
1112 **{'Authors': html_uencode('\n'.join(authorInfo))}) |
1152 if authorInfo else |
1113 if authorInfo else |
1153 "" |
1114 "" |
1154 ) |
1115 ) |
1155 |
1116 |
1156 sinceInfoSect = ( |
1117 sinceInfoSect = ( |
1157 self.sinceInfoTemplate.format( |
1118 TemplatesListsStyleCSS.sinceInfoTemplate.format( |
1158 **{'Info': html_uencode(sinceInfo[0])}) |
1119 **{'Info': html_uencode(sinceInfo[0])}) |
1159 if sinceInfo else |
1120 if sinceInfo else |
1160 "" |
1121 "" |
1161 ) |
1122 ) |
1162 |
1123 |
1163 seeSect = ( |
1124 seeSect = ( |
1164 self.seeListTemplate.format( |
1125 TemplatesListsStyleCSS.seeListTemplate.format( |
1165 **{'Links': self.__genSeeListSection( |
1126 **{'Links': self.__genSeeListSection( |
1166 seeList, self.seeListEntryTemplate)}) |
1127 seeList, TemplatesListsStyleCSS.seeListEntryTemplate)}) |
1167 if seeList else |
1128 if seeList else |
1168 '' |
1129 '' |
1169 ) |
1130 ) |
1170 |
1131 |
1171 return "".join([ |
1132 return "".join([ |