'Main build method.
First updates the environment, and then calls :meth:`write`.'

def build(self, docnames, summary=None, method='update'):

    if summary:
        logger.info(((bold(('building    [%s]' % self.name)) + ':    ') + summary))
    with logging.pending_warnings():
        updated_docnames = set(self.env.update(self.config, self.srcdir, self.doctreedir))
    doccount = len(updated_docnames)
    logger.info(bold('looking    for    now-outdated    files...    '), nonl=1)
    for docname in self.env.check_dependents(self.app, updated_docnames):
        updated_docnames.add(docname)
    outdated = (len(updated_docnames) - doccount)
    if outdated:
        logger.info('%d    found', outdated)
    else:
        logger.info('none    found')
    if updated_docnames:
        from sphinx.application import ENV_PICKLE_FILENAME
        logger.info(bold('pickling    environment...    '), nonl=True)
        self.env.topickle(path.join(self.doctreedir, ENV_PICKLE_FILENAME))
        logger.info('done')
        logger.info(bold('checking    consistency...    '), nonl=True)
        self.env.check_consistency()
        logger.info('done')
    elif ((method == 'update') and (not docnames)):
        logger.info(bold('no    targets    are    out    of    date.'))
        return
    if (docnames and (docnames != ['__all__'])):
        docnames = (set(docnames) & self.env.found_docs)
    self.parallel_ok = False
    if (parallel_available and (self.app.parallel > 1) and self.allow_parallel):
        self.parallel_ok = True
        for extension in itervalues(self.app.extensions):
            if (not extension.parallel_write_safe):
                logger.warning('the    %s    extension    is    not    safe    for    parallel    writing,    doing    serial    write', extension.name)
                self.parallel_ok = False
                break
    self.finish_tasks = SerialTasks()
    self.write(docnames, list(updated_docnames), method)
    self.finish()
    self.finish_tasks.join()
