From: Armin Ronacher Date: Tue, 13 Mar 2007 21:29:01 +0000 (+0100) Subject: [svn] jinja webpage update. (one dirty script more) X-Git-Tag: 2.0rc1~442 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9356b7b1b4502e430c8eea289efb0d6b76aa756b;p=jinja2.git [svn] jinja webpage update. (one dirty script more) --HG-- branch : trunk --- diff --git a/docs/generate.py b/docs/generate.py index 0c155c0..a6dbb4e 100755 --- a/docs/generate.py +++ b/docs/generate.py @@ -109,7 +109,7 @@ LIST_OF_FILTERS = generate_list_of_filters() LIST_OF_TESTS = generate_list_of_tests() LIST_OF_LOADERS = generate_list_of_loaders() -TEMPLATE = e.from_string('''\ +FULL_TEMPLATE = e.from_string('''\ @@ -156,6 +156,13 @@ TEMPLATE = e.from_string('''\ \ ''') +PREPROC_TEMPLATE = e.from_string('''\ +{{ title }} +{% for key, value in toc %}
  • {{ value }}
  • {% endfor %} +{{ body }}\ +''') + def pygments_directive(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): try: @@ -238,7 +245,7 @@ def generate_documentation(data, link_style): } -def handle_file(filename, fp, dst): +def handle_file(filename, fp, dst, preproc): now = datetime.now() title = os.path.basename(filename)[:-4] content = fp.read() @@ -248,11 +255,15 @@ def handle_file(filename, fp, dst): c['style'] = PYGMENTS_FORMATTER.get_style_defs('.syntax') c['generation_date'] = now c['file_id'] = title - result.write(TEMPLATE.render(c).encode('utf-8')) + if preproc: + tmpl = PREPROC_TEMPLATE + else: + tmpl = FULL_TEMPLATE + result.write(tmpl.render(c).encode('utf-8')) result.close() -def run(dst, sources=()): +def run(dst, preproc, sources=(), handle_file=handle_file): path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src')) if not sources: sources = [os.path.join(path, fn) for fn in os.listdir(path)] @@ -262,13 +273,13 @@ def run(dst, sources=()): print 'Processing %s' % fn f = open(fn) try: - handle_file(fn, f, dst) + handle_file(fn, f, dst, preproc) finally: f.close() -def main(dst='build/', *sources): - return run(os.path.realpath(dst), sources) +def main(dst='build/', preproc=False, *sources): + run(os.path.realpath(dst), str(preproc).lower() == 'true', sources) if __name__ == '__main__': diff --git a/jinja/datastructure.py b/jinja/datastructure.py index 3b13ae0..c15519f 100644 --- a/jinja/datastructure.py +++ b/jinja/datastructure.py @@ -33,6 +33,10 @@ class UndefinedType(object): raise TypeError('cannot create %r instances' % self.__class__.__name__) + def __add__(self, other): + return other + __sub__ = __mul__ = __div__ = __add__ + def __getitem__(self, arg): return self diff --git a/jinja/exceptions.py b/jinja/exceptions.py index c13725e..0873281 100644 --- a/jinja/exceptions.py +++ b/jinja/exceptions.py @@ -47,6 +47,15 @@ class TestNotFound(KeyError, TemplateError): KeyError.__init__(self, message) +class TestArgumentError(TypeError, TemplateError): + """ + An argument passed to a test function was invalid. + """ + + def __init__(self, message): + TypeError.__init__(self, message) + + class TemplateNotFound(IOError, TemplateError): """ Raised if a template does not exist. diff --git a/jinja/translators/python.py b/jinja/translators/python.py index a71a4f5..4caddd9 100644 --- a/jinja/translators/python.py +++ b/jinja/translators/python.py @@ -232,6 +232,14 @@ class PythonTranslator(Translator): raise AssertionError('unhandled node %r' % node.__class__) return out + def reset(self): + self.indention = 0 + self.last_cycle_id = 0 + + def translate(self): + self.reset() + return self.handle_node(self.node) + # -- jinja nodes def handle_template(self, node): @@ -851,11 +859,3 @@ class PythonTranslator(Translator): for n in node.nodes: args.append(self.handle_node(n)) return '[%s]' % ':'.join(args) - - def reset(self): - self.indention = 0 - self.last_cycle_id = 0 - - def translate(self): - self.reset() - return self.handle_node(self.node) diff --git a/www/documentation.html b/www/documentation.html index 2edeb79..d674dfe 100644 --- a/www/documentation.html +++ b/www/documentation.html @@ -13,21 +13,21 @@

    Jinja

    +
  • Index
  • +
  • FAQ
  • +
  • Documentation
  • +
  • Download
  • +

    Documentation

    - You can browse the documentation either online or download it: + Currently Jinja 1 in still under heavy development and we have neither + released a final version nor do we provide a documentation you can download. + However you can browse the documentation of the current SVN version online:

    +

    browse online documentation

    -

    - show template source -

    +
  • Index
  • +
  • FAQ
  • +
  • Documentation
  • +
  • Download
  • +

    Download

    @@ -41,9 +41,6 @@ here.

    -

    - show template source -

    +
  • Index
  • +
  • FAQ
  • +
  • Documentation
  • +
  • Download
  • +

    Frequently Asked Questions

    @@ -61,9 +61,6 @@ you probably want to check out Jinja.

    -

    - show template source -

    +
  • Index
  • +
  • FAQ
  • +
  • Documentation
  • +
  • Download
  • +

    Jinja Templates

    @@ -81,9 +81,6 @@ You can then use this block by calling it: no problem to use ASP/PHP/Ruby syntax, html comments for blocks etc.
    -

    - show template source -

    +
  • Index
  • +
  • FAQ
  • +
  • Documentation
  • +
  • Download
  • +
    -

    - show template source -

    <% if trace %> @@ -43,9 +40,6 @@
    <% block content %><% endblock %>
    -

    - show template source -