--- a/UI/CodeDocumentationViewer.py Sun Nov 05 13:24:07 2017 +0100 +++ b/UI/CodeDocumentationViewer.py Sun Nov 05 17:16:40 2017 +0100 @@ -210,7 +210,6 @@ self.__lastDocumentation = None self.__requestingEditor = None - def __setupUi(self): """ @@ -419,14 +418,15 @@ """ Public method to provide the documentation info to the viewer. - If documentationInfo is a dictionary, it should contains these keys - and data: + If documentationInfo is a dictionary, it should contain these + (optional) keys and data: name: the name of the inspected object - argspec: its argspec + argspec: its arguments specification note: A phrase describing the type of object (function or method) and the module it belongs to. docstring: its documentation string + typ: its type information @param documentationInfo dictionary containing the source docu data @type dict or str @@ -468,27 +468,47 @@ if name: title = "".join([name, "\n", "=" * len(name), "\n\n"]) - else: - title = "" - if documentationInfo["argspec"]: - definition = self.tr("Definition: {0}{1}\n").format( - name, documentationInfo["argspec"]) + if "argspec" in documentationInfo and \ + documentationInfo["argspec"]: + definition = self.tr("Definition: {0}{1}\n")\ + .format(name, documentationInfo["argspec"]) + elif name: + definition = self.tr("Definition: {0}\n")\ + .format(name) + else: + definition = "" + + if "typ" in documentationInfo and \ + documentationInfo["typ"]: + typeInfo = self.tr("Type: {0}\n").format( + documentationInfo["typ"]) + else: + typeInfo = "" + + if "note" in documentationInfo and \ + documentationInfo["note"]: + note = self.tr("Note: {0}\n").format( + documentationInfo["note"]) + else: + note = "" + + header = "".join([title, definition, typeInfo, note]) else: - definition = '' - - if documentationInfo["note"]: - note = self.tr("Info: {0}\n\n----\n\n").format( - documentationInfo["note"]) + header = "" + + if "docstring" not in documentationInfo or \ + not documentationInfo["docstring"]: + docString = self.tr( + "No further documentation available") else: - note = "" + if header: + docString = "\n----\n\n{0}".format( + documentationInfo["docstring"]) + else: + docString = documentationInfo["docstring"] - if documentationInfo["docstring"] is None: - docString = "" - else: - docString = documentationInfo["docstring"] - - fullText = "".join([title, definition, note, docString]) + fullText = "".join([header, docString]) self.__plainTextViewer.setText(fullText)