Description: make subclass traversal and input file handling deterministic
Author: Sascha Steinbiss <sascha@steinbiss.name>
Bug: https://sourceforge.net/p/epydoc/bugs/370/
Bug-Debian: http://bugs.debian.org/825968
Forwarded: https://sourceforge.net/p/epydoc/bugs/370/
Last-Update: 2016-06-13
--- a/epydoc/docbuilder.py
+++ b/epydoc/docbuilder.py
@@ -574,7 +574,7 @@
     subpackage_dirs = set()
     for subdir in pkg_path:
         if os.path.isdir(subdir):
-            for name in os.listdir(subdir):
+            for name in sorted(os.listdir(subdir)):
                 filename = os.path.join(subdir, name)
                 # Is it a valid module filename?
                 if is_module_file(filename):
@@ -660,7 +660,7 @@
         num_items = 0
         
         if is_package_dir(package_dir):
-            for name in os.listdir(package_dir):
+            for name in sorted(os.listdir(package_dir)):
                 filename = os.path.join(package_dir, name)
                 if is_module_file(filename):
                     num_items += 1
--- a/epydoc/docwriter/html.py
+++ b/epydoc/docwriter/html.py
@@ -879,7 +879,8 @@
                     len(doc.subclasses) > 0):
                     out('<dl><dt>Known Subclasses:</dt>\n<dd>\n    ')
                     out('  <ul class="subclass-list">\n')
-                    for i, subclass in enumerate(doc.subclasses):
+                    sort_key = lambda c:tuple(reversed(c.canonical_name))
+                    for i, subclass in enumerate(sorted(set(doc.subclasses), key=sort_key)):
                         href = self.href(subclass, context=doc)
                         if self._val_is_public(subclass): css = ''
                         else: css = ' class="private"'
