Advertisement
BugFix

Untitled

Jan 2nd, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. import os.path, inspect
  2.  
  3. def sig(func):
  4.     argspec = inspect.getargspec(func)
  5.     return func.__name__ + inspect.formatargspec(*argspec)
  6.  
  7. pkg = 'numpy'    ##### Hier das Paket eintragen, für das die API erstellt werden soll
  8. i = __import__(pkg, fromlist=[''])
  9.  
  10. subs_dir = os.path.dirname(i.__file__)
  11. subs = [d for d in os.listdir(subs_dir) if os.path.isfile(os.path.join(subs_dir, d + '/__init__.py'))]
  12.  
  13. for s in subs:
  14.     p = '%s.%s' % (pkg, s)
  15.     try:
  16.         i = __import__(p, fromlist=[''])
  17.         cont = dir(i)
  18.  
  19.         bloat = ['Notes', 'Examples', 'Raises', 'See Also', 'References', 'Methods']
  20.  
  21.         for c in cont:
  22.             if c and c[0].isalpha() and c[-1].isalnum():
  23.                 doc_str = getattr(i, c).__doc__
  24.                 for b in bloat:
  25.                     if doc_str: doc_str = doc_str.split(b)[0]
  26.                 if doc_str: doc_str = doc_str.replace('\n', '\\n').replace('    ','\\t')
  27.                 if inspect.isfunction(getattr(i, c)):
  28.                     print '%s.%s\\n%s' % (p, sig(getattr(i, c)), doc_str)
  29.     except: pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement