diff --git a/py/apigen/apigen.py b/py/apigen/apigen.py index 7ecab70d7..b7ee295ae 100644 --- a/py/apigen/apigen.py +++ b/py/apigen/apigen.py @@ -29,7 +29,7 @@ def get_documentable_items_pkgdir(pkgdir): def get_documentable_items(pkgdir): pkgname, pkgdict = get_documentable_items_pkgdir(pkgdir) from py.__.execnet.channel import Channel - # pkgdict['execnet.Channel'] = Channel # XXX doesn't work + pkgdict['execnet.Channel'] = Channel return pkgname, pkgdict def build(pkgdir, dsa, capture): diff --git a/py/apigen/htmlgen.py b/py/apigen/htmlgen.py index 62a98f524..41a4d0f1b 100644 --- a/py/apigen/htmlgen.py +++ b/py/apigen/htmlgen.py @@ -136,7 +136,7 @@ def enumerate_and_color(codelines, firstlineno, enc): break return snippet -def get_obj(pkg, dotted_name): +def get_obj(dsa, pkg, dotted_name): full_dotted_name = '%s.%s' % (pkg.__name__, dotted_name) if dotted_name == '': return pkg @@ -146,8 +146,11 @@ def get_obj(pkg, dotted_name): marker = [] ret = getattr(ret, item, marker) if ret is marker: - raise NameError('can not access %s in %s' % (item, - full_dotted_name)) + try: + return dsa.get_obj(dotted_name) + except KeyError: + raise NameError('can not access %s in %s' % (item, + full_dotted_name)) return ret # the PageBuilder classes take care of producing the docs (using the stuff @@ -314,7 +317,7 @@ class ApiPageBuilder(AbstractPageBuilder): def build_callable_view(self, dotted_name): """ build the html for a class method """ # XXX we may want to have seperate - func = get_obj(self.pkg, dotted_name) + func = get_obj(self.dsa, self.pkg, dotted_name) docstring = func.__doc__ if docstring: docstring = deindent(docstring) @@ -348,7 +351,7 @@ class ApiPageBuilder(AbstractPageBuilder): def build_class_view(self, dotted_name): """ build the html for a class """ - cls = get_obj(self.pkg, dotted_name) + cls = get_obj(self.dsa, self.pkg, dotted_name) # XXX is this a safe check? try: sourcefile = inspect.getsourcefile(cls) @@ -419,7 +422,7 @@ class ApiPageBuilder(AbstractPageBuilder): def build_namespace_view(self, namespace_dotted_name, item_dotted_names): """ build the html for a namespace (module) """ - obj = get_obj(self.pkg, namespace_dotted_name) + obj = get_obj(self.dsa, self.pkg, namespace_dotted_name) docstring = obj.__doc__ snippet = H.NamespaceDescription( H.NamespaceDef(namespace_dotted_name), diff --git a/py/apigen/testing/test_apigen_functional.py b/py/apigen/testing/test_apigen_functional.py index 094c4a65c..1f3f01679 100644 --- a/py/apigen/testing/test_apigen_functional.py +++ b/py/apigen/testing/test_apigen_functional.py @@ -110,7 +110,7 @@ def setup_fs_project(name): def test_get_documentable_items(): fs_root, package_name = setup_fs_project('test_get_documentable_items') - pkgname, documentable = apigen.get_documentable_items( + pkgname, documentable = apigen.get_documentable_items_pkgdir( fs_root.join(package_name)) assert pkgname == 'pak' assert sorted(documentable.keys()) == [ diff --git a/py/misc/testing/test_update_website.py b/py/misc/testing/test_update_website.py index b5ec044ab..5f5974057 100644 --- a/py/misc/testing/test_update_website.py +++ b/py/misc/testing/test_update_website.py @@ -35,13 +35,17 @@ def setup_pkg(testname): def test_foo(): assert foo(1) == 2 """)) - initfile = pkgpath.ensure('__init__.py').write(py.code.Source("""\ + initfile = pkgpath.ensure('__init__.py').write(py.code.Source(""" import py from py.__.initpkg import initpkg initpkg(__name__, exportdefs={ 'sub.foo': ('./mod.py', 'foo'), }) """)) + initfile = pkgpath.ensure('apigen/apigen.py').write(py.code.Source(""" + from py.__.apigen.apigen import build, \ + get_documentable_items_pkgdir as get_documentable_items + """)) return pkgpath def test_run_tests():