[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
This commit is contained in:
guido 2007-02-01 21:10:48 +01:00
parent a2359e0554
commit 9ddca27edc
2 changed files with 13 additions and 7 deletions

View File

@ -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()

View File

@ -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