Add more generated documentation.
authorRadek Brich <radek.brich@devl.cz>
Thu, 08 Sep 2011 11:37:27 +0200
changeset 13 19ebde2fd594
parent 12 bb7d41be0c44
child 14 1f2ff9d3c7f9
Add more generated documentation.
docs/application.rst
docs/button.rst
docs/conf.py
docs/container.rst
docs/eventsource.rst
docs/index.rst
docs/widget.rst
docs/window.rst
tuikit/application.py
tuikit/button.py
tuikit/container.py
tuikit/eventsource.py
tuikit/widget.py
tuikit/window.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/application.rst	Thu Sep 08 11:37:27 2011 +0200
@@ -0,0 +1,11 @@
+Application
+===========
+
+.. toctree::
+   :maxdepth: 3
+   :titlesonly:
+
+.. automodule:: tuikit.application
+   :members:
+   :show-inheritance:
+
--- a/docs/button.rst	Thu Sep 08 10:13:55 2011 +0200
+++ b/docs/button.rst	Thu Sep 08 11:37:27 2011 +0200
@@ -1,2 +1,13 @@
 Button
 ======
+
+.. toctree::
+   :maxdepth: 3
+   :titlesonly:
+
+   window
+
+.. automodule:: tuikit.container
+   :members:
+   :show-inheritance:
+
--- a/docs/conf.py	Thu Sep 08 10:13:55 2011 +0200
+++ b/docs/conf.py	Thu Sep 08 11:37:27 2011 +0200
@@ -192,3 +192,6 @@
 
 # If false, no module index is generated.
 #latex_use_modindex = True
+
+
+autodoc_member_order = 'bysource'
--- a/docs/container.rst	Thu Sep 08 10:13:55 2011 +0200
+++ b/docs/container.rst	Thu Sep 08 11:37:27 2011 +0200
@@ -2,6 +2,12 @@
 =========
 
 .. toctree::
-   :maxdepth: 2
+   :maxdepth: 3
+   :titlesonly:
 
    window
+
+.. automodule:: tuikit.container
+   :members:
+   :show-inheritance:
+
--- a/docs/eventsource.rst	Thu Sep 08 10:13:55 2011 +0200
+++ b/docs/eventsource.rst	Thu Sep 08 11:37:27 2011 +0200
@@ -2,7 +2,8 @@
 ===========
 
 .. toctree::
-   :maxdepth: 2
+   :maxdepth: 3
+   :titlesonly:
 
    widget
 
--- a/docs/index.rst	Thu Sep 08 10:13:55 2011 +0200
+++ b/docs/index.rst	Thu Sep 08 11:37:27 2011 +0200
@@ -6,6 +6,7 @@
 .. toctree::
    :maxdepth: 3
 
+   application
    eventsource
    events
    focus
--- a/docs/widget.rst	Thu Sep 08 10:13:55 2011 +0200
+++ b/docs/widget.rst	Thu Sep 08 11:37:27 2011 +0200
@@ -2,69 +2,23 @@
 ======
 
 .. toctree::
-   :maxdepth: 2
+   :maxdepth: 3
+   :titlesonly:
 
    container
    button
 
-.. py:module:: tuikit.widget
-
-
-Class attributes
-----------------
-
-.. attribute:: Widget.parent
-
-   Parrent widget.
-
-
-.. attribute:: Widget.top
-
-   Top widget (same for every widget in one application).
-
-
-.. attribute:: Widget.x
-               Widget.y
-
-   Position inside parent widget. Modified by layout manager.
-
-
-.. attribute:: Widget.width
-               Widget.height
-
-   Actual size. Modified by layout manager.
-
-
-.. attribute:: Widget.sizemin
+.. autoclass:: tuikit.widget.Widget
+   :members:
+   :show-inheritance:
 
-   Minimal size of widget. Under normal circumstances, widget will never be sized smaller than this.
-   Tuple (w, h). Both must be integers >= 1.
-
-
-.. attribute:: Widget.sizemax
-
-   Maximum size of widget. Widget will never be sized bigger than this.
-   Tuple (w, h). Integers >= 1 or None (meaning no maximum size or infinite).
-
-
-.. attribute:: Widget.sizereq
-
-   Size request. This is default size of the widget. Will be fulfilled if possible.
-   Tuple (w, h). Integers >= 1 or None (meaning use minumal size).
-
+   .. attribute:: x
+                  y
+      
+      Position inside parent widget. Modified by layout manager.
+   
+   .. attribute:: width
+                  height
+      
+      Actual size. Modified by layout manager.
 
-.. attribute:: Widget.hidden
-
-   Hidden widget does not affect layout.
-
-
-.. attribute:: Widget.allowlayout
-
-   When false, the widget is not considered in layout.
-
-
-.. attribute:: Widget.layouthints
-
-   Dictionary containing optional parameters for layout managers.
-
-
--- a/docs/window.rst	Thu Sep 08 10:13:55 2011 +0200
+++ b/docs/window.rst	Thu Sep 08 11:37:27 2011 +0200
@@ -1,2 +1,11 @@
 Window
 ======
+
+.. toctree::
+   :maxdepth: 3
+   :titlesonly:
+
+.. automodule:: tuikit.window
+   :members:
+   :show-inheritance:
+
--- a/tuikit/application.py	Thu Sep 08 10:13:55 2011 +0200
+++ b/tuikit/application.py	Thu Sep 08 11:37:27 2011 +0200
@@ -1,6 +1,5 @@
 # -*- coding: utf-8 -*-
 
-import curses
 import curses.wrapper
 import logging
 import time
@@ -11,7 +10,11 @@
 
 
 class TopWindow(Container):
+    
+    '''Top window of an application. Covers entire screen.'''
+    
     def __init__(self):
+        '''Create top window.'''
         Container.__init__(self)
 
         self.focuswidget = None
@@ -70,9 +73,17 @@
 
 
 class Application:
+    
+    '''Application class. Defines main loop.'''
+       
     def __init__(self):
+        '''Create application.'''
+        
+        '''Top window.'''
         self.top = TopWindow()
         self.quit = False
+        
+        '''Renderer class, i.e. BackendCurses.'''
         self.screen = None
 
         self.log = logging.getLogger('tuikit')
@@ -85,14 +96,17 @@
 
 
     def start(self):
+        '''Start application. Runs main loop.'''
         curses.wrapper(self.mainloop)
 
 
     def terminate(self):
+        '''Terminate application.'''
         self.quit = True
 
 
     def mainloop(self, screen):
+        '''The main loop.'''
         self.screen = BackendCurses(screen)
         self.applytheme()
         self.top.width, self.top.height = self.screen.width, self.screen.height
@@ -129,3 +143,4 @@
         screen.setcolor('button-active',           'black on cyan')
         screen.setcolor('menu',                    'black on cyan')
         screen.setcolor('menu-active',             'white on cyan, bold')
+
--- a/tuikit/button.py	Thu Sep 08 10:13:55 2011 +0200
+++ b/tuikit/button.py	Thu Sep 08 11:37:27 2011 +0200
@@ -1,21 +1,25 @@
 # -*- coding: utf-8 -*-
 
-import curses
-import locale
-
 from .widget import Widget
 
 
 class Button(Widget):
+    
+    '''Clickable button.'''
+    
     def __init__(self, label=''):
+        '''Create button with given label, size according to label.'''
         Widget.__init__(self, len(label) + 4, 1)
 
+        #: Button label.
         self.label = label
         self.bg = 'button'
         self.bghi = 'button-active'
         self.highlight = False
 
+        #: Left bracket graphic character.
         self.lbracket = '<'
+        #: Right bracket graphic character.
         self.rbracket = '>'
 
         self.connect('draw', self.on_draw)
--- a/tuikit/container.py	Thu Sep 08 10:13:55 2011 +0200
+++ b/tuikit/container.py	Thu Sep 08 11:37:27 2011 +0200
@@ -3,14 +3,24 @@
 from .widget import Widget
 import logging
 
+
 class Container(Widget):
+    
+    '''Container widget. Base for any widget which can contain other widgets.'''
+    
     def __init__(self, width = 10, height = 10):
+        '''Create container of requested size.'''
         Widget.__init__(self, width, height)
 
+        #: List of child widgets.
         self.children = []
+        
         self.mousechild = None
 
-        self.borders = (0, 0, 0, 0) # left, top, right, bottom
+        #: Width of borders (left, top, right, bottom).
+        #: Child widgets are placed within borders.
+        self.borders = (0, 0, 0, 0)
+        
         self.widthrequest = (None, None)
         self.heightrequest = (None, None)
 
@@ -20,6 +30,7 @@
 
 
     def add(self, widget, **kw):
+        '''Add widget into this container.'''
         self.children.append(widget)
         widget.parent = self
         widget.settop(self.top)
@@ -27,12 +38,14 @@
 
 
     def layout(self, layout):
+        '''Set layout manager for placing child widgets.'''
         self.layout = layout
         layout.container = self
         self.connect('resize', layout.resize)
 
 
     def settop(self, top):
+        '''Set top widget.'''
         self.top = top
         for child in self.children:
             child.settop(top)
--- a/tuikit/eventsource.py	Thu Sep 08 10:13:55 2011 +0200
+++ b/tuikit/eventsource.py	Thu Sep 08 11:37:27 2011 +0200
@@ -1,7 +1,8 @@
 # -*- coding: utf-8 -*-
 
 class EventSource:
-    '''Event source mixin.'''
+    
+    '''Event source base class.'''
 
     def __init__(self):
         self.event = dict()
--- a/tuikit/widget.py	Thu Sep 08 10:13:55 2011 +0200
+++ b/tuikit/widget.py	Thu Sep 08 11:37:27 2011 +0200
@@ -1,35 +1,58 @@
 # -*- coding: utf-8 -*-
 
-import curses
-
 from .eventsource import EventSource
 
 
 class Widget(EventSource):
 
-    """Base class for all widgets."""
+    '''Base class for all widgets.'''
 
     def __init__(self, width = 10, height = 10):
+        '''Blah.'''
         EventSource.__init__(self)
 
+        #: Parent widget.
         self.parent = None
+        
+        #: Top widget (same for every widget in one application).
         self.top = None
-        # placing - set by parent widget's layout manager
+        
+        # Position inside parent widget. Modified by layout manager.
         self.x = 0
         self.y = 0
-        # size
+        
+        # Actual size. Modified by layout manager.
         self._width = width
         self._height = height
+        
+        #: Minimal size of widget. Under normal circumstances
+        #: widget will never be sized smaller than this.
+        #: Tuple (w, h). Both must be integers >= 1.
         self.sizemin = (1,1)
+        
+        #: Maximum size of widget. Widget will never be sized bigger than this.
+        #: Tuple (w, h). Integers >= 1 or None (meaning no maximum size or infinite).
         self.sizemax = (None, None)
+        
+        #: Size request. This is default size of the widget. Will be fulfilled if possible.
+        #: Tuple (w, h). Integers >= 1 or None (meaning use minumal size).
         self.sizereq = (10,10)
+        
+        #: When false, the widget is not considered in layout.
         self.allowlayout = True
+        
+        #: Dictionary containing optional parameters for layout managers.
         self.layouthints = {}
+        
+        #: Hidden widget does not affect layout.
+        self.hidden = False
+        
         # cursor
         self.cursor = None
+        
         # redraw request
         self._redraw = True
-        self.hidden = False
+        
         # event handlers
         self.addevents(
             'resize',
@@ -93,6 +116,29 @@
                 screen.hidecursor()
 
 
+    def keypress(self, keyname, char):
+        handled = self.handle('keypress', keyname, char)
+        if not handled and self.parent and self.parent != self.top:
+            self.parent.emit('keypress', keyname, char)
+
+
+    def mousedown(self, ev):
+        self.setfocus()
+        self.handle('mousedown', ev)
+
+
+    def mouseup(self, ev):
+        self.handle('mouseup', ev)
+
+
+    def mousemove(self, ev):
+        self.handle('mousemove', ev)
+
+
+    def mousewheel(self, ev):
+        self.handle('mousewheel', ev)
+
+
     ### focus
 
 
@@ -130,32 +176,6 @@
         self.handle('unfocus', newfocus)
 
 
-    ### events
-
-
-    def keypress(self, keyname, char):
-        handled = self.handle('keypress', keyname, char)
-        if not handled and self.parent and self.parent != self.top:
-            self.parent.emit('keypress', keyname, char)
-
-
-    def mousedown(self, ev):
-        self.setfocus()
-        self.handle('mousedown', ev)
-
-
-    def mouseup(self, ev):
-        self.handle('mouseup', ev)
-
-
-    def mousemove(self, ev):
-        self.handle('mousemove', ev)
-
-
-    def mousewheel(self, ev):
-        self.handle('mousewheel', ev)
-
-
     ###
 
 
@@ -183,11 +203,13 @@
 
 
     def hide(self):
+        '''Hide widget. Convenience method.'''
         self.hidden = True
         self.redraw()
 
 
     def show(self):
+        '''Show widget. Convenience method.'''
         self.hidden = False
         self.redraw()
 
--- a/tuikit/window.py	Thu Sep 08 10:13:55 2011 +0200
+++ b/tuikit/window.py	Thu Sep 08 11:37:27 2011 +0200
@@ -5,7 +5,14 @@
 
 
 class Window(Container):
+    
+    '''Window widget.
+    
+    It represents part of screen with border, close button and contents.
+    Window can be moved, resized or closed by user.'''
+    
     def __init__(self, width=40, height=10):
+        '''Create window of requested size.'''
         Container.__init__(self, width, height)
 
         self.connect('draw', self.on_draw)
@@ -14,9 +21,15 @@
         self.connect('mousemove', self.on_mousemove)
         self.connect('resize', self.on_resize)
 
+        #: Window title.
         self.title = ''
+        
         self._closebutton = True
+        
+        #: Allow user to resize window.
         self.resizable = True
+        
+        #: Allow user to move window.
         self.movable = True
 
         self.resizing = False
@@ -37,6 +50,7 @@
 
     @property
     def closebutton(self):
+        '''Show/hide close button.'''
         return self._closebutton
 
     @closebutton.setter