Browse Source

Some Doxygen comments fix

Yann Weber 9 years ago
parent
commit
1c4e2ddba8

+ 3
- 1
EditorialModel/backend/json_backend.py View File

@@ -87,7 +87,9 @@ class EmBackendJson(EmBackendDummy):
87 87
         return data
88 88
 
89 89
     ## Saves the data in the data source json file
90
-    # @param filename str : The filename to save the EM in (if None use self.json_file provided at init )
90
+    # @param model Model : The editorial model
91
+    # @param filename str|None : The filename to save the EM in (if None use self.json_file provided at init )
92
+    # @return json string
91 93
     def save(self, model, filename=None):
92 94
         json_dump = json.dumps({component.uid: component.attr_flat() for component in model.components()}, default=self.date_handler, indent=True)
93 95
         if self._json_file:

+ 1
- 1
EditorialModel/backend/lodel1_backend.py View File

@@ -102,7 +102,7 @@ class EmBackendLodel1(EmBackendDummy):
102 102
         return new_dic
103 103
 
104 104
     ## convert collection of dom element to a dict
105
-    # <col name="id">252</col> => {'id':'252'}
105
+    # \<col name="id"\>252\</col\> => {'id':'252'}
106 106
     def _dom_elements_to_dict(self, elements):
107 107
         fields = {}
108 108
         for element in elements:

+ 3
- 4
EditorialModel/classtypes.py View File

@@ -125,6 +125,7 @@ class EmClassType(object):
125 125
     }
126 126
 
127 127
     ## @brief return a classtype from its name
128
+    # @param cls 
128 129
     # @param classtype str : A classtype name
129 130
     # @return None if no classtype with this name, else return a dict containing classtype informations
130 131
     @classmethod
@@ -140,11 +141,9 @@ class EmClassType(object):
140 141
     def getall(cls):
141 142
         return [cls.entity, cls.entry, cls.person]
142 143
 
143
-    ## natures (Method)
144
+    ## @brief Return possible nature of relations for a classtype name
144 145
     #
145
-    # Return possible nature of relations for a classtype name
146
-    #
147
-    # @param classtype str: The classtype name
146
+    # @param classtype_name str: The classtype name
148 147
     # @return A list of EmNature names (list of str)
149 148
     @staticmethod
150 149
     def natures(classtype_name):

+ 1
- 2
EditorialModel/components.py View File

@@ -11,11 +11,10 @@ import EditorialModel
11 11
 from Lodel.utils.mlstring import MlString
12 12
 
13 13
 
14
-## This class is the mother class of all editorial model objects
14
+## @brief This class is the mother class of all editorial model objects
15 15
 #
16 16
 # It gather all the properties and mechanism that are common to every editorial model objects
17 17
 # @see EditorialModel::classes::EmClass, EditorialModel::types::EmType, EditorialModel::fieldgroups::EmFieldGroup, EditorialModel::fields::EmField
18
-# @pure
19 18
 class EmComponent(object):
20 19
 
21 20
     ## Used by EmComponent::modify_rank

+ 0
- 1
EditorialModel/fields.py View File

@@ -28,7 +28,6 @@ class EmField(EmComponent):
28 28
     # @param internal str|bool : If False the field is not internal, else it can takes value in "object" or "automatic"
29 29
     # @param rel_field_id int|None : If not None indicates that the field is a relation attribute (and the value is the UID of the rel2type field)
30 30
     # @param nullable bool : If True None values are allowed
31
-    # @param default * : Default field value
32 31
     # @param uniq bool : if True the value should be uniq in the db table
33 32
     # @param **kwargs : more keywords arguments for the fieldtype
34 33
     def __init__(self, model, uid, name, fieldgroup_id, fieldtype, optional=False, internal=False, rel_field_id=None, icon='0', string=None, help_text=None, date_update=None, date_create=None, rank=None, nullable=False, uniq=False, **kwargs):

+ 1
- 0
EditorialModel/fieldtypes/datetime.py View File

@@ -11,6 +11,7 @@ class EmFieldType(GenericFieldType):
11 11
     ## @brief A datetime field
12 12
     # @param now_on_update bool : If true the date is set to NOW on update
13 13
     # @param now_on_create bool : If true the date is set to NEW on creation
14
+    # @param **kwargs
14 15
     def __init__(self, now_on_update=False, now_on_create=False, **kwargs):
15 16
         self.now_on_update = now_on_update
16 17
         self.now_on_create = now_on_create

+ 0
- 1
EditorialModel/fieldtypes/generic.py View File

@@ -16,7 +16,6 @@ class GenericFieldType(object):
16 16
     
17 17
     ## @brief Instanciate a new fieldtype
18 18
     # @param ftype str : The type of datas handled by this fieldtype
19
-    # @param default ? : The default value
20 19
     # @param nullable bool : is None allowed as value ?
21 20
     # @param check_function function : A callback check function that takes 1 argument and raise a TypeError if the validation fails
22 21
     # @param uniq bool : Indicate if a field should handle uniq values

+ 3
- 2
EditorialModel/fieldtypes/regexchar.py View File

@@ -10,12 +10,13 @@ class EmFieldType(EditorialModel.fieldtypes.char.EmFieldType):
10 10
     ## @brief A char field validated with a regex
11 11
     # @param regex str : a regex string (passed as argument to re.compile() )
12 12
     # @param max_length int : the maximum length for this field
13
-    def __init__(self, regex='', **kwargs):
13
+    # @param **kwargs
14
+    def __init__(self, regex='', max_length = 10, **kwargs):
14 15
         self.regex = regex
15 16
         v_re = re.compile(regex)  # trigger an error if invalid regex
16 17
         
17 18
         def re_match(value):
18 19
             if not v_re.match(regex, value):
19 20
                 raise TypeError('"%s" don\'t match the regex "%s"'%(value, regex))
20
-        super(EmFieldType, self).__init__(check_function=re_match,**kwargs)
21
+        super(EmFieldType, self).__init__(check_function=re_match, max_length=max_length, **kwargs)
21 22
 

+ 8
- 4
EditorialModel/model.py View File

@@ -1,7 +1,7 @@
1 1
 #-*- coding: utf-8 -*-
2 2
 
3
-## @file editorialmodel.py
4
-# Manage instance of an editorial model
3
+## @package EditorialModel.model
4
+# Contains the class managing and editorial model
5 5
 
6 6
 import EditorialModel
7 7
 from EditorialModel.migrationhandler.dummy import DummyMigrationHandler
@@ -14,7 +14,7 @@ from EditorialModel.exceptions import EmComponentCheckError, EmComponentNotExist
14 14
 import hashlib
15 15
 
16 16
 
17
-## Manages the Editorial Model
17
+## @brief Manages the Editorial Model
18 18
 class Model(object):
19 19
 
20 20
     components_class = [EmClass, EmType, EmFieldGroup, EmField]
@@ -22,6 +22,7 @@ class Model(object):
22 22
     ## Constructor
23 23
     #
24 24
     # @param backend unknown: A backend object instanciated from one of the classes in the backend module
25
+    # @param migration_handler : A migration handler
25 26
     def __init__(self, backend, migration_handler=None):
26 27
         if migration_handler is None:
27 28
             self.migration_handler = DummyMigrationHandler()
@@ -145,7 +146,7 @@ class Model(object):
145 146
         return False
146 147
 
147 148
     ## Sort components by rank in Model::_components
148
-    # @param emclass pythonClass : The type of components to sort
149
+    # @param component_class pythonClass : The type of components to sort
149 150
     # @throw AttributeError if emclass is not valid
150 151
     # @warning disabled the test on component_class because of EmField new way of working
151 152
     def sort_components(self, component_class):
@@ -164,6 +165,9 @@ class Model(object):
164 165
     #
165 166
     # @note if datas does not contains a rank the new component will be added last
166 167
     # @note datas['rank'] can be an integer or two specials strings 'last' or 'first'
168
+    #
169
+    # @warning The uid parameter is designed to be used only by Model.load()
170
+    # @param uid int|None : If given, don't generate a new uid
167 171
     # @param component_type str : a component type ( component_class, component_fieldgroup, component_field or component_type )
168 172
     # @param datas dict : the options needed by the component creation
169 173
     # @return The created EmComponent

+ 1
- 0
EditorialModel/randomem.py View File

@@ -47,6 +47,7 @@ class RandomEm(object):
47 47
     # - optfield : Chances for a field to be optionnal (default 2)
48 48
     # @param backend : A backend to use with the new EM
49 49
     # @param **kwargs dict : Provide tunable generation parameter
50
+    # @param cls
50 51
     # @return A randomly generate EM
51 52
     def random_em(cls, backend=None, **kwargs):
52 53
         ed_mod = Model(EmBackendDummy if backend is None else backend)

+ 2
- 0
EditorialModel/types.py View File

@@ -49,7 +49,9 @@ class EmType(EmComponent):
49 49
     ## Create a new EmType and instanciate it
50 50
     # @param name str: The name of the new type
51 51
     # @param em_class EmClass: The class that the new type will specialize
52
+    # @param sortcolumn str : The name of the field that will be used to sort
52 53
     # @param **em_component_args : @ref EditorialModel::components::create()
54
+    # @param cls
53 55
     # @return An EmType instance
54 56
     # @throw EmComponentExistError if an EmType with this name but different attributes exists
55 57
     # @see EmComponent::__init__()

+ 2
- 2
leobject/leclass.py View File

@@ -16,8 +16,8 @@ class LeClass(object):
16 16
     _class_id = None
17 17
 
18 18
     ## @brief Instanciate a new LeClass
19
-    # @param model Model : The editorial model
20
-    # @param datasource ? : The datasource
19
+    # @note Abstract method
20
+    # @param **kwargs
21 21
     def __init__(self, **kwargs):
22 22
         raise NotImplementedError("Abstract class")
23 23
     

+ 25
- 8
leobject/lefactory.py View File

@@ -6,7 +6,8 @@ import EditorialModel
6 6
 from EditorialModel.model import Model
7 7
 from EditorialModel.fieldtypes.generic import GenericFieldType
8 8
 
9
-## @brief The factory that will return LeObject childs instances
9
+## @brief This class is designed to generated the leobject API given an EditorialModel.model
10
+# @note Contains only static methods
10 11
 #
11 12
 # The name is not good but i've no other ideas for the moment
12 13
 class LeFactory(object):
@@ -66,12 +67,13 @@ class LeFactory(object):
66 67
                 cls_fieldgroup[fieldgroup.name].append(field.name)
67 68
         
68 69
         return """
70
+#Initialisation of {name} class attributes
69 71
 {name}._fieldtypes = {ftypes}
70 72
 {name}._linked_types = {ltypes}
71 73
 {name}._fieldgroups = {fgroups}
72 74
 """.format(
73 75
     name = LeFactory.name2classname(emclass.name),
74
-    ftypes = "{"+(','.join([ '\n%s:%s'%(repr(f),v) for f,v in cls_fields.items()]))+"}",
76
+    ftypes = "{"+(','.join([ '\n\t%s:%s'%(repr(f),v) for f,v in cls_fields.items()]))+"\n}",
75 77
     ltypes = "{"+(','.join(cls_linked_types))+'}',
76 78
     fgroups = repr(cls_fieldgroup)
77 79
 )
@@ -94,6 +96,7 @@ class LeFactory(object):
94 96
             ))
95 97
 
96 98
         return """
99
+#Initialisation of {name} class attributes
97 100
 {name}._fields = {fields}
98 101
 {name}._superiors = {dsups}
99 102
 {name}._leclass = {leclass}
@@ -138,6 +141,8 @@ import %s
138 141
             leobj_me_uid[comp.uid] = LeFactory.name2classname(comp.name)
139 142
 
140 143
         result += """
144
+## @brief _LeObject concret clas
145
+# @see leobject::leobject::_LeObject
141 146
 class LeObject(_LeObject):
142 147
     _model = Model(backend=%s)
143 148
     _datasource = %s(**%s)
@@ -151,15 +156,26 @@ class LeObject(_LeObject):
151 156
         #LeClass child classes definition
152 157
         for emclass in emclass_l:
153 158
            result += """
154
-class %s(LeObject,LeClass):
155
-    _class_id = %d
156
-"""%(LeFactory.name2classname(emclass.name), emclass.uid)
159
+## @brief EmClass {name} LeClass child class
160
+# @see leobject::leclass::LeClass
161
+class {name}(LeObject,LeClass):
162
+    _class_id = {uid}
163
+""".format(
164
+    name = LeFactory.name2classname(emclass.name),
165
+    uid = emclass.uid
166
+)
157 167
         #LeType child classes definition
158 168
         for emtype in emtype_l:
159 169
            result += """
160
-class %s(%s,LeType):
161
-    _type_id = %d
162
-"""%(LeFactory.name2classname(emtype.name),LeFactory.name2classname(emtype.em_class.name),emtype.uid)
170
+## @brief EmType {name} LeType child class
171
+# @see leobject::letype::LeType
172
+class {name}({leclass},LeType):
173
+    _type_id = {uid}
174
+""".format(
175
+    name = LeFactory.name2classname(emtype.name),
176
+    leclass = LeFactory.name2classname(emtype.em_class.name),
177
+    uid = emtype.uid
178
+)
163 179
             
164 180
         #Set attributes of created LeClass and LeType child classes
165 181
         for emclass in emclass_l:
@@ -169,6 +185,7 @@ class %s(%s,LeType):
169 185
 
170 186
         #Populating LeObject._me_uid dict for a rapid fetch of LeType and LeClass given an EM uid
171 187
         result += """
188
+## @brief Dict for getting LeClass and LeType child classes given an EM uid
172 189
 LeObject._me_uid = %s
173 190
 """%repr({ comp.uid:LeFactory.name2classname(comp.name) for comp in emclass_l + emtype_l })
174 191
             

+ 12
- 4
leobject/leobject.py View File

@@ -1,12 +1,19 @@
1 1
 #-*- coding: utf-8 -*-
2 2
 
3
-## @package EditorialModel::leobject::leobject
4
-# @brief Main class to handle objects defined by the types of an Editorial Model
5
-# an instance of these objects is pedantically called LeObject !
3
+## @package leobject API to access lodel datas
4
+#
5
+# This package contains abstract classes leobject.leclass.LeClass , leobject.letype.LeType, leobject.leobject._LeObject.
6
+# Those abstract classes are designed to be mother classes of dynamically generated classes ( see leobject.lefactory.LeFactory )
7
+
8
+## @package leobject.leobject
9
+# @brief Abstract class designed to be implemented by LeObject
10
+#
11
+# @note LeObject will be generated by leobject.lefactory.LeFactory
6 12
 
7 13
 import re
8 14
 from EditorialModel.types import EmType
9 15
 
16
+## @brief Main class to handle objects defined by the types of an Editorial Model
10 17
 class _LeObject(object):
11 18
     
12 19
     ## @brief The editorial model
@@ -165,7 +172,7 @@ class _LeObject(object):
165 172
         return field.startwith('superior.')
166 173
     
167 174
     ## @brief Check that a relational field is valid
168
-    # @param fields str : a relational field
175
+    # @param field str : a relational field
169 176
     # @return a nature
170 177
     @staticmethod
171 178
     def _nature_from_relational_field(field):
@@ -180,6 +187,7 @@ class _LeObject(object):
180 187
     ## @brief Check and split a query filter
181 188
     # @note The query_filter format is "FIELD OPERATOR VALUE"
182 189
     # @param query_filter str : A query_filter string
190
+    # @param cls
183 191
     # @return a tuple (FIELD, OPERATOR, VALUE)
184 192
     @classmethod
185 193
     def _split_filter(cls, query_filter):

+ 16
- 4
leobject/letype.py View File

@@ -1,5 +1,15 @@
1 1
 #-*- coding: utf-8 -*-
2 2
 
3
+## @package leobject API to access lodel datas
4
+#
5
+# This package contains abstract classes leobject.leclass.LeClass , leobject.letype.LeType, leobject.leobject._LeObject.
6
+# Those abstract classes are designed to be mother classes of dynamically generated classes ( see leobject.lefactory.LeFactory )
7
+
8
+## @package leobject.leobject
9
+# @brief Abstract class designed to be implemented by LeObject
10
+#
11
+# @note LeObject will be generated by leobject.lefactory.LeFactory
12
+
3 13
 from Lodel.utils.classinstancemethod import classinstancemethod
4 14
 from leobject.leclass import LeClass
5 15
 from leobject.leobject import LeObjectError
@@ -64,12 +74,13 @@ class LeType(object):
64 74
         pass
65 75
     
66 76
     ## @brief Delete a LeType from the datasource
67
-    # @param lodel_id int : The lodel_id identifying the LeType
68
-    # @param return True if deleted False if not existing
77
+    # @param lodel_id_l list : List of lodel_id to be deleted
78
+    # @param cls
79
+    # @return True if deleted False if not existing
69 80
     # @throw InvalidArgumentError if invalid parameters
70 81
     # @throw Leo exception if the lodel_id identify an object from another type
71 82
     @delete.classmethod
72
-    def delete(cls, uid_l):
83
+    def delete(cls, lodel_id_l):
73 84
         pass
74 85
 
75 86
     @classinstancemethod
@@ -118,6 +129,7 @@ class LeType(object):
118 129
     ## @brief Check that datas are valid for this type
119 130
     # @param datas dict : key == field name value are field values
120 131
     # @param complete bool : if True expect that datas provide values for all non internal fields
132
+    # @param cls
121 133
     # @return True if check pass else False
122 134
     def check_datas(cls, datas, complete = False):
123 135
         try:
@@ -150,7 +162,7 @@ class LeType(object):
150 162
     ## @brief Add a superior
151 163
     # @param nature str : The raltion nature
152 164
     # @param leo LeObject : The superior
153
-    # @param return True if done False if already done
165
+    # @return True if done False if already done
154 166
     # @throw A Leo exception if trying to link with an invalid leo
155 167
     # @throw InvalidArgumentError if invalid argument
156 168
     def set_superior(self, nature, leo):

Loading…
Cancel
Save