RefactoringRope/CodeAssistServer.py

changeset 232
65d7d745543d
parent 223
d30d3b0d1df5
child 245
75a35a927952
--- a/RefactoringRope/CodeAssistServer.py	Sun Nov 05 15:47:47 2017 +0100
+++ b/RefactoringRope/CodeAssistServer.py	Sun Nov 05 17:23:30 2017 +0100
@@ -64,6 +64,18 @@
             "ClientException": self.__processClientException,
         }
         
+        self.__typeMapping = {
+            "staticmethod": self.tr("static method"),
+            "classmethod": self.tr("class method"),
+            "method": self.tr("method"),
+            "function": self.tr("function"),
+            "class": self.tr("class"),
+            "module": self.tr("module"),
+            "package": self.tr("package"),
+            "object": self.tr("object"),
+            "<unknown>": self.tr("not known"),
+        }
+        
         # Python 2
         self.__ensureActive("Python2")
         
@@ -381,7 +393,7 @@
         Private method to process the documentation sent by the client.
         
         @param result dictionary containing the result sent by the client
-        @type dict
+        @type dict with keys 'name', 'argspec', 'note', 'docstring', 'typ'
         """
         docu = None
         
@@ -389,17 +401,27 @@
             documentationDict = result["DocumentationDict"]
             if documentationDict:
                 if "module" in documentationDict:
-                    if Preferences.getDocuViewer("ShowInfoAsRichText"):
-                        documentationDict["note"] = \
-                            self.tr("Present in <i>{0}</i> module",
-                                    "Note with markdown syntax")\
-                            .format(documentationDict["module"])
+                    if documentationDict["module"]:
+                        if Preferences.getDocuViewer("ShowInfoAsRichText"):
+                            documentationDict["note"] = \
+                                self.tr("Present in <i>{0}</i> module")\
+                                .format(documentationDict["module"])
+                        else:
+                            documentationDict["note"] = \
+                                self.tr("Present in '{0}' module")\
+                                .format(documentationDict["module"])
+                    del documentationDict["module"]
+                
+                if "typ" in documentationDict:
+                    if documentationDict["typ"] not in self.__typeMapping:
+                        del documentationDict["typ"]
                     else:
-                        documentationDict["note"] = \
-                            self.tr("Present in '{0}' module",
-                                    "Note as plain text")\
-                            .format(documentationDict["module"])
-                    del documentationDict["module"]
+                        documentationDict["typ"] = \
+                            self.__typeMapping[documentationDict["typ"]]
+                
+                if "note" not in documentationDict:
+                    documentationDict["note"] = ""
+                
                 docu = documentationDict
         
         if docu is None:

eric ide

mercurial