def _html(docmap, options): """ Create the HTML documentation for the objects in the given documentation map. @param docmap: A documentation map containing the documentation for the objects whose API documentation should be created. @param options: Options from the command-line arguments. @type options: C{dict} """ from epydoc.html import HTMLFormatter # Create the documenter, and figure out how many files it will # generate. html_doc = HTMLFormatter(docmap, **options) num_files = html_doc.num_files() # Write documentation. if options['verbosity'] > 0: print >>sys.stderr, ('Writing HTML docs (%d files) to %r.' % (num_files, options['target'])) progress = _Progress('Writing', options['verbosity'], num_files, 1) try: html_doc.write(options['target'], progress.report) except OSError, e: print >>sys.stderr, '\nError writing docs:\n%s\n' % e
def _documented(self, uid): value = HTMLFormatter._documented(self, uid) if not document_all: if not value: try: if uid._name.startswith("twisted."): # ha ha sucker return True except: pass return value
def document(options, progress, cancel): """ Create the documentation for C{modules}, using the options specified by C{options}. C{document} is designed to be started in its own thread by L{EpydocGUI._go}. @param options: The options to use for generating documentation. This includes keyword options that can be given to L{html.HTMLFormatter}, as well as the option C{outdir}, which controls where the output is written to. @type options: C{dictionary} @param progress: This first element of this list will be modified by C{document} to reflect its progress. This first element will be a number between 0 and 1 while C{document} is creating the documentation; and the string C{"done"} once it finishes creating the documentation. @type progress: C{list} """ progress[0] = 0.02 from epydoc.html import HTMLFormatter from epydoc.objdoc import DocMap, report_param_mismatches from epydoc.imports import import_module, find_modules from epydoc.objdoc import set_default_docformat # Set the default docformat. set_default_docformat(options.get('docformat', 'epytext')) try: # Import the modules. modnames = options['modules'] # First, expand packages. for name in modnames[:]: if os.path.isdir(name): modnames.remove(name) new_modules = find_modules(name) if new_modules: modnames += new_modules sys.stderr.write('!!!Error: %r is not a pacakge\n!!!' % name) modules = [] for (name, num) in zip(modnames, range(len(modnames))): if cancel[0]: exit_thread() sys.stderr.write('***Importing %s\n***' % name) try: module = import_module(name) if module not in modules: modules.append(module) except ImportError, e: sys.stderr.write('!!!Error importing %s: %s\n!!!' % (name, e)) progress[0] += (IMPORT_PROGRESS*0.98)/len(modnames) # Create the documentation map. verbosity = 0 document_bases = 1 document_autogen_vars = 1 inheritance_groups = (options['inheritance'] == 'grouped') inherit_groups = (options['inheritance'] != 'grouped') d = DocMap(verbosity, document_bases, document_autogen_vars, inheritance_groups, inherit_groups) # Build the documentation. for (module, num) in zip(modules, range(len(modules))): if cancel[0]: exit_thread() sys.stderr.write('***Building docs for %s\n***' % module.__name__) d.add(module) progress[0] += (BUILD_PROGRESS*0.98)/len(modules) # Report any param inheritance mismatches. report_param_mismatches(d) # Create the HTML formatter. htmldoc = HTMLFormatter(d, **options) numfiles = htmldoc.num_files() # Set up the progress callback. n = htmldoc.num_files() def progress_callback(path, numfiles=numfiles, progress=progress, cancel=cancel, num=[1]): if cancel[0]: exit_thread() # Find the short name of the file we're writing. (dir, file) = os.path.split(path) (root, d) = os.path.split(dir) if d in ('public', 'private'): fname = os.path.join(d, file) else: fname = file sys.stderr.write('***Writing %s\n***' % fname) progress[0] += (WRITE_PROGRESS*0.98)/numfiles num[0] += 1 # Write the documentation. htmldoc.write(options.get('outdir', 'html'), progress_callback) # We're done. sys.stderr.write('***Finished!\n***') progress[0] = 'done'
class Foo: def _bar(x,y,z): 'This is a sample method' def baz(a,b): ''' @param a: foo @type a: L{Foo} ''' from epydoc.html import HTMLFormatter from epydoc.uid import * import sys print '~'*70 print '~'*70 print HTMLFormatter.format(sys) print '~'*70 print '~'*70 #print HTMLFormatter.format(baz) #print '~'*70 #print '~'*70
def write(self, directory=None, progress_callback=None): HTMLFormatter.write(self, directory, progress_callback) # Write method redirectors self._write_method_redirects(directory)