@@ -25,7 +25,15 @@ class Element(object):
2525
2626 Parameters
2727 ----------
28- TODO: docstring.
28+ template: str, default None
29+ A jinaj2-compatible template string for rendering the element.
30+ If None, template will be:
31+ {% for name, element in this._children.items() %}
32+ {{element.render(**kwargs)}}
33+ {% endfor %}
34+ so that all the element's children are rendered.
35+ template_name: str, default None
36+ If no template is provided, you can also provide a filename.
2937 """
3038 def __init__ (self , template = None , template_name = None ):
3139 self ._name = 'Element'
@@ -42,7 +50,10 @@ def __init__(self, template=None, template_name=None):
4250 """ )
4351
4452 def get_name (self ):
45- """TODO: docstring."""
53+ """Returns a string representation of the object.
54+ This string has to be unique and to be a python and javascript-compatible
55+ variable name.
56+ """
4657 return _camelify (self ._name ) + '_' + self ._id
4758
4859 def _get_self_bounds (self ):
@@ -95,7 +106,7 @@ def add_to(self, parent, name=None, index=None):
95106 return self
96107
97108 def to_dict (self , depth = - 1 , ordered = True , ** kwargs ):
98- """TODO: docstring ."""
109+ """Returns a dict representation of the object ."""
99110 if ordered :
100111 dict_fun = OrderedDict
101112 else :
@@ -109,7 +120,7 @@ def to_dict(self, depth=-1, ordered=True, **kwargs):
109120 return out
110121
111122 def to_json (self , depth = - 1 , ** kwargs ):
112- """TODO: docstring ."""
123+ """Returns a JSON representation of the object ."""
113124 return json .dumps (self .to_dict (depth = depth , ordered = True ), ** kwargs )
114125
115126 def get_root (self ):
@@ -146,15 +157,15 @@ def save(self, outfile, close_file=True, **kwargs):
146157
147158
148159class Link (Element ):
149- """TODO: docstring ."""
160+ """An abstract class for embedding a link in the HTML ."""
150161 def get_code (self ):
151- """TODO : docstring ."""
162+ """Opens the link and returns the response's content ."""
152163 if self .code is None :
153164 self .code = urlopen (self .url ).read ()
154165 return self .code
155166
156167 def to_dict (self , depth = - 1 , ** kwargs ):
157- """TODO : docstring ."""
168+ """Returns a dict representation of the object ."""
158169 out = super (Link , self ).to_dict (depth = - 1 , ** kwargs )
159170 out ['url' ] = self .url
160171 return out
@@ -331,15 +342,15 @@ def __init__(self, width="100%", height=None, ratio="60%", figsize=None):
331342 """ ), name = 'css_style' )
332343
333344 def to_dict (self , depth = - 1 , ** kwargs ):
334- """TODO: docstring ."""
345+ """Returns a dict representation of the object ."""
335346 out = super (Figure , self ).to_dict (depth = depth , ** kwargs )
336347 out ['header' ] = self .header .to_dict (depth = depth - 1 , ** kwargs )
337348 out ['html' ] = self .html .to_dict (depth = depth - 1 , ** kwargs )
338349 out ['script' ] = self .script .to_dict (depth = depth - 1 , ** kwargs )
339350 return out
340351
341352 def get_root (self ):
342- """TODO: docstring ."""
353+ """Returns the root of the elements tree ."""
343354 return self
344355
345356 def render (self , ** kwargs ):
@@ -375,7 +386,21 @@ def _repr_html_(self, **kwargs):
375386 return iframe
376387
377388 def add_subplot (self , x , y , n , margin = 0.05 ):
378- """TODO: docstring."""
389+ """Creates a div child subplot in a matplotlib.figure.add_subplot style.
390+
391+ Parameters
392+ ----------
393+ x : int
394+ The number of rows in the grid.
395+ y : int
396+ The number of columns in the grid.
397+ n : int
398+ The cell number in the grid, counted from 1 to x*y.
399+
400+ Example:
401+ >>> fig.add_subplot(3,2,5)
402+ # Create a div in the 5th cell of a 3rows x 2columns grid(bottom-left corner).
403+ """
379404 width = 1. / y
380405 height = 1. / x
381406 left = ((n - 1 ) % y )* width
@@ -427,11 +452,21 @@ def __init__(self, data, width="100%", height="100%"):
427452
428453
429454class Div (Figure ):
430- """Create a Map with Folium and Leaflet.js .
455+ """Create a Div to be embedded in a Figure .
431456
432457 Parameters
433458 ----------
434- TODO: docstring.
459+ width: int or str, default '100%'
460+ The width of the div in pixels (int) or percentage (str).
461+ height: int or str, default '100%'
462+ The height of the div in pixels (int) or percentage (str).
463+ left: int or str, default '0%'
464+ The left-position of the div in pixels (int) or percentage (str).
465+ top: int or str, default '0%'
466+ The top-position of the div in pixels (int) or percentage (str).
467+ position: str, default 'relative'
468+ The position policy of the div.
469+ Usual values are 'relative', 'absolute', 'fixed', 'static'.
435470 """
436471 def __init__ (self , width = '100%' , height = '100%' ,
437472 left = "0%" , top = "0%" , position = 'relative' ):
@@ -475,7 +510,7 @@ def __init__(self, width='100%', height='100%',
475510 """ )
476511
477512 def get_root (self ):
478- """TODO: docstring ."""
513+ """Returns the root of the elements tree ."""
479514 return self
480515
481516 def render (self , ** kwargs ):
0 commit comments