417 def documentationReady(self, documentationInfo, isWarning=False, |
416 def documentationReady(self, documentationInfo, isWarning=False, |
418 isDocWarning=False): |
417 isDocWarning=False): |
419 """ |
418 """ |
420 Public method to provide the documentation info to the viewer. |
419 Public method to provide the documentation info to the viewer. |
421 |
420 |
422 If documentationInfo is a dictionary, it should contains these keys |
421 If documentationInfo is a dictionary, it should contain these |
423 and data: |
422 (optional) keys and data: |
424 |
423 |
425 name: the name of the inspected object |
424 name: the name of the inspected object |
426 argspec: its argspec |
425 argspec: its arguments specification |
427 note: A phrase describing the type of object (function or method) and |
426 note: A phrase describing the type of object (function or method) and |
428 the module it belongs to. |
427 the module it belongs to. |
429 docstring: its documentation string |
428 docstring: its documentation string |
|
429 typ: its type information |
430 |
430 |
431 @param documentationInfo dictionary containing the source docu data |
431 @param documentationInfo dictionary containing the source docu data |
432 @type dict or str |
432 @type dict or str |
433 @param isWarning flag indicating a warning page |
433 @param isWarning flag indicating a warning page |
434 @type bool |
434 @type bool |
466 elif isinstance(documentationInfo, dict): |
466 elif isinstance(documentationInfo, dict): |
467 name = documentationInfo["name"] |
467 name = documentationInfo["name"] |
468 if name: |
468 if name: |
469 title = "".join([name, "\n", |
469 title = "".join([name, "\n", |
470 "=" * len(name), "\n\n"]) |
470 "=" * len(name), "\n\n"]) |
|
471 |
|
472 if "argspec" in documentationInfo and \ |
|
473 documentationInfo["argspec"]: |
|
474 definition = self.tr("Definition: {0}{1}\n")\ |
|
475 .format(name, documentationInfo["argspec"]) |
|
476 elif name: |
|
477 definition = self.tr("Definition: {0}\n")\ |
|
478 .format(name) |
|
479 else: |
|
480 definition = "" |
|
481 |
|
482 if "typ" in documentationInfo and \ |
|
483 documentationInfo["typ"]: |
|
484 typeInfo = self.tr("Type: {0}\n").format( |
|
485 documentationInfo["typ"]) |
|
486 else: |
|
487 typeInfo = "" |
|
488 |
|
489 if "note" in documentationInfo and \ |
|
490 documentationInfo["note"]: |
|
491 note = self.tr("Note: {0}\n").format( |
|
492 documentationInfo["note"]) |
|
493 else: |
|
494 note = "" |
|
495 |
|
496 header = "".join([title, definition, typeInfo, note]) |
471 else: |
497 else: |
472 title = "" |
498 header = "" |
473 |
499 |
474 if documentationInfo["argspec"]: |
500 if "docstring" not in documentationInfo or \ |
475 definition = self.tr("Definition: {0}{1}\n").format( |
501 not documentationInfo["docstring"]: |
476 name, documentationInfo["argspec"]) |
502 docString = self.tr( |
|
503 "No further documentation available") |
477 else: |
504 else: |
478 definition = '' |
505 if header: |
479 |
506 docString = "\n----\n\n{0}".format( |
480 if documentationInfo["note"]: |
507 documentationInfo["docstring"]) |
481 note = self.tr("Info: {0}\n\n----\n\n").format( |
508 else: |
482 documentationInfo["note"]) |
509 docString = documentationInfo["docstring"] |
483 else: |
|
484 note = "" |
|
485 |
510 |
486 if documentationInfo["docstring"] is None: |
511 fullText = "".join([header, docString]) |
487 docString = "" |
|
488 else: |
|
489 docString = documentationInfo["docstring"] |
|
490 |
|
491 fullText = "".join([title, definition, note, docString]) |
|
492 |
512 |
493 self.__plainTextViewer.setText(fullText) |
513 self.__plainTextViewer.setText(fullText) |
494 |
514 |
495 def __showDisabledMessage(self): |
515 def __showDisabledMessage(self): |
496 """ |
516 """ |