Skip to content

Instantly share code, notes, and snippets.

@MurphyMc
Created March 21, 2020 23:42
Show Gist options
  • Select an option

  • Save MurphyMc/88707d0b18762b523314625f7bf50848 to your computer and use it in GitHub Desktop.

Select an option

Save MurphyMc/88707d0b18762b523314625f7bf50848 to your computer and use it in GitHub Desktop.
diff between original pydoc.py circa August 2011 and pox-pydoc.py
--- pydoc.py 2020-03-21 16:30:43.000000000 -0700
+++ pox-pydoc.py 2020-03-21 16:39:25.000000000 -0700
@@ -44,6 +44,9 @@
Richard Chamberlain, for the first implementation of textdoc.
"""
+import sys
+sys.path.append('..')
+
# Known bugs that can't be fixed here:
# - imp.load_module() cannot be prevented from clobbering existing
# loaded modules, so calling synopsis() on a binary module file
@@ -496,6 +499,8 @@
def classlink(self, object, modname):
"""Make a link for a class."""
name, module = object.__name__, sys.modules.get(object.__module__)
+ if modname == '__builtin__': #MM
+ return classname(object, object.__module__) #MM
if hasattr(module, name) and getattr(module, name) is object:
return '<a href="%s.html#%s">%s</a>' % (
module.__name__, name, classname(object, modname))
@@ -593,12 +598,14 @@
linkedname = join(links + parts[-1:], '.')
head = '<big><big><strong>%s</strong></big></big>' % linkedname
try:
- path = inspect.getabsfile(object)
+ path = inspect.getfile(object)
+ if path.endswith('.pyc'): path = path[:-1]
url = path
if sys.platform == 'win32':
import nturl2path
url = nturl2path.pathname2url(path)
- filelink = '<a href="file:%s">%s</a>' % (url, path)
+ if path.startswith('./'): path = path[2:]
+ filelink = '<a href="../../hg/pox/file/tip/%s">%s</a>' % (url, path)
except TypeError:
filelink = '(built-in)'
info = []
@@ -809,6 +816,18 @@
except TypeError:
attrs.sort(lambda t1, t2: cmp(t1[0], t2[0])) # 2.3 compat
+ from pox.lib.revent.revent import EventMixin
+ if hasattr(object, '_eventMixin_events') and issubclass(object, EventMixin):
+ events = list(object._eventMixin_events)
+ if len(events) > 0:
+ events.sort(key=lambda t: t.__name__)
+ hr.maybe()
+ push('<dl><dt>Class-level events:</dt>\n')
+ for e in events:
+ push('<dd>%s</dd>\n' % self.classlink(e,
+ object.__module__))
+ push('</dl>\n')
+
# Pump out the attrs, segregated by kind.
attrs = spill('Methods %s' % tag, attrs,
lambda t: t[1] == 'method')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment