From c849c0136336d81c4d2cafbe10e0d5cf23c27ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Sun, 21 Jul 2013 13:13:39 -0600 Subject: [PATCH] Update internal documentation. --- __init__.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/__init__.py b/__init__.py index 6d13da3..220f955 100644 --- a/__init__.py +++ b/__init__.py @@ -26,8 +26,11 @@ Secretary Take the power of Jinja2 templates to OpenOffice and LibreOffice. -This file implements BaseRender. BaseRender prepares a XML which describes -ODT document content to be processed by jinja2 or Django template system. +This file implements Render. Render provides an interface to render +Open Document Format (ODF) documents to be used as templates using +the jinja2 template engine. To render a template: + engine = Render(template_file) + result = engine.render(template_var1=...) """ import re @@ -76,11 +79,18 @@ def pad_string(value, length=5): class Render(): """ - Prapares a XML string or file to be processed by a templating system. + Main engine to convert and ODT document into a jinja + compatible template. Render provides an enviroment + variable which can be manipulated to provide custom + filters to the ODF render. + + engine = Render('template.odt') + engine.enviroment.filters['custom_filer'] = filter_function + result = engine.render() - Use example: - render = BaseRender('content/xml', var1, var2.. varN) - render.render + Basic use example: + engine = Render('template') + result = engine.render() """ _template = None @@ -109,8 +119,10 @@ class Render(): # def __init__(self, xml_doc, template_args): def __init__(self, template, **kwargs): """ - Builds a ODFRender instance - TODO: document + Builds a Render instance and assign init the internal enviroment. + Params: + template: Either the path to the file, or a file-like object. + If it is a path, the file will be open with mode read 'r'. """ self.template = template