@@ -25,7 +25,15 @@ class Element(object):
25
25
26
26
Parameters
27
27
----------
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.
29
37
"""
30
38
def __init__ (self , template = None , template_name = None ):
31
39
self ._name = 'Element'
@@ -42,7 +50,10 @@ def __init__(self, template=None, template_name=None):
42
50
""" )
43
51
44
52
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
+ """
46
57
return _camelify (self ._name ) + '_' + self ._id
47
58
48
59
def _get_self_bounds (self ):
@@ -95,7 +106,7 @@ def add_to(self, parent, name=None, index=None):
95
106
return self
96
107
97
108
def to_dict (self , depth = - 1 , ordered = True , ** kwargs ):
98
- """TODO: docstring ."""
109
+ """Returns a dict representation of the object ."""
99
110
if ordered :
100
111
dict_fun = OrderedDict
101
112
else :
@@ -109,7 +120,7 @@ def to_dict(self, depth=-1, ordered=True, **kwargs):
109
120
return out
110
121
111
122
def to_json (self , depth = - 1 , ** kwargs ):
112
- """TODO: docstring ."""
123
+ """Returns a JSON representation of the object ."""
113
124
return json .dumps (self .to_dict (depth = depth , ordered = True ), ** kwargs )
114
125
115
126
def get_root (self ):
@@ -146,15 +157,15 @@ def save(self, outfile, close_file=True, **kwargs):
146
157
147
158
148
159
class Link (Element ):
149
- """TODO: docstring ."""
160
+ """An abstract class for embedding a link in the HTML ."""
150
161
def get_code (self ):
151
- """TODO : docstring ."""
162
+ """Opens the link and returns the response's content ."""
152
163
if self .code is None :
153
164
self .code = urlopen (self .url ).read ()
154
165
return self .code
155
166
156
167
def to_dict (self , depth = - 1 , ** kwargs ):
157
- """TODO : docstring ."""
168
+ """Returns a dict representation of the object ."""
158
169
out = super (Link , self ).to_dict (depth = - 1 , ** kwargs )
159
170
out ['url' ] = self .url
160
171
return out
@@ -331,15 +342,15 @@ def __init__(self, width="100%", height=None, ratio="60%", figsize=None):
331
342
""" ), name = 'css_style' )
332
343
333
344
def to_dict (self , depth = - 1 , ** kwargs ):
334
- """TODO: docstring ."""
345
+ """Returns a dict representation of the object ."""
335
346
out = super (Figure , self ).to_dict (depth = depth , ** kwargs )
336
347
out ['header' ] = self .header .to_dict (depth = depth - 1 , ** kwargs )
337
348
out ['html' ] = self .html .to_dict (depth = depth - 1 , ** kwargs )
338
349
out ['script' ] = self .script .to_dict (depth = depth - 1 , ** kwargs )
339
350
return out
340
351
341
352
def get_root (self ):
342
- """TODO: docstring ."""
353
+ """Returns the root of the elements tree ."""
343
354
return self
344
355
345
356
def render (self , ** kwargs ):
@@ -375,7 +386,21 @@ def _repr_html_(self, **kwargs):
375
386
return iframe
376
387
377
388
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
+ """
379
404
width = 1. / y
380
405
height = 1. / x
381
406
left = ((n - 1 ) % y )* width
@@ -427,11 +452,21 @@ def __init__(self, data, width="100%", height="100%"):
427
452
428
453
429
454
class Div (Figure ):
430
- """Create a Map with Folium and Leaflet.js .
455
+ """Create a Div to be embedded in a Figure .
431
456
432
457
Parameters
433
458
----------
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'.
435
470
"""
436
471
def __init__ (self , width = '100%' , height = '100%' ,
437
472
left = "0%" , top = "0%" , position = 'relative' ):
@@ -475,7 +510,7 @@ def __init__(self, width='100%', height='100%',
475
510
""" )
476
511
477
512
def get_root (self ):
478
- """TODO: docstring ."""
513
+ """Returns the root of the elements tree ."""
479
514
return self
480
515
481
516
def render (self , ** kwargs ):
0 commit comments