From e15da6e204a63b673e8a2d7a533b137c3019cce3 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 7 Jul 2005 05:24:24 +0000 Subject: [PATCH] docs --- doc/build/components/doclib.myt | 184 ++++++++++++++++++++++++++++++++ doc/syntaxhighlight.css | 54 ++++++++++ 2 files changed, 238 insertions(+) create mode 100644 doc/build/components/doclib.myt create mode 100644 doc/syntaxhighlight.css diff --git a/doc/build/components/doclib.myt b/doc/build/components/doclib.myt new file mode 100644 index 0000000000..cbbd7df466 --- /dev/null +++ b/doc/build/components/doclib.myt @@ -0,0 +1,184 @@ + +<%python scope="global"> +import sys, string, re + +# datastructure that will store the whole contents of the documentation +class TOCElement: + def __init__(self, filename, name, description, parent = None, ext = None, header = None, last_updated = 0): + self.filename = filename + self.name = name + self.parent = parent + self.path = self._create_path() + self.header = header + + if self.parent is not None: + self.root = parent.root + self.root.pathlookup[self.path] = self + + if self.parent.filename != self.filename: + self.root.filelookup[self.filename] = self + self.isTop = True + else: + self.root = self + self.pathlookup = {} + self.pathlookup[''] = self + self.filelookup = {} + self.filelookup[filename] = self + + if ext is not None: + self.ext = ext + else: + self.ext = self.root.ext + + self.last_updated = last_updated + self.description = description + self.content = None + self.previous = None + self.next = None + self.children = [] + if parent: + if len(parent.children): + self.previous = parent.children[-1] + parent.children[-1].next = self + parent.children.append(self) + if last_updated > parent.last_updated: + parent.last_updated = self.last_updated + + def get_file(self, name): + name = re.sub("\.\w+$", "", name) + return self.root.filelookup[name] + + def lookup(self, path): + return self.root.pathlookup[path] + + def get_link(self, includefile = True, anchor = True): + if includefile: + if anchor: + return "%s%s#%s" % (self.filename, self.ext, self.path) + else: + return "%s%s" % (self.filename, self.ext) + else: + if anchor: + return "#" + self.path + else: + return "" + + + def _create_path(self): + elem = self + tokens = [] + while elem.parent is not None: + tokens.insert(0, elem.name) + elem = elem.parent + path = string.join(tokens, '_') + return path + + + + + +<%python scope="request"> + current = Value() + filename = Value() + + + +<%args scope="request"> + paged = 'yes' + + +<%python scope="init"> + + try: + a = r + isdynamic = True + ext = ".myt" + except: + isdynamic = False + ext = ".html" + + request_comp = m.request_comp() + + if isdynamic and not m.interpreter.attributes.get('docs_static_cache', False): + page_cache = True + else: + page_cache = False + + # for dynamic page, cache the output of the final page + + if page_cache: + if m.cache_self(key="doc_%s" % paged, component = request_comp): + return + + list_comp = m.fetch_next() + files = request_comp.attributes['files'] + title = request_comp.attributes.setdefault('title', "Documentation") + version = request_comp.attributes['version'] + wrapper = request_comp.attributes['wrapper'] + index = request_comp.attributes['index'] + onepage = request_comp.attributes['onepage'] + + + + def buildtoc(): + root = TOCElement("", "root", "root element", ext = ext) + current.assign(root) + + for file in files: + filename.assign(file) + comp = m.fetch_component(file + ".myt") + + main = m.scomp(comp) + + return root + + if not page_cache: + # non-dynamic (i.e. command-line) page, cache the datastructure so successive + # pages are fast (disables auto-recompiling) + cache = m.get_cache(list_comp) + + toc = cache.get_value('toc', createfunc = buildtoc) + + else: + toc = buildtoc() + + last_updated = toc.last_updated + m.comp(wrapper, isdynamic=isdynamic, ext = ext, toc = toc, comp = request_comp, onepage = onepage, paged = paged, title = title, version = version, index=index, last_updated = last_updated) + + + +<%method title> +<% m.request_comp().get_attribute('title', inherit = True) or "Documentation" %> + + +<%method item> + <%doc>stores an item in the table of contents + <%args> + # name should be a URL friendly name used for hyperlinking the section + name + + # description is the heading for the item + description + + escapedesc = False + + header = None + + <%python scope="init"> + if escapedesc: + description = m.apply_escapes(description, ['h']) + + current(TOCElement(filename(), name, description, current(), header = header, last_updated = m.caller.component_source.last_modified)) + current().content = m.content() + current(current().parent) + + + +<%method current> +<%init>return current() + + + + + + diff --git a/doc/syntaxhighlight.css b/doc/syntaxhighlight.css new file mode 100644 index 0000000000..8529ebb5fc --- /dev/null +++ b/doc/syntaxhighlight.css @@ -0,0 +1,54 @@ + +.substitution, .compcall { + color: #DF2020; +} + + +.controlline { + color: #10109E; +} + +.doctag_text, .python_comment, .doctag { + color: #109010; +} + +.argstag_text { + color: #10109E; +} + +.blocktag, .python_keyword, .deftag, .argstag { + #color: #1010FF; + color: #0908CE; +} + +.blocktag_text { + color: #10109E; +} + +.python_literal, .python_number { + color: #804049; +} + +.text { + color: #807079; +} + +.python_operator { + color: #EF0005; +} + +.python_enclosure { + color: #0000FF; +} + +.compname { + color: #272767; +} + +.python_name, name { + color: #070707; +} + + + + -- 2.47.2