[Epydoc-commits] SF.net SVN: epydoc: [1450] trunk/epydoc/src/epydoc
Brought to you by:
edloper
|
From: <ed...@us...> - 2007-02-11 04:04:29
|
Revision: 1450
http://svn.sourceforge.net/epydoc/?rev=1450&view=rev
Author: edloper
Date: 2007-02-10 20:04:28 -0800 (Sat, 10 Feb 2007)
Log Message:
-----------
- Fixed SF bug 1657050, which was caused because the introspector decided
not to introspect values that it knew were imported; but it then turned
out that it should have introspected them, because they were explicitly
listed in __all__. The patch changes the docintrospector to
introspect all values listed in __all__.
Modified Paths:
--------------
trunk/epydoc/src/epydoc/docintrospecter.py
trunk/epydoc/src/epydoc/test/docintrospecter.doctest
Modified: trunk/epydoc/src/epydoc/docintrospecter.py
===================================================================
--- trunk/epydoc/src/epydoc/docintrospecter.py 2007-02-11 03:18:26 UTC (rev 1449)
+++ trunk/epydoc/src/epydoc/docintrospecter.py 2007-02-11 04:04:28 UTC (rev 1450)
@@ -240,6 +240,14 @@
if module_doc.package not in (None, UNKNOWN):
module_doc.package.submodules.append(module_doc)
+ # Look up the module's __all__ attribute (public names).
+ public_names = None
+ if hasattr(module, '__all__'):
+ try:
+ public_names = set([str(name) for name in module.__all__])
+ except KeyboardInterrupt: raise
+ except: pass
+
# Record the module's variables.
module_doc.variables = {}
for child_name in dir(module):
@@ -249,7 +257,10 @@
# Create a VariableDoc for the child, and introspect its
# value if it's defined in this module.
container = get_containing_module(child)
- if container is not None and container == module_doc.canonical_name:
+ if ((container is not None and
+ container == module_doc.canonical_name) or
+ (public_names is not None and
+ child_name in public_names)):
# Local variable.
child_val_doc = introspect_docs(child, context=module_doc,
module_name=dotted_name)
@@ -278,22 +289,18 @@
container=module_doc,
docs_extracted_by='introspecter')
+ # If the module's __all__ attribute is set, use it to set the
+ # variables public/private status and imported status.
+ if public_names is not None:
+ if child_name in public_names:
+ child_var_doc.is_public = True
+ if not isinstance(child_var_doc, ModuleDoc):
+ child_var_doc.is_imported = False
+ else:
+ child_var_doc.is_public = False
+
module_doc.variables[child_name] = child_var_doc
- # Record the module's __all__ attribute (public names).
- if hasattr(module, '__all__'):
- try:
- public_names = set([str(name) for name in module.__all__])
- for name, var_doc in module_doc.variables.items():
- if name in public_names:
- var_doc.is_public = True
- if not isinstance(var_doc, ModuleDoc):
- var_doc.is_imported = False
- else:
- var_doc.is_public = False
- except KeyboardInterrupt: raise
- except: pass
-
return module_doc
#////////////////////////////////////////////////////////////
Modified: trunk/epydoc/src/epydoc/test/docintrospecter.doctest
===================================================================
--- trunk/epydoc/src/epydoc/test/docintrospecter.doctest 2007-02-11 03:18:26 UTC (rev 1449)
+++ trunk/epydoc/src/epydoc/test/docintrospecter.doctest 2007-02-11 04:04:28 UTC (rev 1450)
@@ -614,3 +614,24 @@
+- name = 'b'
+- value
+- ClassDoc for epydoc_test.B [1] (defined above)
+
+Closed Bugs
+===========
+
+SF Bug [ 1657050 ] Builtins not resolved in "os"
+------------------------------------------------
+If a variable is listed in __all__, then we need to introspect it,
+even if we know for certain that it's imported. Before this bug
+was fixed, the following test generated a generic 'ValueDoc' value
+instead of a 'RoutineDoc' value, because it didn't introspect the
+value of getcwd.
+
+ >>> x = runintrospecter(s="""
+ ... __all__ = ['getcwd']
+ ... from os import getcwd
+ ... """, attribs='variables value')
+ ModuleDoc for epydoc_test [0]
+ +- variables
+ +- getcwd => VariableDoc for epydoc_test.getcwd [1]
+ +- value
+ +- RoutineDoc [2]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|