[Epydoc-commits] SF.net SVN: epydoc: [1384] trunk/epydoc/src/epydoc
Brought to you by:
edloper
From: <dva...@us...> - 2006-09-11 13:42:21
|
Revision: 1384 http://svn.sourceforge.net/epydoc/?rev=1384&view=rev Author: dvarrazzo Date: 2006-09-11 06:42:10 -0700 (Mon, 11 Sep 2006) Log Message: ----------- - Introspecter doesn't document the object resulting from a "from __future__" statement. Because the check deals with the implementation of a quasi-magic module, guard from unexpected implementation changes. In such case, issue a single warning and don't barf. The current implementation is tested with Python 2.4.3. 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 2006-09-11 12:34:31 UTC (rev 1383) +++ trunk/epydoc/src/epydoc/docintrospecter.py 2006-09-11 13:42:10 UTC (rev 1384) @@ -255,6 +255,10 @@ container=module_doc, docs_extracted_by='introspecter') elif container is None or module_doc.canonical_name is UNKNOWN: + + # Don't introspect stuff "from __future__" + if is_future_feature(child): continue + # Possibly imported variable. child_val_doc = introspect_docs(child, context=module_doc) child_var_doc = VariableDoc(name=child_name, @@ -483,6 +487,31 @@ """ return isinstance(object, (TypeType, ClassType)) +__future_check_works = None + +def is_future_feature(object): + """ + Return True if C{object} results from a C{from __future__ import feature"} + statement. + """ + # Guard from unexpected implementation changes of the __future__ module. + global __future_check_works + if __future_check_works is not None: + if __future_check_works: + import __future__ + return isinstance(object, __future__._Feature) + else: + return False + else: + __future_check_works = True + try: + return is_future_feature(object) + except: + __future_check_works = False + log.warning("Troubles inspecting __future__. Python implementation" + " may have been changed.") + return False + def get_docstring(value): """ Return the docstring for the given value; or C{None} if it Modified: trunk/epydoc/src/epydoc/test/docintrospecter.doctest =================================================================== --- trunk/epydoc/src/epydoc/test/docintrospecter.doctest 2006-09-11 12:34:31 UTC (rev 1383) +++ trunk/epydoc/src/epydoc/test/docintrospecter.doctest 2006-09-11 13:42:10 UTC (rev 1384) @@ -520,6 +520,16 @@ +- ModuleDoc for re [4] +- variables = {} + >>> runintrospecter(s=""" + ... from __future__ import division + ... from re import match + ... """, + ... attribs='variables value') + ModuleDoc for epydoc_test [0] + +- variables + +- match => VariableDoc for epydoc_test.match [1] + +- value + +- ValueDoc for sre.match [2] Unicode ======= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |