def Help(obj=None): '''Usage: help(obj)''' if obj is None: print(Help.__doc__) return out = [] try: out.append("<h2>{}</h2>".format(obj.__name__)) if hasattr(obj, "__doc__"): out.append("<p>{}</p>".format(obj.__doc__)) else: out.append("<p>No docstring found.</p>") except: pass for attr in dir(obj): if attr == "__class__": continue if hasattr(getattr(obj, attr), "__doc__"): if getattr(obj, attr).__doc__: out.append("<h3>{}</h3>".format(attr)) doc = "<p>{}</p>".format(getattr(obj, attr).__doc__) out.append(doc.replace("\n", "<br>")) if not out: raise ReeborgError("This object has no docstring.") else: window.narration("".join(out))
def Help(obj=None): '''Usage: help(obj)''' # yes: lowercase!!! if obj is None: print(Help.__doc__) return out = [] try: out.append("<h2>{}</h2>".format(obj.__name__)) if hasattr(obj, "__doc__"): doc = "<p>{}</p>".format(str(obj.__doc__)) out.append(doc.replace("\n", "<br>")) else: out.append("<p>No docstring found.</p>") except Exception as e: window.console.log("exception in Help", e.__name__) for attr in dir(obj): if attr == "__class__": continue if hasattr(getattr(obj, attr), "__doc__"): if getattr(obj, attr).__doc__: out.append("<h3>{}</h3>".format(attr)) doc = "<p>{}</p>".format(getattr(obj, attr).__doc__) out.append(doc.replace("\n", "<br>")) if not out: raise AttributeError("This object has no docstring.") else: window.narration("".join(out))