[Epydoc-commits] SF.net SVN: epydoc: [1645] trunk/epydoc/src/epydoc/docintrospecter.py
Brought to you by:
edloper
From: <ed...@us...> - 2007-09-25 21:37:09
|
Revision: 1645 http://epydoc.svn.sourceforge.net/epydoc/?rev=1645&view=rev Author: edloper Date: 2007-09-25 14:35:17 -0700 (Tue, 25 Sep 2007) Log Message: ----------- - Moved the code that checks for submodules that are shadowed by vars in their containing package(s) -- this is now done inside get_canonical_name(). This ensures that it's always done -- previously, this could get skipped if a module had already been introspected & put into the cache before docbuilder tried to build the docs for the module. - Apparently, inspect.findsource has a bug that can cause it to raise IndexError sometimes (not sure exactly when). If it does, then catch the error, and print a warning, but don't die. Modified Paths: -------------- trunk/epydoc/src/epydoc/docintrospecter.py Modified: trunk/epydoc/src/epydoc/docintrospecter.py =================================================================== --- trunk/epydoc/src/epydoc/docintrospecter.py 2007-09-25 18:42:40 UTC (rev 1644) +++ trunk/epydoc/src/epydoc/docintrospecter.py 2007-09-25 21:35:17 UTC (rev 1645) @@ -116,6 +116,10 @@ # If we've already introspected this value, then simply return # its ValueDoc from our cache. if pyid in _introspected_values: + # If the file is a script, then adjust its name. + if is_script and filename is not None: + _valuedoc_cache[pyid].canonical_name = DottedName( + munge_script_name(str(filename))) return _valuedoc_cache[pyid] # Create an initial value doc for this value & add it to the cache. @@ -130,11 +134,7 @@ if val_doc.canonical_name is UNKNOWN and name is not None: val_doc.canonical_name = DottedName(name) - # If we were given a filename, but didn't manage to get a - # canonical name, then the module defined by the given file - # must be shadowed by a variable in its parent package(s). - # E.g., this happens with `curses.wrapper`. Add a "'" to - # the end of the name to distinguish it from the variable. + # If the file is a script, then adjust its name. if is_script and filename is not None: val_doc.canonical_name = DottedName(munge_script_name(str(filename))) @@ -606,7 +606,21 @@ # Get the name via introspection. if isinstance(value, ModuleType): - dotted_name = DottedName(value.__name__, strict=strict) + try: + dotted_name = DottedName(value.__name__, strict=strict) + # If the module is shadowed by a variable in its parent + # package(s), then add a prime mark to the end, to + # differentiate it from the variable that shadows it. + if verify_name(value, dotted_name) is UNKNOWN: + log.warning("Module %s is shadowed by a variable with " + "the same name." % shadowed_name) + # Note -- this return bypasses verify_name check: + return DottedName(value.__name__+"'") + except DottedName.InvalidDottedName: + # Name is not a valid Python identifier -- treat as script. + if hasattr(value, '__file__'): + filename = '%s' % value.__str__ + dotted_name = DottedName(munge_script_name(filename)) elif isclass(value): if value.__module__ == '__builtin__': @@ -945,6 +959,9 @@ return lineno + 1 except IOError: pass except TypeError: pass + except IndexError: + log.warning('inspect.findsource(%s) raised IndexError' + % api_doc.canonical_name) return None class _DevNull: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |