[Epydoc-commits] SF.net SVN: epydoc: [1351] trunk/epydoc/src/epydoc
Brought to you by:
edloper
|
From: <ed...@us...> - 2006-09-06 15:49:53
|
Revision: 1351
http://svn.sourceforge.net/epydoc/?rev=1351&view=rev
Author: edloper
Date: 2006-09-06 08:49:48 -0700 (Wed, 06 Sep 2006)
Log Message:
-----------
- Replaced VariableDoc._get_canonical_name property with a simple
canonical_name attribute. This now gets assigned by docbuilder
at the same time as ValueDoc attributes.
- When assigning canonical names, don't bother to recurse to
GenericValueDoc variables.
- Fixed bug in code to merge parsed & introspected GenericValueDocs,
which was sometimes causing value repr's to not propagate correctly.
Modified Paths:
--------------
trunk/epydoc/src/epydoc/apidoc.py
trunk/epydoc/src/epydoc/docbuilder.py
trunk/epydoc/src/epydoc/docstringparser.py
Modified: trunk/epydoc/src/epydoc/apidoc.py
===================================================================
--- trunk/epydoc/src/epydoc/apidoc.py 2006-09-04 04:09:52 UTC (rev 1350)
+++ trunk/epydoc/src/epydoc/apidoc.py 2006-09-06 15:49:48 UTC (rev 1351)
@@ -568,6 +568,12 @@
variable.
@type: L{ValueDoc}"""
+ canonical_name = UNKNOWN
+ """@ivar: A dotted name that serves as a unique identifier for
+ this C{VariableDoc}. It should be formed by concatenating
+ the C{VariableDoc}'s C{container} with its C{name}.
+ @type: L{DottedName}"""
+
value = UNKNOWN
"""@ivar: The API documentation for this variable's value.
@type: L{ValueDoc}"""
@@ -635,24 +641,6 @@
else:
return '<%s>' % self.__class__.__name__
- def _get_canonical_name(self):
- # Check cache.
- canonical_name = getattr(self, '_canonical_name', None)
- if canonical_name is not None: return canonical_name
- # Otherwise, compute it.
- if (self.container is UNKNOWN or
- self.container.canonical_name is UNKNOWN):
- return UNKNOWN
- else:
- self._canonical_name = self.container.canonical_name + self.name
- return self._canonical_name
- canonical_name = property(_get_canonical_name,
- doc="""A read-only property that can be used to get the variable's
- canonical name. This is formed by taking the varaible's
- container's cannonical name, and adding the variable's name
- to it. (The value is cached upon the first successful
- look-up.)""")
-
def _get_defining_module(self):
if self.container is UNKNOWN:
return UNKNOWN
Modified: trunk/epydoc/src/epydoc/docbuilder.py
===================================================================
--- trunk/epydoc/src/epydoc/docbuilder.py 2006-09-04 04:09:52 UTC (rev 1350)
+++ trunk/epydoc/src/epydoc/docbuilder.py 2006-09-06 15:49:48 UTC (rev 1351)
@@ -678,9 +678,12 @@
# them. E.g., we don't want to merge 2+2 with 4. So just copy
# the inspect_doc's pyval to the parse_doc, and return the parse_doc.
if type(introspect_doc) == type(parse_doc) == GenericValueDoc:
- parse_doc.pyval = introspect_doc.pyval
+ if introspect_doc.pyval is not UNKNOWN:
+ parse_doc.pyval = introspect_doc.pyval
+ if introspect_doc.parse_repr is not UNKNOWN:
+ parse_doc.parse_repr = introspect_doc.parse_repr
parse_doc.docs_extracted_by = 'both'
- return parse_doc
+ return parse_doc.merge_and_overwrite(introspect_doc)
# Perform several sanity checks here -- if we accidentally
# merge values that shouldn't get merged, then bad things can
@@ -1008,9 +1011,16 @@
# Recurse to any contained values.
if isinstance(val_doc, NamespaceDoc):
for var_doc in val_doc.variables.values():
- if var_doc.value is UNKNOWN: continue
+ # Set the variable's canonical name.
varname = DottedName(name, var_doc.name)
-
+ var_doc.canonical_name = varname
+
+ # If the value is unknown, or is a generic value doc, then
+ # the valuedoc doesn't get assigned a name; move on.
+ if (var_doc.value is UNKNOWN
+ or isinstance(var_doc.value, GenericValueDoc)):
+ continue
+
# This check is for cases like curses.wrapper, where an
# imported variable shadows its value's "real" location.
if _var_shadows_self(var_doc, varname):
Modified: trunk/epydoc/src/epydoc/docstringparser.py
===================================================================
--- trunk/epydoc/src/epydoc/docstringparser.py 2006-09-04 04:09:52 UTC (rev 1350)
+++ trunk/epydoc/src/epydoc/docstringparser.py 2006-09-06 15:49:48 UTC (rev 1351)
@@ -205,6 +205,9 @@
field.arg(), field.body())
except ValueError, e: field_warnings.append(str(e))
+ # [XX] If descr is empty but we have a return field,
+ # generate a descr from it..
+
# Extract a summary
if api_doc.summary is None and api_doc.descr is not None:
api_doc.summary = api_doc.descr.summary()
@@ -607,8 +610,9 @@
def set_var_descr(api_doc, ident, descr):
if ident not in api_doc.variables:
- api_doc.variables[ident] = VariableDoc(container=api_doc,
- name=ident)
+ api_doc.variables[ident] = VariableDoc(
+ container=api_doc, name=ident,
+ canonical_name=api_doc.canonical_name+ident)
var_doc = api_doc.variables[ident]
if var_doc.descr not in (None, UNKNOWN):
@@ -619,8 +623,10 @@
def set_var_type(api_doc, ident, descr):
if ident not in api_doc.variables:
- api_doc.variables[ident] = VariableDoc(container=api_doc,
- name=ident)
+ api_doc.variables[ident] = VariableDoc(
+ container=api_doc, name=ident,
+ canonical_name=api_doc.canonical_name+ident)
+
var_doc = api_doc.variables[ident]
if var_doc.type_descr not in (None, UNKNOWN):
raise ValueError(REDEFINED % ('type for '+ident))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|