Commits

Ali Gholami Rudi  committed ef841e6

Enhancing documents

  • Participants
  • Parent commits 169054c

Comments (0)

Files changed (8)

File docs/dev/contributing.txt

 python.  But after observing python IDE limitations we grew bigger
 ideas in our heads.
 
-If you want to have more a powerful python IDE and have big ideas
+If you want to have a more powerful python IDE and have big ideas
 in your head, you are welcome to get involved.
 
 
 .. _`rope-developers`: rope-developers@lists.sourceforge.net
 
 
+Wish List
+=========
+
+If you're interested you are welcome discuss your ideas in
+`rope-developers`_ mailing list or send your patches.  Here is only a
+list of suggestions.
+
+A New GUI
+---------
+
+Right now rope uses Tkinter for its GUI.  But Tkinter, as many have
+complained about, looks very bad and is not suitable for writing an
+IDE.  The UI parts of rope, ie. `rope.ui` package, is a layer on top
+of other core parts of rope.  When I started rope I hoped that someday
+the IDE and UI parts of rope (`rope.ui` and `rope.ide` packages) would
+be developed by other developers and I still do hope so.  So if you're
+interested in working on GUI/IDE part of rope using something like
+`pygtk` or `wxPython` you're welcome.
+
+Formatting
+----------
+
+You can format python source code.  This probably needs using ASTs and
+writing them.
+
+Detecting Warnings
+------------------
+
+This might include detecting unused variables and imports or
+unreachable statements.  `rope.base` can help, too.  Currently rope
+only detects redefined elements.
+
+Modules Without Source Code
+---------------------------
+
+Rope cannot know anything about python C extensions and compiled
+modules without matching source code.  Some information can be
+gathered using `inspect` module.  But that is not safe but better than
+nothing.  This requires a good knowledge of `rope.base`.
+
+
 Rope Structure
 ==============
 
 .. _`library.txt`: library.html
 
 
-Wish List
-=========
-
-Right now rope uses Tkinter for its GUI.  But Tkinter, as many have
-complained about, looks very bad and is not suitable for writing an
-IDE.  The UI parts of rope, ie. `rope.ui` package, is a layer on top
-of other core parts of rope.  When I started rope I hoped that
-someday the IDE and UI parts of rope (`rope.ui` and `rope.ide`
-packages) would be developed by other developers and I still do hope
-so.  If you're interested, start sending patches or if you want to
-use some other graphical library like wxPython send a basic but
-working UI.
-
-
 Submitting patches
 ==================
 

File docs/dev/workingon.txt

 Small Stories
 =============
 
-- Multiple 'Collecting Classes' JobSet when collecting methods
-  in hierarchy
+- Document how to rename fields
+- Document how to use templates
+- Fixing handling long imports for single character imports
 
+* Not compiling when only the commented lines change in codeassist
 * StoppableTaskRunner stops when finished till a GUI event
 * Problems for highlighting after refactorings
 * Move refactoring and moving a group of elements together
 * How rope helps custom refactorings
 * Request for contributions: ui, documentation, others
 * Write more docs
-* Adding ``random_hacks.txt``?
-
-  * Renaming fields
-  * Using change occurrences
-  * Using templates
-
+* Renaming ``overview.txt``? ``random_hacks.txt``?
+* Using change occurrences in docs
 * A better homepage with screen-shots?
 
 
 
 * Adding call for UI contributions section and interesting tasks
 * Document features and organize them
-* Document how to move fields
 * Describe why rope does not stop the user from performing wrong
   refactorings
 

File docs/index.txt

   * Stored object data validation
 
 
+For more information see `overview.txt`_.
+
+.. _overview.txt: user/overview.html
+
+
 Download
 ========
 

File docs/user/overview.txt

 ===============
- Rope Features
+ Rope Overview
 ===============
 
 
 can do in extremes.  So if you really want to feel the power of
 rope try its features and see its unit tests.
 
+Note that this file assumes emacs keybinding.
+
 
 .. contents:: Table of Contents
 
 Show PyDoc
 ----------
 
-Try it!
+By using ``C-c C-d`` you can tell rope to show the pydoc of a python
+defined element.
 
 
 Goto Definition
 ---------------
 
-Try it!
+You can use ``C-c g`` for going to the line a name was defined in.
 
 
 Generate Python Elements
 prefix.
 
 
+Defining Templates
+------------------
+
+You can define your own templates in ``~/.rope``.  You can use ``C-x c``
+and a line like this::
+
+    core.add('templates', ('say_hello', "print 'Hello, my name is ${name}'\n"))
+
+This defines a new python template called ``say_hello``.  Now if you
+type ``say_`` in a python file and use code-assist (``M-/``), this
+template will be proposed.  If you press enter you can insert the
+value to be used as ``name``.
+
+
 ``.ropeproject`` Folder
 =======================
 
-``0.5m4`` release added of a new folder inside projects for holding
-configurations and other information for a project.  Its default name
-is ``.ropeproject``, but it can be changed in ``~/.rope`` or `Project`
-constructor (if using rope as a library).  You can also force rope not
-to make such a folder by using `None` instead of a `str`.
+Rope uses a folder inside projects for holding project configuration
+and data.  Its default name is ``.ropeproject``, but it can be changed
+in ``~/.rope`` or `Project` constructor (if using rope as a library).
+You can also force rope not to make such a folder by using `None`
+instead of a `str`.
 
 Currently it is used for things such as:
 
 Refactorings
 ============
 
-This section shows some random refactorings you can perform using rope.
+This section shows some random refactorings that you can perform using
+rope.
 
 
 Renaming attributes
   a_func(a_param=10)
   a_func(10)
 
-After performing rename refactoring on any occurance of ``a_param``
+After performing rename refactoring on any occurrence of ``a_param``
 we will have::
 
   def a_func(new_param):
   mod2.a_func()
   a_var = AClass()
 
-After performing rename refactoring one of the ``mod2`` occurances in
+After performing rename refactoring one of the ``mod2`` occurrences in
 `mod1` we'll get::
 
   import newmod
 
   def f():
       a_var = 1
+      # INFO: I'm printing `a_var`
       print 'a_var = %s' % a_var
 
   # f prints a_var
 
   def f():
       new_var = 1
+      # INFO: I'm printing `new_var`
       print 'new_var = %s' % new_var
 
   # f prints a_var
 want to change all of the occurrences of the old method to use the new
 method you can inline it afterwards.
 
+For instance if you perform move method on `a_method` in::
+
+  class A(object):
+      pass
+
+  class B(object):
+
+      def __init__(self):
+          self.attr = A()
+
+      def a_method(self):
+          pass
+
+  b = B()
+  b.a_method()
+
+You will be asked for the destination field and the name of the new
+method.  If you use ``attr`` and ``new_method`` in these fields
+and press enter, you'll have::
+      
+  class A(object):
+
+      def new_method(self):
+          pass
+
+  class B(object):
+
+      def __init__(self):
+          self.attr = A()
+
+      def a_method(self):
+          return self.attr.new_method()
+
+
+  b = B()
+  b.a_method()
+
+Now if you want to change the occurrences of `B.a_method()` to use
+`A.new_method()`, you can inline `B.a_method()`::
+
+  class A(object):
+
+      def new_method(self):
+          pass
+
+  class B(object):
+
+      def __init__(self):
+          self.attr = A()
+
+  b = B()
+  b.attr.new_method()
+
+
+Moving Fields
+-------------
+
+Rope does not have a separate refactoring for moving fields.  Rope's
+refactorings are very flexible.  You can use the rename refactoring to
+rename fields.  For instance::
+
+  class A(object):
+      pass
+
+  class B(object):
+
+      def __init__(self):
+          self.a = A()
+          self.attr = 1
+
+  b = B()
+  print(b.attr)
+
+consider we want to move `attr` to `A`.  We can do that by renaming `attr`
+to `a.attr`::
+  
+  class A(object):
+      pass
+
+  class B(object):
+
+      def __init__(self):
+          self.a = A()
+          self.attr = 1
+
+  b = B()
+  print(b.a.attr)
+
+You can move the definition of `attr` manually.
+
 
 Extract Method
 --------------
 taskhandle.TaskHandle` to this method.  See `rope.refactor.taskhandle`
 module for more information.
 
+
 Basic Implicit Interfaces
 -------------------------
 
   count_for(A())
   count_for(B())
 
-
 This also works for change method signature.  Note that this feature
 relies on rope's object inference mechanisms to find out the
 parameters that are passed to a function.
   l2.append(C())
   var2 = l2.pop()
 
-Here rope knowns the type of `var1` without doing anything.  But for
+Here rope knows the type of `var1` without doing anything.  But for
 knowing the type of `var2` we need to analyze the items added to `l2`
 which might happen in other modules.  Rope can find out that by
 running SOI analysis on this module.
 refactorings it will call the appropriate subversion commands.  The
 subversion support is automatically turned on when there is a ``.svn``
 folder inside project root and the ``pysvn`` package is
-available. (You can get PySVN from http://pysvn.tigris.org ).  Rope
+available. (You can get PySVN from http://pysvn.tigris.org).  Rope
 assumes all files are under version control when these conditions are
 met.  Also don't forget to commit your changes yourself, rope doesn't
 do that yet.

File rope/base/codeanalyze.py

         next_char = self._find_first_non_space_char(start)
         if self.source_code[next_char] == '(':
             try:
-                return self.source_code.index(')', next_char)
+                return self.source_code.index(')', next_char) + 1
             except ValueError:
                 return SyntaxError('Unmatched Parens')
         else:
     def is_import_statement(self, offset):
         try:
             last_import = self.source_code.rindex('import ', 0, offset)
-            import_names = last_import + 8
         except ValueError:
             return False
-        return self._find_import_pair_end(import_names) >= offset
+        return self._find_import_pair_end(last_import + 7) >= offset
 
     def is_from_statement(self, offset):
         try:

File rope/refactor/importutils/__init__.py

             module_imports.get_changed_source(),
             resource=pymodule.get_resource())
         for name in to_be_fixed:
-            pymodule = self._rename_in_module(pymodule, name, name.split('.')[-1])
+            pymodule = self._rename_in_module(pymodule, name,
+                                              name.split('.')[-1])
         # organizing imports
         return self.organize_imports(pymodule)

File ropetest/codeanalyzetest.py

         self.assertTrue(word_finder.is_import_statement(code.index('mod') + 1))
         self.assertFalse(word_finder.is_import_statement(code.index('a_var') + 1))
 
+    def test_import_statement_finding2(self):
+        code = 'import a.b.c.d\nresult = a.b.c.d.f()\n'
+        word_finder = WordRangeFinder(code)
+        self.assertFalse(word_finder.is_import_statement(code.rindex('d') + 1))
+
 
 class ScopeNameFinderTest(unittest.TestCase):
 

File ropetest/refactor/importutilstest.py

         p2 = self.pycore.create_package(p1, 'p2')
         p3 = self.pycore.create_package(p2, 'p3')
         m1 = self.pycore.create_module(p3, 'm1')
+        l = self.pycore.create_module(p3, 'l')
 
     def tearDown(self):
         testutils.remove_project(self.project)
             self.import_tools.handle_long_imports(pymod, maxdots=3,
                                                   maxlength=10))
 
+    def test_handling_long_imports_with_one_letter_last(self):
+        self.mod.write('import p1.p2.p3.l\n\n\nm = p1.p2.p3.l\n')
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        self.assertEquals(
+            'from p1.p2.p3 import l\n\n\nm = l\n',
+            self.import_tools.handle_long_imports(pymod, maxdots=2))
+
     def test_empty_removing_unused_imports_and_eating_blank_lines(self):
         self.mod.write('import pkg1\nimport pkg2\n\n\nprint pkg1\n')
         pymod = self.pycore.get_module('mod')