import epydoc import epydoc.apidoc import epydoc.cli import epydoc.docbuilder import epydoc.docintrospecter import epydoc.docwriter.html import epydoc.markup.epytext import inspect import PyQt4.QtCore import sys import types DOC_PAGES = [ ("Hello world!", "doc-hello-world"), ] OUTPUT_DIR = "output" # SIP does some strange stuff with the __dict__ of wrapped C++ classes: # someclass.__dict__["function"] != someclass.function # These little hacks make epydoc generate documentation for the actual functions # instead of their sip.methoddescriptor wrappers. def is_pyqt_wrapper_class(thing): return epydoc.docintrospecter.isclass(thing) and \ isinstance(thing, PyQt4.QtCore.pyqtWrapperType) def introspect_pyqt_wrapper_class(thing, doc, module_name=None): # Inspect the class as normal doc = epydoc.docintrospecter.introspect_class(thing, doc, module_name=module_name) # Re-inspect the actual member functions for name in thing.__dict__.keys(): if name in doc.variables and hasattr(thing, name): actual_var = getattr(thing, name) val_doc = epydoc.docintrospecter.introspect_docs( actual_var, context=doc, module_name=module_name) var_doc = epydoc.docintrospecter.VariableDoc( name=name, value=val_doc, container=doc, docs_extracted_by='introspecter') doc.variables[name] = var_doc return doc epydoc.docintrospecter.register_introspecter(is_pyqt_wrapper_class, introspect_pyqt_wrapper_class) # Monkey-patch some functions in the HTML docwriter to show a table of contents # down the side of each page, instead of in a separate frame, and to do external # API links. original_write_header = epydoc.docwriter.html.HTMLWriter.write_header def my_write_header(self, out, title): original_write_header(self, out, title) out('
') out('