Anonymous avatar Anonymous committed c36792a

interface: renamed rope-get-docstring to rope-get-doc

Renamed rope-get-docstring to rope-get-doc for consistency.
Added RopeMode._base_show_doc method to avoid code duplication.

Comments (0)

Files changed (1)

ropemode/interface.py

         self._base_show_doc(prefix, _get_doc)
 
     def _base_show_doc(self, prefix, get_doc):
+        docs = self._base_get_doc(get_doc)
+        if docs:
+            self.env.show_doc(docs, prefix)
+        else:
+            self.env.message('No docs available!')
+
+    @decorators.local_command()
+    def get_doc(self):
+        self._check_project()
+        return self._base_get_doc(codeassist.get_doc)
+
+    def _base_get_doc(self, get_doc):
         maxfixes = self.env.get('codeassist_maxfixes')
         text = self._get_text()
         offset = self.env.get_offset()
-        docs = get_doc(self.project, text, offset,
-                       self.resource, maxfixes)
-        self.env.show_doc(docs, prefix)
-        if docs is None:
-            self.env.message('No docs available!')
+        try:
+            return get_doc(self.project, text, offset,
+                           self.resource, maxfixes)
+        except exceptions.BadIdentifierError:
+            return None
 
     def _get_text(self):
         resource = self.resource
             ask_func = self.env.ask_directory
         return ask_func(**ask_args)
 
-    @decorators.local_command()
-    def get_docstring(self):
-        self._check_project()
-        # almost like _base_show_doc()
-        maxfixes = self.env.get('codeassist_maxfixes')
-        text = self._get_text()
-        offset = self.env.get_offset()
-        return codeassist.get_doc(self.project, text, offset,
-                                  self.resource, maxfixes)
-
 
 class Location(object):
     def __init__(self, location):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.