From 9ddca27edcbc05e9e5483b2639d2478cf51001a3 Mon Sep 17 00:00:00 2001 From: guido Date: Thu, 1 Feb 2007 21:10:48 +0100 Subject: [PATCH] [svn r37765] Was still getting filenames for source files from code objects, so adding more defensiveness, and made that the 'capture' object is passed over to the builder instances (to help debugging, currently not used). --HG-- branch : trunk --- py/apigen/apigen.py | 5 +++-- py/apigen/htmlgen.py | 15 ++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/py/apigen/apigen.py b/py/apigen/apigen.py index 70b9662a6..1dc5f5441 100644 --- a/py/apigen/apigen.py +++ b/py/apigen/apigen.py @@ -29,8 +29,9 @@ def build(pkgdir, dsa, capture): all_names = dsa._get_names(filter=lambda x, y: True) namespace_tree = htmlgen.create_namespace_tree(all_names) - apb = htmlgen.ApiPageBuilder(targetdir, l, dsa, pkgdir, namespace_tree) - spb = htmlgen.SourcePageBuilder(targetdir, l, pkgdir) + apb = htmlgen.ApiPageBuilder(targetdir, l, dsa, pkgdir, namespace_tree, + capture) + spb = htmlgen.SourcePageBuilder(targetdir, l, pkgdir, capture) capture.err.writeorg('preparing namespace pages\n') ns_data = apb.prepare_namespace_pages() diff --git a/py/apigen/htmlgen.py b/py/apigen/htmlgen.py index b77b77a90..866084dc2 100644 --- a/py/apigen/htmlgen.py +++ b/py/apigen/htmlgen.py @@ -205,10 +205,11 @@ class AbstractPageBuilder(object): class SourcePageBuilder(AbstractPageBuilder): """ builds the html for a source docs page """ - def __init__(self, base, linker, projroot): + def __init__(self, base, linker, projroot, capture=None): self.base = base self.linker = linker self.projroot = projroot + self.capture = capture def build_navigation(self, fspath): nav = H.Navigation() @@ -348,14 +349,16 @@ def enumerate_and_color(codelines, firstlineno, enc): class ApiPageBuilder(AbstractPageBuilder): """ builds the html for an api docs page """ - def __init__(self, base, linker, dsa, projroot, namespace_tree): + def __init__(self, base, linker, dsa, projroot, namespace_tree, + capture=None): self.base = base self.linker = linker self.dsa = dsa self.projroot = projroot self.projpath = py.path.local(projroot) self.namespace_tree = namespace_tree - + self.capture = capture + def build_callable_view(self, dotted_name): """ build the html for a class method """ # XXX we may want to have seperate @@ -728,7 +731,8 @@ class ApiPageBuilder(AbstractPageBuilder): # skip py.code.Source objects and source files outside of the # package is_code_source = self._reg_source.match(sourcefile) - if (not is_code_source and self.is_in_pkg(sourcefile)): + if (not is_code_source and self.is_in_pkg(sourcefile) and + py.path.local(sourcefile).check()): enc = source_html.get_module_encoding(sourcefile) href = self.linker.get_lazyhref(sourcefile) sourcelink = H.a(linktext, href=href) @@ -737,7 +741,8 @@ class ApiPageBuilder(AbstractPageBuilder): sourcelink = H.div(linktext) colored = enumerate_and_color(mangled, frame.firstlineno, enc) else: - sourcelink = H.div('source unknown') + sourcelink = H.div('source unknown (%s)' % (sourcefile,)) + colored = mangled[:] tbdiv.append(sourcelink) tbdiv.append(H.div(class_='code', *colored)) return tbdiv