Skip to content
Myr

Merge pull request #171 from mgorny/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix jinjaext compatibility with Python 3

authored by Armin Ronacher · committed by Armin Ronacher · parents d4e5438, 67c2480 · Browse files · 1 file+9 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−7 removed

  • other:+9 added−7 removed

1 file+9 added−7 removed

modified:docs/jinjaext.py+9 added-7 removed
6 unmodified lines
78 :copyright: Copyright 2008 by Armin Ronacher.9 :license: BSD.10"""11import collections12import os13import re14import inspect15import jinja2
6 unmodified lines
22from pygments.style import Style23from pygments.token import Keyword, Name, Comment, String, Error, \24 Number, Operator, Generic25from jinja2 import Environment, FileSystemLoader26from jinja2.utils import next272829def parse_rst(state, content_offset, doc):30 node = nodes.section()
80 unmodified lines
111def dump_functions(mapping):112 def directive(dirname, arguments, options, content, lineno,113 content_offset, block_text, state, state_machine):114 reverse_mapping = {}113 for name, func in mapping.iteritems():115 for name, func in mapping.items():116 reverse_mapping.setdefault(func, []).append(name)117 filters = []116 for func, names in reverse_mapping.iteritems():118 for func, names in reverse_mapping.items():119 aliases = sorted(names, key=lambda x: len(x))120 name = aliases.pop()121 filters.append((name, aliases, func))122 filters.sort()
23 unmodified lines
146 sig = ', '.join(node.fields)147 doc.append(p + '.. autoclass:: %s(%s)' % (node.__name__, sig), '')148 if node.abstract:149 members = []148 for key, name in node.__dict__.iteritems():150 for key, name in node.__dict__.items():151 if not key.startswith('_') and \150 not hasattr(node.__base__, key) and callable(name):152 not hasattr(node.__base__, key) and isinstance(name, collections.Callable):153 members.append(key)154 if members:155 members.sort()156 doc.append('%s :members: %s' % (p, ', '.join(members)), '')
13 unmodified lines
170def inject_toc(app, doctree, docname):171 titleiter = iter(doctree.traverse(nodes.title))172 try:173 # skip first title, we are not interested in that one172 titleiter.next()173 title = titleiter.next()174 next(titleiter)175 title = next(titleiter)176 # and check if there is at least another title175 titleiter.next()177 next(titleiter)178 except StopIteration:179 return180 tocnode = nodes.section('')181 tocnode['classes'].append('toc')
14 unmodified lines