Package Camelot :: Package camelot :: Package core :: Package document
[frames] | no frames]

Source Code for Package Camelot.camelot.core.document

 1  """Decorators to enhance the docstrings of classes 
 2  """ 
 3   
4 -def documented_entity():
5 """Class decorator to append an image of the default view for 6 an entity to an entity class. The image can be generated by using 7 the testing framework to create images of all default views in an 8 application :: 9 10 @documented_entity() 11 class Movie(Entity): 12 '''A movie as played in the theater''' 13 title = Field(Unicode(50)) 14 15 The resulting docstring of the Movie entity will be :: 16 17 '''A movie as played in the theater 18 19 image ../_static/entityviews/new_view_movie.png 20 ''' 21 """ 22 23 def document_entity(model): 24 model.__doc__ = (model.__doc__ or '') + """ 25 26 .. image:: ../_static/entityviews/new_view_%s.png 27 """%(model.__name__.lower()) 28 return model
29 30 return document_entity 31 32
33 -def documented_type():
34 """Class decorator to append an image of the default editor of 35 a field type to the docstring of the type""" 36 37 def document_type(field_type): 38 field_type.__doc__ = (field_type.__doc__ or '') + """ 39 40 .. image:: ../_static/editors/%s_editable.png 41 """ 42 return field_type
43 44 return document_type 45