From e73e34ebd6c8ac4d04bc249bab73f3ab667c464c Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 20 Sep 2005 03:49:00 +0000 Subject: [PATCH] --- doc/build/components/formatting.myt | 407 +++++++++++++++------------- 1 file changed, 221 insertions(+), 186 deletions(-) diff --git a/doc/build/components/formatting.myt b/doc/build/components/formatting.myt index 3ff0a2c91e..437dd17ebc 100644 --- a/doc/build/components/formatting.myt +++ b/doc/build/components/formatting.myt @@ -1,80 +1,80 @@ <%doc>formatting.myt - library of HTML formatting functions to operate on a TOCElement tree <%global> - import string, re - import highlight + import string, re + import highlight <%def printtocelement> <%doc>prints a TOCElement as a table of contents item and prints its immediate child items - <%args> - item - includefile - bold = False - full = False - children = True - - - - -% if children: - % <%def printsmtocelem> - <%args> - item - includefile - children = False - - <%method printtoc> <%args> - root - includefile - current = None - full = False - children = True + root + includefile + current = None + full = False + children = True % header = False % for i in root.children: -% if i.header: -% if header: - +% if i.header: +% if header: + % -% header = True - <% i.header %>
-
+% header = True + <% i.header %>
+
% - <& printtocelement, item=i, includefile = includefile, bold = (i == current and includefile), full = full, children=children &> + <& printtocelement, item=i, includefile = includefile, bold = (i == current and includefile), full = full, children=children &> % -% if header: -
+% if header: +
% @@ -83,11 +83,11 @@ <%doc>prints the description and contents of a TOC element and recursively prints its child items <%args> - item - indentlevel = 0 - includefile - omitheader = False - root = None + item + indentlevel = 0 + includefile + omitheader = False + root = None % if root is None: root = item @@ -99,49 +99,47 @@
% if not omitheader: - <% item.description %> + <% item.description %> % -
+
<%python> - regexp = re.compile(r"__FORMAT:LINK{(.*?)(?:\|(.*?))?}") - def link(matchobj): - path = matchobj.group(1) - if matchobj.lastindex >= 2: - xtra = matchobj.group(2) - else: - xtra = None - - try: - element = item.lookup(path) - if xtra is not None: - return '%s' % (element.get_link(includefile), xtra, xtra) - else: - return '%s' % (element.get_link(includefile), element.description) - except KeyError: - if xtra is not None: - return '%s' % (xtra) - else: - return '%s' % path - - m.write(regexp.sub(link, item.content)) + regexp = re.compile(r"__FORMAT:LINK{(.*?)(?:\|(.*?))?(?:\@text=(.+?))?}") + def link(matchobj): + path = matchobj.group(1) + text = matchobj.group(3) + xtra = matchobj.group(2) + + try: + element = item.lookup(path) + if xtra is not None: + return '%s' % (element.get_link(includefile), xtra, text or xtra) + else: + return '%s' % (element.get_link(includefile), text or element.description) + except KeyError: + if xtra is not None: + return '%s' % (text or xtra) + else: + return '%s' % text or path + + m.write(regexp.sub(link, item.content)) -
+
-% for i in item.children: - <& printitem, item=i, indentlevel=indentlevel + 1, includefile = includefile, root=root &> +% for i in item.children: + <& printitem, item=i, indentlevel=indentlevel + 1, includefile = includefile, root=root &> % % if root is not None and len(item.children) == 0: - back to section top + back to section top % % if indentlevel == 0: -% if includefile: - <& SELF:pagenav, item=item, includefile=includefile &> -% else: -
+% if includefile: + <& SELF:pagenav, item=item, includefile=includefile &> +% else: +
% # % @@ -151,14 +149,14 @@ <%method pagenav> <%args> - item - includefile + item + includefile
% if not includefile: - Top | + Top | % % if item.previous is not None: @@ -178,19 +176,19 @@ <%method itemlink trim="both"> - <%args> - item - includefile - - <% item.description %> + <%args> + item + includefile + + <% item.description %> <%method paramtable> - - <% m.content() %> -
+ + <% m.content() %> +
<%method param> @@ -198,94 +196,94 @@ name classname type - users = 'all' + users = 'all' default = None - version = None + version = None % if default is None: default = 'None' <&|SELF:fliprow, flip=True &> - - - <% name %> (<% type %>) - -
+ + + <% name %> (<% type %>) + +
% if users is not None: - for users: <% users %>
+ for users: <% users %>
% - default: <% default %>
- used by: <% classname %> + default: <% default %>
+ used by: <% classname %> % if version: -
since version: <% version %> +
since version: <% version %> % -
- +
+ <&|SELF:fliprow, flip=False &> - -

<% m.content() %>

+ +

<% m.content() %>

- + <%method function_doc> - <%args> - name = "" - alt = None - arglist = [] - rettype = None - - <&|SELF:fliprow, flip=True&> - - - <% name %>(<% string.join(map(lambda k: "%s" % k, arglist), ", ")%>) - - - <&|SELF:fliprow, flip=False&> -
<% m.content() %> -% if alt is not None: -

Also called as: <% alt %> + <%args> + name = "" + alt = None + arglist = [] + rettype = None + + <&|SELF:fliprow, flip=True&> + + + <% name %>(<% string.join(map(lambda k: "%s" % k, arglist), ", ")%>) + + + <&|SELF:fliprow, flip=False&> +
<% m.content() %> +% if alt is not None: +

Also called as: <% alt %> % -
- - - +
+ + + <%method member_doc> - <%args> - name = "" - type = None - - <&|SELF:fliprow, flip=True&> - - - <% name %> - - - <&|SELF:fliprow, flip=False&> -
<% m.content() %> -
- - - + <%args> + name = "" + type = None + + <&|SELF:fliprow, flip=True&> + + + <% name %> + + + <&|SELF:fliprow, flip=False&> +
<% m.content() %> +
+ + + <%method fliprow trim="both"> - <%args>flip=True - <%python> - flipper = m.get_attribute("formatflipper") - if flipper is None: - flipper = Value("light") - m.set_attribute("formatflipper", flipper) - - + <%args>flip=True + <%python> + flipper = m.get_attribute("formatflipper") + if flipper is None: + flipper = Value("light") + m.set_attribute("formatflipper", flipper) + + % if flip: flipper({"light":"dark", "dark": "light"}[flipper()]) - <% m.content() %> + <% m.content() %> @@ -296,57 +294,94 @@ <%method code autoflush=False> <%args> - title = None - syntaxtype = 'python' + title = None + syntaxtype = 'python' <%init> - def fix_indent(f): - f =string.expandtabs(f, 4) - g = '' - lines = string.split(f, "\n") - whitespace = None - for line in lines: - if whitespace is None: - match = re.match(r"^([ ]+)", line) - if match is not None: - whitespace = match.group(1) + def fix_indent(f): + f =string.expandtabs(f, 4) + g = '' + lines = string.split(f, "\n") + whitespace = None + for line in lines: + if whitespace is None: + match = re.match(r"^([ ]+)", line) + if match is not None: + whitespace = match.group(1) - if whitespace is not None: - line = re.sub(r"^%s" % whitespace, "", line) + if whitespace is not None: + line = re.sub(r"^%s" % whitespace, "", line) - if whitespace is not None or re.search(r"\w", line) is not None: - g += (line + "\n") + if whitespace is not None or re.search(r"\w", line) is not None: + g += (line + "\n") - return g.rstrip() + return g.rstrip() - content = highlight.highlight(fix_indent(m.content()), syntaxtype = syntaxtype) + content = highlight.highlight(fix_indent(m.content()), syntaxtype = syntaxtype)
% if title is not None: -
<% title %>
+
<% title %>
%
<% content %>
<%method link trim="both"> - <%args> - path = None - param = None - method = None - member = None - - <%init> - if path is None: - path = m.comp('doclib.myt:current').path - - extra = (param or method or member) - -__FORMAT:LINK{<%path%><% extra and "|" + extra or "" %>} + <%args> + path = None + param = None + method = None + member = None + text = None + + <%init> + if path is None: + path = m.comp('doclib.myt:current').path + + extra = (param or method or member) + +__FORMAT:LINK{<%path%><% extra and "|" + extra or "" %><% text and "@text=" + text or "" %>} +<%method uniqueblock> +<%args> + blockname + uniquename + + +<%init> + context = m.attributes.setdefault('ubcontext', {}) + try: + writer = context[blockname] + except KeyError: + context[blockname] = uniquename + writer = uniquename + + +% if writer == uniquename: + <% m.content() %> +% + +#<&| /components/uniqueblock.mhtml, blockname=>'popboxscript', uniquename=>$name &> +# +# -- 2.47.2