Entry
Showing docstrings of modules
Jul 5th, 2000 10:01
Nathan Wallace, Hans Nowak, Snippet 219, J
"""
Packages: text.docstrings;modules_and_packages
"""
"""
I just wrote this short script inspired by this post.. it's a little more
generic, but it's incomplete. feel free to use the code, post
enhancements, etc. it is limited in what it can do-- it won't work for
'os.path', for example, but it's a start.
"""
#!/usr/bin/env python
def showdoc(module):
try:
m = __import__(module)
except ImportError, reason:
print "** import error: %s" % (reason)
return
if hasattr(m, "__doc__") and m.__doc__ != None:
print "-- module documentation --"
print m.__doc__
print "-- end module documentation --"
print
for item in dir(m):
print item
if hasattr(item, "__doc__"):
print " %s" % (item.__doc__)
else:
print " %s has no doc string." % (item)
del m
if __name__ == "__main__":
showdoc("string")