diff --git a/src/diana/drawer/svg.py b/src/diana/drawer/svg.py --- a/src/diana/drawer/svg.py +++ b/src/diana/drawer/svg.py @@ -23,6 +23,12 @@ class Svg(Drawer): self.padding = 30 def render(self, template_name, bgcolor=""): + """Render the template with the current drawer state. + + :param str template_name: a template file name in the templ directory + :param bgcolor: a background color + :type bgcolor: an SVG color, which is the same as a CSS color + :return: the rendered template string""" points = [p for (i, p) in sorted(self._index.values(), key=lambda x: x[0])] stones = [p for p in points if p.color and p.label == ""] @@ -36,6 +42,12 @@ class Svg(Drawer): return self._env.get_template(template_name).render(params) def save(self, filename, template="templ.svg", bgcolor=""): + """Render the template and save it with the filename. + + :param str filename: a path where to save the diagram. SVG and TXT suffixes will be appended + :param str template: a template file name in the templ directory + :param bgcolor: a background color + :type bgcolor: an SVG color, which is the same as a CSS color""" file = open(filename+".svg", 'w') file.write(self.render(template, bgcolor)) file.close()