[Epydoc-commits] SF.net SVN: epydoc: [1545] trunk/epydoc/src/epydoc/docbuilder.py
Brought to you by:
edloper
|
From: <ed...@us...> - 2007-02-20 19:34:06
|
Revision: 1545
http://svn.sourceforge.net/epydoc/?rev=1545&view=rev
Author: edloper
Date: 2007-02-20 11:34:01 -0800 (Tue, 20 Feb 2007)
Log Message:
-----------
- Check that duplicate item names are not given to build_doc_index;
if they are, then issue a warning and discard dups.
- Check that we don't generate 2 doc items with the same canonical name
from different items. This can happen, e.g., if you run
"epydoc a/x.py b/x.py" where neither a nor b are package directories,
so both modules will have canonical name "x". In this case, issue an
error message, and discard the docs from the second item.
(Otherwise, there would be 2 problems: first, we'd try to merge the
docs of these two modules; and second, we wouldn't have unique names
for them, so we'd end up overwriting the doc files of one with the
doc files of the other.)
Modified Paths:
--------------
trunk/epydoc/src/epydoc/docbuilder.py
Modified: trunk/epydoc/src/epydoc/docbuilder.py
===================================================================
--- trunk/epydoc/src/epydoc/docbuilder.py 2007-02-20 09:54:15 UTC (rev 1544)
+++ trunk/epydoc/src/epydoc/docbuilder.py 2007-02-20 19:34:01 UTC (rev 1545)
@@ -311,6 +311,20 @@
log.start_progress('Building documentation')
progress_estimator = _ProgressEstimator(items)
+ # Check for duplicate item names.
+ item_set = set()
+ for item in items[:]:
+ if item in item_set:
+ log.warning("Name %r given multiple times" % item)
+ items.remove(item)
+ item_set.add(item)
+
+ # Keep track of what top-level canonical names we've assigned, to
+ # make sure there are no naming conflicts. This dict maps
+ # canonical names to the item names they came from (so we can print
+ # useful error messages).
+ canonical_names = {}
+
# Collect (introspectdoc, parsedoc) pairs for each item.
doc_pairs = []
for item in items:
@@ -346,6 +360,20 @@
doc_pairs.append(_get_docs_from_pyobject(
item, options, progress_estimator))
+ # Make sure there are no naming conflicts.
+ name = (getattr(doc_pairs[-1][0], 'canonical_name', None) or
+ getattr(doc_pairs[-1][1], 'canonical_name', None))
+ if name in canonical_names:
+ log.error(
+ 'Two of the specified items, %r and %r, have the same '
+ 'canonical name ("%s"). This may mean that you specified '
+ 'two different files that both use the same module name. '
+ 'Ignoring the second item (%r)' %
+ (canonical_names[name], item, name, canonical_names[name]))
+ doc_pairs.pop()
+ else:
+ canonical_names[name] = item
+
# This will only have an effect if doc_pairs[-1] contains a
# package's docs. The 'not is_module_file(item)' prevents
# us from adding subdirectories if they explicitly specify
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|