Commits

Anonymous committed 27189a6

updated some of pydocs

  • Participants
  • Parent commits 541a5f4

Comments (0)

Files changed (2)

File rope/refactor/restructure.py

 
 
 class Restructure(object):
-    """A class to perform python restructurings"""
+    """A class to perform python restructurings
+
+    A restructuring transforms pieces of code matching `pattern` to
+    `goal`.  In the `pattern` wildcards can appear.  Wildcards match
+    some piece of code based on their kind and arguments that are
+    passed to them through `args`.
+
+    `args` is a dictionary of wildcard names to wildcard arguments.
+    If the argument is a tuple, the first item of the tuple is
+    considered to be the name of the wildcard to use; otherwise the
+    "default" wildcard is used.
+
+    `wildcards` is the list of wildcard types that can appear in
+    `pattern`.  See `rope.refactor.wildcards`.  If a wildcard does not
+    specify its kind (by using a tuple in args), the wildcard named
+    "default" is used.  So there should be a wildcard with "default"
+    name in `wildcards`.
+
+    `imports` is the list of imports that changed modules should
+    import.  Note that rope handles duplicate imports and does not add
+    the import if it already appears.
+
+    """
 
     def __init__(self, project, pattern, goal, args=None,
                  imports=None, wildcards=None):
             job_set.started_job('Working on <%s>' % resource.path)
             pymodule = self.pycore.resource_to_pyobject(resource)
             finder = similarfinder.SimilarFinder(pymodule,
-                                                  wildcards=self.wildcards)
+                                                 wildcards=self.wildcards)
             computer = _ChangeComputer(pymodule, self.template,
                                        list(finder.get_matches(self.pattern,
                                                                self.args)))

File rope/refactor/similarfinder.py

 
 
 class SimilarFinder(object):
-    """`SimilarFinder` can be used to find similar pieces of code"""
+    """`SimilarFinder` can be used to find similar pieces of code
+
+    See the notes in the `rope.refactor.restructure` module for more
+    info.
+
+    """
 
     def __init__(self, pymodule, wildcards=None):
         """Construct a SimilarFinder"""
 
     def _does_match(self, node, name):
         arg = self.args.get(name, '')
+        kind = 'default'
+        if isinstance(arg, (tuple, list)):
+            kind = arg[0]
+            arg = arg[1]
         suspect = wildcards.Suspect(self.pymodule, node, name)
-        return self.wildcards['default'].matches(suspect, arg)
+        return self.wildcards[kind].matches(suspect, arg)
 
 
 class RawSimilarFinder(object):