updated documentation
authorArmin Ronacher <armin.ronacher@active-4.com>
Mon, 9 Jun 2008 16:27:19 +0000 (18:27 +0200)
committerArmin Ronacher <armin.ronacher@active-4.com>
Mon, 9 Jun 2008 16:27:19 +0000 (18:27 +0200)
--HG--
branch : trunk

Makefile
docs/_static/darkmetal.png [new file with mode: 0644]
docs/_static/jinja.js [new file with mode: 0644]
docs/_static/style.css
docs/_static/watermark.png
docs/_static/watermark_blur.png
docs/_templates/layout.html
docs/faq.rst
docs/jinjaext.py
docs/templates.rst
jinja2/utils.py

index 5728fdb089d69086ddef7446d270a60b2faeec77..6622bd10d14235c2f67e9d6928da05622ea9c42b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -14,8 +14,11 @@ test:
 test-coverage:
        @(cd tests; py.test -C $(TESTS))
 
-documentation:
-       @(cd docs; ./generate.py)
+html-documentation:
+       @(cd docs; make html)
+
+pdf-documentation:
+       @(cd docs; make latex; cd _build/latex; make all-pdf)
 
 webpage:
        @(cd ../www; ./generate.py)
diff --git a/docs/_static/darkmetal.png b/docs/_static/darkmetal.png
new file mode 100644 (file)
index 0000000..4000a94
Binary files /dev/null and b/docs/_static/darkmetal.png differ
diff --git a/docs/_static/jinja.js b/docs/_static/jinja.js
new file mode 100644 (file)
index 0000000..1c04218
--- /dev/null
@@ -0,0 +1,26 @@
+$(function() {
+
+  var
+    toc = $('#toc').show(),
+    items = $('#toc > ul').hide();
+
+  $('#toc h3')
+    .click(function() {
+      if (items.is(':visible')) {
+        items.animate({
+          height:     'hide',
+          opacity:    'hide'
+        }, 300, function() {
+          toc.removeClass('expandedtoc');
+        });
+      }
+      else {
+        items.animate({
+          height:     'show',
+          opacity:    'show'
+        }, 400);
+        toc.addClass('expandedtoc');
+      }
+    });
+
+});
index c5894f6b63014202851dbc62c553f9a1d4ad2901..a52436d3fec16a04336a017ca7aa78caa66095cd 100644 (file)
@@ -8,10 +8,11 @@ body {
 }
 
 div.footer {
-    border-top: 1px solid black;
+    border-top: 1px solid #111;
     padding: 8px;
     font-size: 11px;
-    text-align: right;
+    text-align: center;
+    letter-spacing: 0.5px;
 }
 
 div.footer a {
@@ -19,17 +20,20 @@ div.footer a {
 }
 
 div.header {
+    margin: 0 -15px 0 -15px;
     background: url(headerbg.png) repeat-x;
     border-top: 6px solid #D20000;
 }
 
 div.relnav {
-    border-bottom: 1px solid #ACACAC;
+    border-bottom: 1px solid #111;
     background: url(navigation.png);
+    margin: 0 -15px 0 -15px;
     padding: 2px 20px 0 28px;
     line-height: 25px;
     color: #aaa;
     font-size: 12px;
+    text-align: center;
 }
 
 div.relnav a {
@@ -45,8 +49,9 @@ div.relnav a:hover {
 #content {
     background-color: white;
     color: #111;
-    background: url(watermark.png) -110px 0;
-    padding: 0;
+    border-bottom: 1px solid black;
+    background: url(watermark.png) center 0;
+    padding: 0 15px 0 15px;
     margin: 0;
 }
 
@@ -66,7 +71,7 @@ h1.heading:hover {
 }
 
 h1.heading a {
-    background: url(jinjabanner.png) no-repeat 20px 0;
+    background: url(jinjabanner.png) no-repeat center 0;
     display: block;
     width: 100%;
     height: 80px;
@@ -89,12 +94,12 @@ h1.heading span {
 }
 
 #contentwrapper {
-    max-width: 700px;
+    max-width: 680px;
     padding: 0 18px 20px 18px;
-    margin: 0 0 0 10px;
+    margin: 0 auto 0 auto;
     border-right: 1px solid #eee;
     border-left: 1px solid #eee;
-    background: url(watermark_blur.png) -120px -114px;
+    background: url(watermark_blur.png) center -114px;
 }
 
 #contentwrapper h2,
@@ -230,37 +235,9 @@ div.admonition-implementation {
     background: url(implementation.png) no-repeat 10px 40px;
 }
 
-#toc {
-    margin: 20px 0 10px 15px;
-    padding: 10px;
-    width: 200px;
-    float: right;
-    background-color: #f8f8f8;
-    border: 1px solid #ccc;
-    border-right: none;
-}
-
-#toc h3 {
-    font-size: 20px;
-    margin: 0 0 10px 0;
-    padding: 0;
-    color: #444;
-}
-
-#toc ul {
-    margin: 0 0 0 30px;
-    padding: 0;
-}
-
-#toc ul li {
-    padding: 0;
-    margin: 2px 0 2px 0;
-}
-
 a.headerlink {
     color: #B4B4B4!important;
     font-size: 0.8em;
-    margin-left: 8px;
     padding: 0 4px 0 4px;
     text-decoration: none!important;
     visibility: hidden;
@@ -345,3 +322,64 @@ span.highlight {
     background-color: #eee;
     border: 1px solid #ccc;
 }
+
+#toc {
+    margin: 0 -17px 0 -17px;
+    display: none;
+}
+
+#toc h3 {
+    float: right;
+    margin: 5px 5px 0 0;
+    padding: 0;
+    font-size: 12px;
+    color: #777;
+}
+
+#toc h3:hover {
+    color: #333;
+    cursor: pointer;
+}
+
+.expandedtoc {
+    background: #222 url(darkmetal.png);
+    border-bottom: 1px solid #111;
+    outline-bottom: 1px solid #000;
+    padding: 5px;
+}
+
+.expandedtoc h3 {
+    color: #aaa;
+    margin: 0!important;
+}
+
+.expandedtoc h3:hover {
+    color: white!important;
+}
+
+#tod h3:hover {
+    color: white;
+}
+
+#toc a {
+    color: #ddd;
+    text-decoration: none;
+}
+
+#toc a:hover {
+    color: white;
+    text-decoration: underline;
+}
+
+#toc ul {
+    margin: 5px 0 12px 17px;
+    padding: 0 7px 0 7px;
+}
+
+#toc ul ul {
+    margin-bottom: 0;
+}
+
+#toc ul li {
+    margin: 2px 0 0 0;
+}
index cc5eb33dd591f99fcd63ee81b11647eb50062525..d791ea00fabf6921ac61aeb1587720c02b3ec071 100644 (file)
Binary files a/docs/_static/watermark.png and b/docs/_static/watermark.png differ
index 6f686832af47059c15ea78e70ccdb3c571f6bb23..06e799ec6ba345cc047411893d94762708a5913a 100644 (file)
Binary files a/docs/_static/watermark_blur.png and b/docs/_static/watermark_blur.png differ
index c2add7d8624b02c3948cccbdb10b5d73ab2e5e09..7d1a4d5a65b53e965efcc3f35d8e97d287886d40 100644 (file)
@@ -16,6 +16,7 @@
     <script type="text/javascript" src="{{ pathto('_static/jquery.js', 1) }}"></script>
     <script type="text/javascript" src="{{ pathto('_static/interface.js', 1) }}"></script>
     <script type="text/javascript" src="{{ pathto('_static/doctools.js', 1) }}"></script>
+    <script type="text/javascript" src="{{ pathto('_static/jinja.js', 1) }}"></script>
     {%- endif %}
     {%- if use_opensearch and builder != 'htmlhelp' %}
     <link rel="search" type="application/opensearchdescription+xml"
         | <a href="{{ next.link|e }}">{{ next.title }} &raquo;</a>
         {%- endif %}
       </div>
-      {%- if display_toc %}
-      <div id="toc">
-        <h3>Table Of Contents</h3>
-        {{ toc }}
-      </div>
-      {%- endif %}
       <div id="contentwrapper">
+        {%- if display_toc %}
+        <div id="toc">
+          <h3>Table Of Contents</h3>
+          {{ toc }}
+        </div>
+        {%- endif %}
         {% block body %}{% endblock %}
       </div>
     </div>
index 9f7112ef301f78afff6f32b07937a4f620187f99..2042fccf5c10a8d719b557400bf74fd868b875b2 100644 (file)
@@ -128,13 +128,10 @@ instead that one can assign to a variable by using set::
 I don't have the _speedups Module.  Is Jinja slower now?
 --------------------------------------------------------
 
-To achieve a good performance with automatic escaping enabled the escaping
-function is implemented also written in pure C and used if Jinja2 was
-installed with the speedups module which automatically happens if a C
-compiled is available on the system.  It won't affect templates without
-auto escaping much if that feature is not enabled.  You may however
-experience werid tracebacks if you are using a Python installation, for
-more information see the next FAQ item.
+To achieve a good performance with automatic escaping enabled, the escaping
+function is also implemented in pure C and used if Jinja2 was installed with
+the speedups module.  This happens automatically if a C compiler is available
+on the system during installation.
 
 My tracebacks look weird.  What's happening?
 --------------------------------------------
@@ -145,3 +142,14 @@ Jinja2 is unable to provide correct debugging information and the traceback
 may be incomplete.  There is currently no good workaround for Jython or
 the AppEngine as ctypes is unavailable there and it's not possible to use
 the speedups extension.
+
+Why is there no Python 2.3 support?
+-----------------------------------
+
+Python 2.3 is missing a lot of features that are used heavily in Jinja2.  This
+decision was made as with the upcoming Python 2.6 and 3.0 versions it becomes
+harder to maintain the code for older Python versions.  If you really need
+Python 2.3 support you either have to use `Jinja 1`_ or other templating
+engines that still support 2.3.
+
+.. _Jinja 1: http://jinja.pocoo.org/1/
index 8a15d657f787ca2d61e0594e9a874dfb8f688ca0..7dc9baf762afce234a0612d9f21892a1c7b56cf6 100644 (file)
@@ -178,7 +178,6 @@ def jinja_nodes(dirname, arguments, options, content, lineno,
             doc.append('', '')
             doc.append('%s :Node type: :class:`%s`' %
                        (p, node.__base__.__name__), '')
-            # XXX: sphinx bug?  Expr gives a rst warning
         doc.append('', '')
         children = node.__subclasses__()
         children.sort(key=lambda x: x.__name__.lower())
@@ -188,8 +187,30 @@ def jinja_nodes(dirname, arguments, options, content, lineno,
     return parse_rst(state, content_offset, doc)
 
 
+def inject_toc(app, doctree, docname):
+    titleiter = iter(doctree.traverse(nodes.title))
+    try:
+        # skip first title, we are not interested in that one
+        titleiter.next()
+        title = titleiter.next()
+        # and check if there is at least another title
+        titleiter.next()
+    except StopIteration:
+        return
+    tocnode = nodes.section('')
+    tocnode['classes'].append('toc')
+    toctitle = nodes.section('')
+    toctitle['classes'].append('toctitle')
+    toctitle.append(nodes.title(text='Table Of Contents'))
+    tocnode.append(toctitle)
+    tocnode += doctree.document.settings.env.get_toc_for(docname)[0][1]
+    title.parent.insert(title.parent.children.index(title), tocnode)
+
+
 def setup(app):
     app.add_directive('jinjafilters', jinja_filters, 0, (0, 0, 0))
     app.add_directive('jinjatests', jinja_tests, 0, (0, 0, 0))
     app.add_directive('jinjachangelog', jinja_changelog, 0, (0, 0, 0))
     app.add_directive('jinjanodes', jinja_nodes, 0, (0, 0, 0))
+    # uncomment for inline toc.  links are broken unfortunately
+    ##app.connect('doctree-resolved', inject_toc)
index 182ef9468b7b33e1c2e3375499c3060e3ef27b56..11d9978f87e3bf5871091f8fefd200ab86a2f99f 100644 (file)
@@ -218,6 +218,19 @@ precedes it.  For better readability statements that start a block (such as
     # endfor
 
 
+.. admonition:: Note
+
+    Line statements can span multiple lines if there are open parentheses,
+    braces or brackets::
+
+        <ul>
+        # for href, caption in [('index.html', 'Index'),
+                                ('about.html', 'About')]:
+            <li><a href="{{ href }}">{{ caption }}</a></li>
+        # endfor
+        </ul>
+
+
 .. _template-inheritance:
 
 Template Inheritance
index f402704661bf8ff9e3d95e00babe695767a88895..b1c20b699159d0fc377926577f381632b9f700f9 100644 (file)
@@ -293,10 +293,12 @@ class Markup(unicode):
     """
     __slots__ = ()
 
-    def __new__(cls, base=u''):
+    def __new__(cls, base=u'', encoding=None, errors='strict'):
         if hasattr(base, '__html__'):
             base = base.__html__()
-        return unicode.__new__(cls, base)
+        if encoding is None:
+            return unicode.__new__(cls, base)
+        return unicode.__new__(cls, base, encoding, errors)
 
     def __html__(self):
         return self
@@ -434,7 +436,7 @@ class _MarkupEscapeHelper(object):
     __getitem__ = lambda s, x: _MarkupEscapeHelper(s.obj[x])
     __unicode__ = lambda s: unicode(escape(s.obj))
     __str__ = lambda s: str(escape(s.obj))
-    __repr__ = lambda s: str(repr(escape(s.obj)))
+    __repr__ = lambda s: str(escape(repr(s.obj)))
     __int__ = lambda s: int(s.obj)
     __float__ = lambda s: float(s.obj)