Ignore:
Timestamp:
02/22/13 12:44:41 (14 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Added rst documentation for the registry package.

Fixing docstrings in the process.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/registry/base.py

    r11282 r11368  
    1818 
    1919class WidgetRegistry(object): 
    20     """A container for widget and category descriptions. 
     20    """ 
     21    A container for widget and category descriptions. 
    2122 
    2223    This class is most often used with WidgetDiscovery class but can 
     
    2425 
    2526    >>> reg = WidgetRegistry() 
    26     >>> file_desc = description.WidgetDescription.from_module( 
     27    >>> file_desc = WidgetDescription.from_module( 
    2728    ...     "Orange.OrangeWidgets.Data.OWFile" 
    2829    ... ) 
    2930    ... 
    30     >>> reg.register_widget(file_desc) 
    31     >>> reg.widgets() 
     31    >>> reg.register_widget(file_desc)  # register the description 
     32    >>> print reg.widgets() 
    3233    [... 
     34 
     35    Parameters 
     36    ---------- 
     37    other : :class:`WidgetRegistry`, optional 
     38        If supplied the registry is initialized with the contents of `other`. 
    3339 
    3440    """ 
     
    5258 
    5359    def categories(self): 
    54         """List all top level widget categories ordered by priority. 
     60        """ 
     61        Return a list all top level :class:`CategoryDescription` instances 
     62        ordered by priority. 
     63 
    5564        """ 
    5665        return [c for c, _ in self.registry] 
    5766 
    5867    def category(self, name): 
    59         """Return category with `name`. 
     68        """ 
     69        Find a :class:`CategoryDescription` by its `name`. 
    6070 
    6171        .. note:: Categories are identified by `name` attribute in contrast 
    62             with widgets which are identified by `qualified_name`. 
     72                  with widgets which are identified by `qualified_name`. 
     73 
     74        Parameters 
     75        ---------- 
     76        name : str 
     77            Category name 
    6378 
    6479        """ 
     
    6681 
    6782    def has_category(self, name): 
    68         """Does the category with `name` exist in this registry. 
     83        """ 
     84        Does a category with `name` exist in this registry. 
     85 
     86        Parameters 
     87        ---------- 
     88        name : str 
     89            Category name 
     90 
    6991        """ 
    7092        return name in self._categories_dict 
    7193 
    7294    def widgets(self, category=None): 
    73         """List all widgets in a `category`. If no category is 
    74         specified list widgets in all categories. 
     95        """ 
     96        Return a list of all widgets in the registry. If `category` is 
     97        specified return only widgets which belong to the category. 
     98 
     99        Parameters 
     100        ---------- 
     101        category : :class:`CategoryDescription` or str, optional 
     102            Return only descriptions of widgets belonging to the category. 
    75103 
    76104        """ 
     
    92120 
    93121    def widget(self, qualified_name): 
    94         """Return widget description for `qualified_name`. 
    95         Raise KeyError if the description does not exist. 
     122        """ 
     123        Return a :class:`WidgetDescription` identified by `qualified_name`. 
     124 
     125        Raise :class:`KeyError` if the description does not exist. 
     126 
     127        Parameters 
     128        ---------- 
     129        qualified_name : str 
     130            Widget description qualified name 
     131 
     132        See also 
     133        -------- 
     134        WidgetDescription 
    96135 
    97136        """ 
     
    99138 
    100139    def has_widget(self, qualified_name): 
    101         """Does the widget with `qualified_name` exist in this registry. 
     140        """ 
     141        Does the widget with `qualified_name` exist in this registry. 
    102142        """ 
    103143        return qualified_name in self._widgets_dict 
    104144 
    105145    def register_widget(self, desc): 
    106         """Register a widget by its description. 
     146        """ 
     147        Register a :class:`WidgetDescription` instance. 
    107148        """ 
    108149        if not isinstance(desc, description.WidgetDescription): 
     
    128169 
    129170    def register_category(self, desc): 
    130         """Register category by its description. 
     171        """ 
     172        Register a :class:`CategoryDescription` instance. 
    131173 
    132174        .. note:: It is always best to register the category 
    133             before the widgets belonging to it. 
     175                  before the widgets belonging to it. 
    134176 
    135177        """ 
     
    150192 
    151193    def _insert_category(self, desc): 
    152         """Insert category description into 'registry' list 
     194        """ 
     195        Insert category description into 'registry' list 
    153196        """ 
    154197        priority = desc.priority 
     
    161204 
    162205    def _insert_widget(self, category, desc): 
    163         """Insert widget description `desc` into `category`. 
     206        """ 
     207        Insert widget description `desc` into `category`. 
    164208        """ 
    165209        assert(isinstance(category, description.CategoryDescription)) 
Note: See TracChangeset for help on using the changeset viewer.