diff --git a/doc/build/read_markdown.py b/doc/build/read_markdown.py index cbd1a8c7f8157f56ef487febce150426e8440eec..d2bec0bd74f4704341acf5e244e7cb5908b85211 100644 --- a/doc/build/read_markdown.py +++ b/doc/build/read_markdown.py @@ -74,7 +74,7 @@ def create_toc(filename, tree, tocroot): level[0] = taglevel - tag = et.Element("MAKO:self.formatting.section", path=repr(current[0].path), toc="toc") + tag = et.Element("MAKO:formatting.section", path=repr(current[0].path), toc="toc") tag.text = (node.tail or "") + '\n' tag.tail = '\n' tag[:] = content @@ -114,9 +114,9 @@ def process_rel_href(tree): (bold, path) = m.group(1,2) text = a.text if text == path: - tag = et.Element("MAKO:self.nav.toclink", path=repr(path), toc="toc", extension="extension") + tag = et.Element("MAKO:nav.toclink", path=repr(path), toc="toc", extension="extension") else: - tag = et.Element("MAKO:self.nav.toclink", path=repr(path), description=repr(text), toc="toc", extension="extension") + tag = et.Element("MAKO:nav.toclink", path=repr(path), description=repr(text), toc="toc", extension="extension") a_parent = parent[a] if bold: bold = et.Element('strong') @@ -131,7 +131,7 @@ def replace_pre_with_mako(tree): parents = get_parent_map(tree) for precode in tree.findall('.//pre/code'): - tag = et.Element("MAKO:self.formatting.code") + tag = et.Element("MAKO:formatting.code") tag.text = precode.text [tag.append(x) for x in precode] pre = parents[precode] @@ -160,6 +160,8 @@ def get_parent_map(tree): def header(toc, title, filename): return """ <%%inherit file="content_layout.html"/> +<%%namespace name="formatting" file="formatting.html"/> +<%%namespace name="nav" file="nav.html"/> <%%def name="title">%s - %s</%%def> <%%! filename = '%s' diff --git a/doc/build/templates/base.html b/doc/build/templates/base.html index 3f45059598c6f3236be4a451af123b7540618493..9758956a4b706a8910bd13e94ae875146d494c08 100644 --- a/doc/build/templates/base.html +++ b/doc/build/templates/base.html @@ -2,7 +2,13 @@ from mako.ext.autohandler import autohandler %> <%inherit file="${autohandler(template, context)}"/> -<%page cached="True" cache_key="${self.filename}"/> +<%page cached="False" cache_key="${self.filename}"/> + +<%def name="style"> + ${parent.style()} + <link rel="stylesheet" href="docs.css"></link> +</%def> + # base.html - common to all documentation pages. intentionally separate # from autohandler, which can be swapped out for a different one <% @@ -16,24 +22,16 @@ toc = pickle.load(file(filename)) version = toc.version last_updated = toc.last_updated -%> - -<%namespace name="formatting" file="formatting.html" inheritable="True"/> -<%namespace name="tocns" file="toc.html" inheritable="True"/> -<%namespace name="nav" file="nav.html" inheritable="True"/> -<div style="position:absolute;left:0px;top:0px;"><a name="top"></a> </div> - -<div class="doccontainer"> +%> -<div class="docheader"> +<div id="topanchor"><a name="top"></a> </div> <h1>${toc.root.doctitle}</h1> -<div class="">Version: ${version} Last Updated: ${time.strftime('%x %X', time.localtime(last_updated))}</div> -</div> + +<div class="versionheader">Version: ${version} Last Updated: ${time.strftime('%x %X', time.localtime(last_updated))}</div> ${next.body(toc=toc)} -</div> diff --git a/doc/build/templates/formatting.html b/doc/build/templates/formatting.html index d2de584c3e40b588993779ba8daabdb1824fe63f..b1bdadb87c2a8738ad831a08c80fd3f65ef26a8c 100644 --- a/doc/build/templates/formatting.html +++ b/doc/build/templates/formatting.html @@ -22,7 +22,7 @@ %> <A name="${item.path}"></a> - <div class="subsection" style="margin-left:${repr(item.depth * 10)}px;"> + <div class="section" style="margin-left:${repr(item.depth * 10)}px;"> <% content = capture(caller.body) re2 = re.compile(r"'''PYESC(.+?)PYESC'''", re.S) @@ -31,17 +31,18 @@ % if item.depth > 1: <h3>${description or item.description}</h3> % endif - <div class="sectiontext"> + ${content} - </div> + % if item.depth > 1: % if (item.next and item.next.depth >= item.depth): - <a href="#${ item.get_page_root().path }" class="toclink">back to section top</a> + <a href="#${ item.get_page_root().path }">back to section top</a> % endif % else: - <a href="#${ item.get_page_root().path }" class="toclink">back to section top</a> + <a href="#${ item.get_page_root().path }">back to section top</a> ${nav.pagenav(item=item)} % endif + </div> </%def> @@ -63,7 +64,7 @@ <div class="${ use_sliders and "sliding_code" or "code" }"> % if title is not None: - <div class="codetitle">${ title }</div> + ${title} % endif ${ content } </div> diff --git a/doc/build/templates/nav.html b/doc/build/templates/nav.html index ea14469dad95ca2b4f216c0660b389574c29cbca..c4888b898392c7a44892a4057cd86fa8d0d224f5 100644 --- a/doc/build/templates/nav.html +++ b/doc/build/templates/nav.html @@ -28,50 +28,33 @@ </%def> <%def name="topnav(item, extension='html')"> - <div class="topnav"> - <div class="topnavsectionlink"> + <a href="index.${ extension }">Table of Contents</a> - <a href="index.${ extension }">Table of Contents</a> + <div class="prevnext"> + % if item.previous is not None: + Previous: ${itemlink(item=item.previous, anchor=False)} + % endif - <div class="prevnext"> - % if item.previous is not None: - Previous: ${itemlink(item=item.previous, anchor=False)} - % endif + % if item.previous is not None and item.next is not None: + | + % endif - % if item.previous is not None and item.next is not None: - | - % endif - - % if item.next is not None: - Next: ${itemlink(item=item.next, anchor=False)} - % endif - - </div> - </div> - - <div class="topnavmain"> - <div class="topnavheader">${ item.description }</div> - <div class="topnavitems"> - ${tocns.printtoc(root=item, current=None, full=True, anchor_toplevel=True)} - </div> - </div> + % if item.next is not None: + Next: ${itemlink(item=item.next, anchor=False)} + % endif </div> + ${ item.description } + ${tocns.printtoc(root=item, current=None, full=True, anchor_toplevel=True)} </%def> <%def name="pagenav(item)"> - <div class="sectionnavblock"> - <div class="sectionnav"> - - % if item.previous is not None: - Previous: ${itemlink(item=item.previous)} - % endif - - % if item.next is not None: - ${item.previous is not None and "|" or ""} - Next: ${itemlink(item=item.next)} - % endif + % if item.previous is not None: + Previous: ${itemlink(item=item.previous)} + % endif - </div> - </div> + % if item.next is not None: + ${item.previous is not None and "|" or ""} + Next: ${itemlink(item=item.next)} + % endif </%def> diff --git a/doc/docs.css b/doc/docs.css new file mode 100644 index 0000000000000000000000000000000000000000..2157d39e046417d41c813c6961f1905559774717 --- /dev/null +++ b/doc/docs.css @@ -0,0 +1 @@ +#topanchor {position:absolute;left:0px;top:0px;width:0px;height:0px;} \ No newline at end of file diff --git a/lib/mako/codegen.py b/lib/mako/codegen.py index 9cb6b7f6a90cbdea46df202881aff6024fa0af99..480c620d117a0b1ac827a1b230f86399f45d0efa 100644 --- a/lib/mako/codegen.py +++ b/lib/mako/codegen.py @@ -317,6 +317,7 @@ class _GenerateRenderMethod(object): self.printer.writeline("return %s" % s) else: self.printer.writeline("context.write(%s)" % s) + self.printer.writeline("return ''") self.printer.writeline(None) def write_cache_decorator(self, node_or_pagetag, name, buffered, identifiers): @@ -402,7 +403,6 @@ class _GenerateRenderMethod(object): pass def visitCallTag(self, node): - self.write_source_comment(node) self.printer.writeline("def ccall(context):") export = ['body'] identifiers = self.identifiers.branch(node) @@ -436,7 +436,9 @@ class _GenerateRenderMethod(object): "__cl = context.locals_({'caller':context.caller_stack[-1]})", # push on global "caller" to be picked up by the next ccall "context.caller_stack.append(runtime.Namespace('caller', __cl, callables=ccall(__cl)))", - "try:", + "try:") + self.write_source_comment(node) + self.printer.writelines( "context.write(unicode(%s))" % node.attributes['expr'], "finally:", # pop it off diff --git a/lib/mako/exceptions.py b/lib/mako/exceptions.py index bb96ecc1ce9ff5c4438509fb516609cc71b1f016..15e77d33e04ac545d01de3cfdcce84d68212a634 100644 --- a/lib/mako/exceptions.py +++ b/lib/mako/exceptions.py @@ -130,9 +130,11 @@ class RichTraceback(object): template_line = None new_trcback.append((filename, lineno, function, line, template_filename, template_ln, template_line, template_source)) if not self.source: - if new_trcback[-1][5]: - self.source = template_source - self.lineno = template_ln + for l in range(len(new_trcback)-1, 0, -1): + if new_trcback[l][5]: + self.source = new_trcback[l][7] + self.lineno = new_trcback[l][5] + break else: self.source = file(new_trcback[-1][0]).read() self.lineno = new_trcback[-1][1]