Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os.path, inspect
- def sig(func):
- argspec = inspect.getargspec(func)
- return func.__name__ + inspect.formatargspec(*argspec)
- pkg = 'numpy' ##### Hier das Paket eintragen, für das die API erstellt werden soll
- i = __import__(pkg, fromlist=[''])
- subs_dir = os.path.dirname(i.__file__)
- subs = [d for d in os.listdir(subs_dir) if os.path.isfile(os.path.join(subs_dir, d + '/__init__.py'))]
- for s in subs:
- p = '%s.%s' % (pkg, s)
- try:
- i = __import__(p, fromlist=[''])
- cont = dir(i)
- bloat = ['Notes', 'Examples', 'Raises', 'See Also', 'References', 'Methods']
- for c in cont:
- if c and c[0].isalpha() and c[-1].isalnum():
- doc_str = getattr(i, c).__doc__
- for b in bloat:
- if doc_str: doc_str = doc_str.split(b)[0]
- if doc_str: doc_str = doc_str.replace('\n', '\\n').replace(' ','\\t')
- if inspect.isfunction(getattr(i, c)):
- print '%s.%s\\n%s' % (p, sig(getattr(i, c)), doc_str)
- except: pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement