RefactoringRope/CodeAssistServer.py

changeset 232
65d7d745543d
parent 223
d30d3b0d1df5
child 245
75a35a927952
equal deleted inserted replaced
231:6bc3382a7462 232:65d7d745543d
60 "CompletionsResult": self.__processCompletionsResult, 60 "CompletionsResult": self.__processCompletionsResult,
61 "CallTipsResult": self.__processCallTipsResult, 61 "CallTipsResult": self.__processCallTipsResult,
62 "DocumentationResult": self.__processDocumentationResult, 62 "DocumentationResult": self.__processDocumentationResult,
63 63
64 "ClientException": self.__processClientException, 64 "ClientException": self.__processClientException,
65 }
66
67 self.__typeMapping = {
68 "staticmethod": self.tr("static method"),
69 "classmethod": self.tr("class method"),
70 "method": self.tr("method"),
71 "function": self.tr("function"),
72 "class": self.tr("class"),
73 "module": self.tr("module"),
74 "package": self.tr("package"),
75 "object": self.tr("object"),
76 "<unknown>": self.tr("not known"),
65 } 77 }
66 78
67 # Python 2 79 # Python 2
68 self.__ensureActive("Python2") 80 self.__ensureActive("Python2")
69 81
379 def __processDocumentationResult(self, result): 391 def __processDocumentationResult(self, result):
380 """ 392 """
381 Private method to process the documentation sent by the client. 393 Private method to process the documentation sent by the client.
382 394
383 @param result dictionary containing the result sent by the client 395 @param result dictionary containing the result sent by the client
384 @type dict 396 @type dict with keys 'name', 'argspec', 'note', 'docstring', 'typ'
385 """ 397 """
386 docu = None 398 docu = None
387 399
388 if "Error" not in result: 400 if "Error" not in result:
389 documentationDict = result["DocumentationDict"] 401 documentationDict = result["DocumentationDict"]
390 if documentationDict: 402 if documentationDict:
391 if "module" in documentationDict: 403 if "module" in documentationDict:
392 if Preferences.getDocuViewer("ShowInfoAsRichText"): 404 if documentationDict["module"]:
393 documentationDict["note"] = \ 405 if Preferences.getDocuViewer("ShowInfoAsRichText"):
394 self.tr("Present in <i>{0}</i> module", 406 documentationDict["note"] = \
395 "Note with markdown syntax")\ 407 self.tr("Present in <i>{0}</i> module")\
396 .format(documentationDict["module"]) 408 .format(documentationDict["module"])
409 else:
410 documentationDict["note"] = \
411 self.tr("Present in '{0}' module")\
412 .format(documentationDict["module"])
413 del documentationDict["module"]
414
415 if "typ" in documentationDict:
416 if documentationDict["typ"] not in self.__typeMapping:
417 del documentationDict["typ"]
397 else: 418 else:
398 documentationDict["note"] = \ 419 documentationDict["typ"] = \
399 self.tr("Present in '{0}' module", 420 self.__typeMapping[documentationDict["typ"]]
400 "Note as plain text")\ 421
401 .format(documentationDict["module"]) 422 if "note" not in documentationDict:
402 del documentationDict["module"] 423 documentationDict["note"] = ""
424
403 docu = documentationDict 425 docu = documentationDict
404 426
405 if docu is None: 427 if docu is None:
406 msg = self.tr("No documentation available.") 428 msg = self.tr("No documentation available.")
407 self.__documentationViewer.documentationReady( 429 self.__documentationViewer.documentationReady(

eric ide

mercurial