Commits

Anonymous committed f62a8d1

Use jinja2 for docs generation. Patch by POX.

Comments (0)

Files changed (1)

 from docutils.core import publish_parts
 from docutils.writers import html4css1
 
-from jinja import from_string
+from jinja2 import Template
 
 from pygments import highlight
 from pygments.lexers import get_lexer_by_name
         out.append('\n' + heading + '\n' + '-'*len(heading) + '\n')
         for data in lexers:
             out.append(LEXERDOC % data)
-    return ''.join(out)
+    return ''.join(out).decode('utf-8')
 
 def generate_formatter_docs():
     from pygments.formatters import FORMATTERS
 
 
 ''' % (', '.join(data[1]) or 'None', ', '.join(data[2]).replace('*', '\\*') or 'None'))
-    return ''.join(out)
+    return ''.join(out).decode('utf-8')
 
 def generate_filter_docs():
     from pygments.filters import FILTERS
 %s
     :Name: %s
 ''' % (cls.__name__, cls.__doc__, name))
-    return ''.join(out)
+    return ''.join(out).decode('utf-8')
 
 def generate_changelog():
     fn = os.path.abspath(os.path.join(os.path.dirname(__file__), '..',
         else:
             result.append(line.rstrip())
     f.close()
-    return '\n'.join(result)
+    return '\n'.join(result).decode('utf-8')
 
 def generate_authors():
     fn = os.path.abspath(os.path.join(os.path.dirname(__file__), '..',
             except IndexError:
                 continue
             ref_id = reference['refid']
-            text = escape(reference.astext().encode('utf-8'))
+            text = escape(reference.astext())
             toc.append((ref_id, text))
 
         self._generated_toc = [('#%s' % href, caption) for href, caption in toc]
         }
     )
     return {
-        'title':        parts['title'].encode('utf-8'),
-        'body':         parts['body'].encode('utf-8'),
+        'title':        parts['title'],
+        'body':         parts['body'],
         'toc':          parts['toc']
     }
 
 def handle_html(filename, fp, dst):
     now = datetime.now()
     title = os.path.basename(filename)[:-4]
-    content = fp.read()
+    content = fp.read().decode('utf-8')
     c = generate_documentation(content, (lambda x: './%s.html' % x))
     result = file(os.path.join(dst, title + '.html'), 'w')
     c['style'] = STYLESHEET + PYGMENTS_FORMATTER.get_style_defs('.syntax')
     c['generation_date'] = now
     c['file_id'] = title
-    t = from_string(TEMPLATE)
+    t = Template(TEMPLATE)
     result.write(t.render(c).encode('utf-8'))
     result.close()