diff examples/doctest.txt @ 90:26b9c3bba04e

make the api for substitute() variables, output
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 10 Jan 2011 21:33:03 -0800
parents 712a6d358083
children 672d2d3ee322
line wrap: on
line diff
--- a/examples/doctest.txt	Mon Jan 10 19:58:21 2011 -0800
+++ b/examples/doctest.txt	Mon Jan 10 21:33:03 2011 -0800
@@ -17,14 +17,14 @@
     >>> template = makeitso.PolyTemplate([example], interactive=False)
     >>> template.missing()
     set(['name'])
-    >>> template.substitute(output=None, name='foo')
+    >>> template.substitute(dict(name='foo'))
     Hello foo
     
 Substitute to a buffer::
 
     >>> buffer = StringIO()
     >>> template = makeitso.PolyTemplate([example], interactive=False)
-    >>> template.substitute(output=buffer, name='bar')
+    >>> template.substitute(dict(name='bar'), output=buffer)
     >>> buffer.getvalue().strip()
     'Hello bar'
 
@@ -32,7 +32,7 @@
 
     >>> buffer = tempfile.mktemp()
     >>> template = makeitso.PolyTemplate([example], interactive=False)
-    >>> template.substitute(buffer, name='fleem')
+    >>> template.substitute(dict(name='fleem'), buffer)
     >>> file(buffer).read().strip()
     'Hello fleem'
     >>> os.remove(buffer)
@@ -44,7 +44,7 @@
     >>> template = makeitso.PolyTemplate([exampledir], interactive=False)
     >>> sorted(template.missing())
     ['bar', 'foo', 'subdir']
-    >>> template.substitute(tempdir, foo='It', bar='life', subdir='mysubdir')
+    >>> template.substitute(dict(foo='It', bar='life', subdir='mysubdir'), output=tempdir)
     >>> sorted(os.listdir(tempdir))
     ['foo.txt', 'mysubdir']
     >>> file(os.path.join(tempdir, 'foo.txt')).read().strip()
@@ -66,7 +66,7 @@
 
     >>> variables = dict([(i, i.title()) for i in variables])
     >>> try:
-    ...    template.substitute(output=None, **variables)
+    ...    template.substitute(variables)
     ... except AssertionError, e:
     ...    pass
     >>> e
@@ -75,7 +75,7 @@
 Provide an output::
 
     >>> template = makeitso.PolyTemplate([example, exampledir], interactive=False)
-    >>> template.substitute(tempdir, **variables)
+    >>> template.substitute(variables, tempdir)
     >>> sorted(os.listdir(tempdir))
     ['Subdir', 'example.txt', 'foo.txt']
     >>> shutil.rmtree(tempdir)
@@ -89,7 +89,7 @@
     ...    vars = [Variable(name='name', default='bar')]
     >>> buffer = tempfile.mktemp()
     >>> apitemplate = MyTemplate(interactive=False)
-    >>> apitemplate.substitute(buffer)
+    >>> apitemplate.substitute({}, buffer)
     >>> file(buffer).read().strip()
     'Hello bar'
     >>> os.remove(buffer)
@@ -102,7 +102,7 @@
     >>> f.close()
     >>> os.chmod(buffer, 0755)
     >>> uritemplate = makeitso.URITemplate(example, interactive=False)
-    >>> uritemplate.substitute(buffer, name='bar')
+    >>> uritemplate.substitute(dict(name='bar'), buffer)
     >>> ('%o' % os.stat(buffer).st_mode).endswith('755')
     True
     >>> os.remove(buffer)