File: deterministic-sort.patch

package info (click to toggle)
epydoc 3.0.1%2Bdfsg-14
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 17,540 kB
  • ctags: 30,686
  • sloc: python: 14,373; sh: 97; makefile: 59
file content (50 lines) | stat: -rw-r--r-- 2,617 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Author: Val Lorentz <progval@progval.net>
Description: Make class and module ordering predictable.
 A lot of Debian packages rely on Epydoc during their build process.  By
 default, Eypdoc-generated documentation is "unreproducible", meaning that the
 content of the generated files changes from build to build even if the source
 tree does not. 
 .
 Class trees written by Epydoc list classes in an order that varies across
 builds.  This patch applies a total order on classes (orders on class name,
 then module, then package, then parent package, etc.) instead of a partial one
 (only class name).  It also adds ordering for modules.
 .
 This patch was contributed by the Debian Reproducible Builds effort [1].
 [1]: https://wiki.debian.org/ReproducibleBuilds
Bug: https://sourceforge.net/p/epydoc/bugs/370/
Bug-Debian: http://bugs.debian.org/795835
Forwarded: https://sourceforge.net/p/epydoc/bugs/370/
Last-Update: 2015-08-17
diff -u -r epydoc-3.0.1+dfsg.old/epydoc/docwriter/html.py epydoc-3.0.1+dfsg/epydoc/docwriter/html.py
--- epydoc-3.0.1+dfsg.old/epydoc/docwriter/html.py	2015-08-16 18:57:38.152484836 +0000
+++ epydoc-3.0.1+dfsg/epydoc/docwriter/html.py	2015-08-17 09:59:14.756288022 +0000
@@ -404,6 +404,7 @@
             imports=False, packages=False, bases=False, submodules=False, 
             subclasses=False, private=self._show_private))
         self.module_list = [d for d in valdocs if isinstance(d, ModuleDoc)]
+        self.module_list.sort(key=lambda x:(x.filename, x.path))
         """The list of L{ModuleDoc}s for the documented modules."""
         self.module_set = set(self.module_list)
         """The set of L{ModuleDoc}s for the documented modules."""
@@ -1012,7 +1013,8 @@
                             #class_set.add(base)
  
         out('<ul class="nomargin-top">\n')
-        for doc in sorted(class_set, key=lambda c:c.canonical_name[-1]):
+        sort_key = lambda c:tuple(reversed(c.canonical_name))
+        for doc in sorted(class_set, key=sort_key):
             if doc.bases != UNKNOWN and len(doc.bases)==0:
                 self.write_class_tree_item(out, doc, class_set)
         out('</ul>\n')
@@ -2817,7 +2819,8 @@
         >>> # endif
         >>> if doc.subclasses:
             <ul>
-        >>>   for subclass in sorted(set(doc.subclasses), key=lambda c:c.canonical_name[-1]):
+        >>>   sort_key = lambda c:tuple(reversed(c.canonical_name))
+        >>>   for subclass in sorted(set(doc.subclasses), key=sort_key):
         >>>     if subclass in class_set:
         >>>       self.write_class_tree_item(out, subclass, class_set)
         >>>     #endif