[py-svn] r38183 - in py/trunk/py: apigen apigen/testing misc/testing

guido at codespeak.net guido at codespeak.net
Thu Feb 8 18:28:57 CET 2007


Author: guido
Date: Thu Feb  8 18:28:55 2007
New Revision: 38183

Modified:
   py/trunk/py/apigen/apigen.py
   py/trunk/py/apigen/htmlgen.py
   py/trunk/py/apigen/testing/test_apigen_functional.py
   py/trunk/py/misc/testing/test_update_website.py
Log:
Made that py.execnet.Channel (referring to py.__.execnet.channel.Channel) is
picked up by the apigen doc generator, fixed some bugs that made that that
didn't work previously.


Modified: py/trunk/py/apigen/apigen.py
==============================================================================
--- py/trunk/py/apigen/apigen.py	(original)
+++ py/trunk/py/apigen/apigen.py	Thu Feb  8 18:28:55 2007
@@ -29,7 +29,7 @@
 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):

Modified: py/trunk/py/apigen/htmlgen.py
==============================================================================
--- py/trunk/py/apigen/htmlgen.py	(original)
+++ py/trunk/py/apigen/htmlgen.py	Thu Feb  8 18:28:55 2007
@@ -136,7 +136,7 @@
             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 @@
         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 @@
     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 @@
 
     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 @@
 
     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),

Modified: py/trunk/py/apigen/testing/test_apigen_functional.py
==============================================================================
--- py/trunk/py/apigen/testing/test_apigen_functional.py	(original)
+++ py/trunk/py/apigen/testing/test_apigen_functional.py	Thu Feb  8 18:28:55 2007
@@ -110,7 +110,7 @@
 
 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()) ==  [

Modified: py/trunk/py/misc/testing/test_update_website.py
==============================================================================
--- py/trunk/py/misc/testing/test_update_website.py	(original)
+++ py/trunk/py/misc/testing/test_update_website.py	Thu Feb  8 18:28:55 2007
@@ -35,13 +35,17 @@
         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():



More information about the pytest-commit mailing list