File: 0004-Use-pydoc.visiblename-to-filter-doc-generation.patch

package info (click to toggle)
pydispatcher 2.0.5-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 444 kB
  • sloc: python: 1,079; makefile: 10
file content (40 lines) | stat: -rw-r--r-- 1,791 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
From: Neil Muller <drnlmuller+debian@gmail.com>
Date: Fri, 27 Dec 2019 11:53:28 +0200
Subject: Use pydoc.visiblename to filter doc generation

To improve the reproduciblity of the documentation build, we use the
pydoc.visiblename function to filter out private attributes which
contain path information, such as __file__ and __cached__ .
---
 docs/pydoc/pydoc2.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/docs/pydoc/pydoc2.py b/docs/pydoc/pydoc2.py
index f5bfcaa..12ab96a 100644
--- a/docs/pydoc/pydoc2.py
+++ b/docs/pydoc/pydoc2.py
@@ -42,6 +42,8 @@ class DefaultFormatter(pydoc.HTMLDoc):
         classes, cdict = [], {}
         for key, value in inspect.getmembers(object, inspect.isclass):
             if (inspect.getmodule(value) or object) is object:
+                if not pydoc.visiblename(key, None, object):
+                    continue
                 classes.append((key, value))
                 cdict[key] = cdict[value] = '#' + key
         for key, value in classes:
@@ -55,11 +57,15 @@ class DefaultFormatter(pydoc.HTMLDoc):
         funcs, fdict = [], {}
         for key, value in inspect.getmembers(object, inspect.isroutine):
             if inspect.isbuiltin(value) or inspect.getmodule(value) is object:
+                if not pydoc.visiblename(key, None, object):
+                    continue
                 funcs.append((key, value))
                 fdict[key] = '#-' + key
                 if inspect.isfunction(value): fdict[value] = fdict[key]
         data = []
         for key, value in inspect.getmembers(object, pydoc.isdata):
+            if not pydoc.visiblename(key, None, object):
+                continue
             data.append((key, value))
 
         doc = self.markup(pydoc.getdoc(object), self.preformat, fdict, cdict)