@@ -67,7 +67,11 @@ def get_bounds(self):
6767 return bounds
6868
6969 def add_children (self , child , name = None , index = None ):
70- """Add a children."""
70+ """Add a child."""
71+ return self .add_child (child , name = name , index = index )
72+
73+ def add_child (self , child , name = None , index = None ):
74+ """Add a child."""
7175 if name is None :
7276 name = child .get_name ()
7377 if index is None :
@@ -78,10 +82,12 @@ def add_children(self, child, name=None, index=None):
7882 items .insert (int (index ), (name , child ))
7983 self ._children = items
8084 child ._parent = self
85+ return self
8186
8287 def add_to (self , parent , name = None , index = None ):
8388 """Add element to a parent."""
8489 parent .add_children (self , name = name , index = index )
90+ return self
8591
8692 def to_dict (self , depth = - 1 , ordered = True , ** kwargs ):
8793 if ordered :
@@ -107,7 +113,7 @@ def get_root(self):
107113 return self ._parent .get_root ()
108114
109115 def render (self , ** kwargs ):
110- """TODO : docstring here ."""
116+ """Renders the HTML representation of the element ."""
111117 return self ._template .render (this = self , kwargs = kwargs )
112118
113119 def save (self , outfile , close_file = True , ** kwargs ):
@@ -325,7 +331,7 @@ def get_root(self):
325331 return self
326332
327333 def render (self , ** kwargs ):
328- """TODO : docstring here ."""
334+ """Renders the HTML representation of the element ."""
329335 for name , child in self ._children .items ():
330336 child .render (** kwargs )
331337 return self ._template .render (this = self , kwargs = kwargs )
@@ -378,8 +384,21 @@ def add_subplot(self, x, y, n, margin=0.05):
378384
379385
380386class Html (Element ):
387+ """A basic Element for embedding HTML."""
381388 def __init__ (self , data , width = "100%" , height = "100%" ):
382- """TODO : docstring here"""
389+ """Create an HTML div object for embedding data.
390+
391+ Parameters
392+ ----------
393+ data : str
394+ The HTML data to be embedded.
395+ width : int or str, default '100%'
396+ The width of the output div element.
397+ Ex: 120 , '120px', '80%'
398+ height : int or str, default '100%'
399+ The height of the output div element.
400+ Ex: 120 , '120px', '80%'
401+ """
383402 super (Html , self ).__init__ ()
384403 self ._name = 'Html'
385404 self .data = data
@@ -441,7 +460,7 @@ def get_root(self):
441460 return self
442461
443462 def render (self , ** kwargs ):
444- """TODO : docstring here ."""
463+ """Renders the HTML representation of the element ."""
445464 figure = self ._parent
446465 assert isinstance (figure , Figure ), ("You cannot render this Element "
447466 "if it's not in a Figure." )
@@ -521,12 +540,7 @@ def __init__(self, html=None, width="100%", height=None, ratio="60%",
521540 self .add_children (html )
522541
523542 def render (self , ** kwargs ):
524- """Displays the Figure in a Jupyter notebook.
525-
526- Parameters
527- ----------
528-
529- """
543+ """Renders the HTML representation of the element."""
530544 html = super (IFrame , self ).render (** kwargs )
531545 html = "data:text/html;base64," + base64 .b64encode (html .encode ('utf8' )).decode ('utf8' ) # noqa
532546
@@ -566,13 +580,14 @@ class MacroElement(Element):
566580 {% endmacro %}
567581 """
568582 def __init__ (self ):
569- """TODO : docstring here """
583+ """Creates a MacroElement object. """
570584 super (MacroElement , self ).__init__ ()
571585 self ._name = 'MacroElement'
572586
573587 self ._template = Template (u"" )
574588
575589 def render (self , ** kwargs ):
590+ """Renders the HTML representation of the element."""
576591 figure = self .get_root ()
577592 assert isinstance (figure , Figure ), ("You cannot render this Element "
578593 "if it's not in a Figure." )
0 commit comments