summaryrefslogtreecommitdiff
path: root/doc/build/lib
diff options
context:
space:
mode:
Diffstat (limited to 'doc/build/lib')
-rw-r--r--doc/build/lib/docstring.py7
-rw-r--r--doc/build/lib/documentgen.py44
-rw-r--r--doc/build/lib/toc.py70
3 files changed, 75 insertions, 46 deletions
diff --git a/doc/build/lib/docstring.py b/doc/build/lib/docstring.py
index b6879c7ad..b4ddcff4e 100644
--- a/doc/build/lib/docstring.py
+++ b/doc/build/lib/docstring.py
@@ -1,6 +1,8 @@
-import re, types, string, inspect
+"""
+defines a pickleable, recursive "generated python documentation" datastructure.
+"""
-"""sucks a module and its contents into a simple documentation object, suitable for pickling"""
+import re, types, string, inspect
allobjects = {}
@@ -9,6 +11,7 @@ class AbstractDoc(object):
allobjects[id(obj)] = self
self.id = id(obj)
self.allobjects = allobjects
+ self.toc_path = None
class ObjectDoc(AbstractDoc):
def __init__(self, obj, functions=None, classes=None):
diff --git a/doc/build/lib/documentgen.py b/doc/build/lib/documentgen.py
deleted file mode 100644
index 7e1783d1d..000000000
--- a/doc/build/lib/documentgen.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import sys, re, os
-import myghty.interp
-import myghty.exception as exception
-
-# document generation library
-
-def genall(comps, component_root, output_dir):
- interp = myghty.interp.Interpreter( component_root = component_root)
-
- try:
- for comp in comps:
- gendoc(comp, interp, output_dir = output_dir)
- except exception.Error, e:
- sys.stderr.write(e.textformat())
-
-
-def gendoc(doccomp, interp, output_dir):
- component = interp.load(doccomp)
- files = component.get_attribute('files')
- index = component.get_attribute('index')
- onepage = component.get_attribute('onepage')
-
- genfile(index + ".myt", interp, output_dir)
-
- for file in files:
- file += '.myt'
- genfile(file, interp, output_dir)
-
- genfile(index + ".myt", interp, output_dir, outfile = onepage + ".html", args = {'paged':'no'})
-
-
-
-def genfile(file, interp, output_dir, outfile = None, args = {}):
- if outfile is None:
- outfile = re.sub(r"\..+$", "%s" % '.html', file)
-
- outfile = os.path.join(output_dir, outfile)
- print "%s -> %s" % (file, outfile)
- outbuf = open(outfile, "w")
-
- interp.execute(file, out_buffer = outbuf, request_args = args, raise_error = True)
-
- outbuf.close()
-
diff --git a/doc/build/lib/toc.py b/doc/build/lib/toc.py
new file mode 100644
index 000000000..ebf7e9547
--- /dev/null
+++ b/doc/build/lib/toc.py
@@ -0,0 +1,70 @@
+"""
+defines a pickleable, recursive "table of contents" datastructure.
+
+TOCElements define a name, a description, and also a uniquely-identifying "path" which is
+used to generate hyperlinks between document sections.
+"""
+import time
+
+toc_by_file = {}
+toc_by_path = {}
+
+class TOCElement(object):
+ def __init__(self, filename, name, description, parent=None, version=None, last_updated=None, doctitle=None, **kwargs):
+ self.filename = filename
+ self.name = name
+ self.description = description
+ self.parent = parent
+ self.content = None
+ self.toc_by_path = toc_by_path
+ self.toc_by_file = toc_by_file
+ self.last_updated = time.time()
+ self.version = version
+ self.doctitle = doctitle
+ (self.path, self.depth) = self._create_path()
+ #print "NEW TOC:", self.path
+ for key, value in kwargs.iteritems():
+ setattr(self, key, value)
+
+ toc_by_path[self.path] = self
+
+ self.is_top = (self.parent is not None and self.parent.filename != self.filename) or self.parent is None
+ if self.is_top:
+ toc_by_file[self.filename] = self
+
+ self.root = self.parent or self
+
+ 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)
+
+ def get_page_root(self):
+ return self.toc_by_file[self.filename]
+
+ def get_by_path(self, path):
+ return self.toc_by_path.get(path)
+
+ def get_by_file(self, filename):
+ return self.toc_by_file[filename]
+
+ def get_link(self, extension='html', anchor=True):
+ if anchor:
+ return "%s.%s#%s" % (self.filename, extension, self.path)
+ else:
+ return "%s.%s" % (self.filename, extension)
+
+ def _create_path(self):
+ elem = self
+ tokens = []
+ depth = 0
+ while elem.parent is not None:
+ tokens.insert(0, elem.name)
+ elem = elem.parent
+ depth +=1
+ return ('_'.join(tokens), depth)